From 8508d9f6e9f91f9a9a09039e2598c24d481d6c24 Mon Sep 17 00:00:00 2001 From: Paul-Louis NECH Date: Sun, 17 Feb 2019 17:52:24 +0100 Subject: [PATCH] refactor(model): Docs/indent/companion --- app/src/main/java/fr/plnech/lifelogger/model/DataPoint.kt | 18 +++++++++++++----- app/src/main/java/fr/plnech/lifelogger/model/Log.kt | 10 ++++++++-- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/fr/plnech/lifelogger/model/DataPoint.kt b/app/src/main/java/fr/plnech/lifelogger/model/DataPoint.kt index b51ef74..ba0da5e 100644 --- a/app/src/main/java/fr/plnech/lifelogger/model/DataPoint.kt +++ b/app/src/main/java/fr/plnech/lifelogger/model/DataPoint.kt @@ -20,9 +20,13 @@ package fr.plnech.lifelogger.model import java.util.* import kotlin.collections.HashMap -private const val NONE: Int = Int.MIN_VALUE - -data class DataPoint(val date: Date = Date(), private val metadata: HashMap = HashMap()) { +/** + * An event tracked with some associated metadata. + */ +data class DataPoint( + val date: Date = Date(), + private val metadata: HashMap = HashMap() +) { constructor(name: String, count: Int = NONE) : this() { metadata["name"] = name @@ -35,11 +39,15 @@ data class DataPoint(val date: Date = Date(), private val metadata: HashMap = ArrayList()) { +/** + * A Log of events to track. + */ +class Log( + val name: String, + private val dataPoints: ArrayList = ArrayList() +) { fun addPoint(dataPoint: DataPoint) { dataPoints.add(dataPoint) @@ -25,7 +31,7 @@ class Log(val name: String, private val dataPoints : ArrayList = Arra override fun toString(): String { val b = StringBuilder("$name: ") - dataPoints.forEach({b.append(it).append(" | ")}) + dataPoints.forEach({ b.append(it).append(" | ") }) return b.removeSuffix("| ").toString() } } \ No newline at end of file -- libgit2 0.27.0