comparison src/main/kotlin/name/blackcap/passman/Entry.kt @ 8:698c4a3d758d

Some code clean-up.
author David Barts <n5jrn@me.com>
date Fri, 23 Sep 2022 20:59:52 -0700
parents f245b9a53495
children 72619175004e
comparison
equal deleted inserted replaced
7:f245b9a53495 8:698c4a3d758d
2 2
3 import java.util.* 3 import java.util.*
4 import kotlin.reflect.KProperty 4 import kotlin.reflect.KProperty
5 import kotlin.reflect.full.declaredMemberProperties 5 import kotlin.reflect.full.declaredMemberProperties
6 6
7 class Entry(val name: String, val username: String, val password: CharArray, val notes: String, 7 class Entry(val name: String, val username: String, val password: CharArray, val notes: String?,
8 val created: Date? = null, val modified: Date? = null, val accessed: Date? = null) { 8 val created: Date? = null, val modified: Date? = null, val accessed: Date? = null) {
9 9
10 companion object { 10 companion object {
11 private val FIELD_MAP = mutableMapOf<String, KProperty.Getter<*>>().apply { 11 private val FIELD_MAP = mutableMapOf<String, KProperty.Getter<*>>().apply {
12 Entry::class.declaredMemberProperties.forEach{ 12 Entry::class.declaredMemberProperties.forEach{
57 } 57 }
58 } 58 }
59 59
60 fun printLong(redactPassword: String? = null) { 60 fun printLong(redactPassword: String? = null) {
61 print(redactPassword) 61 print(redactPassword)
62 println("Notes: $notes") 62 println("Notes: ${notes ?: "(none)"}")
63 printDate("Created", created) 63 printDate("Created", created)
64 printDate("Modified", modified) 64 printDate("Modified", modified)
65 printDate("Accessed", accessed) 65 printDate("Accessed", accessed)
66 } 66 }
67 67
75 println("never") 75 println("never")
76 } else { 76 } else {
77 println(ISO8601.format(date)) 77 println(ISO8601.format(date))
78 } 78 }
79 } 79 }
80
81 } 80 }