@@ -29,21 +29,34 @@ data class RawEntity(
29
29
override fun unwrap (): Referencable {
30
30
val entity = RawEntity (
31
31
id = id,
32
+ creationTimestamp = creationTimestamp,
32
33
expirationTimestamp = expirationTimestamp,
33
34
singletons = singletons.mapValues { it.value?.unwrap() },
34
35
collections = collections.mapValues {
35
36
it.value.map { item -> item.unwrap() }.toSet()
36
37
}
37
38
)
39
+ entity.creationTimestamp = creationTimestamp
38
40
entity.expirationTimestamp = expirationTimestamp
39
41
return entity
40
42
}
41
43
44
+ /* * Entity creation time (in millis). */
45
+ @Suppress(" GoodTime" ) // use Instant
46
+ override var creationTimestamp: Long = UNINITIALIZED_TIMESTAMP
47
+ set(value) {
48
+ require(this .creationTimestamp == UNINITIALIZED_TIMESTAMP ) {
49
+ " cannot override creationTimestamp $value "
50
+ }
51
+ @Suppress(" GoodTime" ) // use Instant
52
+ field = value
53
+ }
54
+
42
55
/* * Entity expiration time (in millis). */
43
56
@Suppress(" GoodTime" ) // use Instant
44
- override var expirationTimestamp: Long = NO_EXPIRATION
57
+ override var expirationTimestamp: Long = UNINITIALIZED_TIMESTAMP
45
58
set(value) {
46
- require(this .expirationTimestamp == NO_EXPIRATION ) {
59
+ require(this .expirationTimestamp == UNINITIALIZED_TIMESTAMP ) {
47
60
" cannot override expirationTimestamp $value "
48
61
}
49
62
@Suppress(" GoodTime" ) // use Instant
@@ -62,7 +75,8 @@ data class RawEntity(
62
75
id: ReferenceId = NO_REFERENCE_ID ,
63
76
singletonFields: Set <FieldName > = emptySet(),
64
77
collectionFields: Set <FieldName > = emptySet(),
65
- expirationTimestamp: Long = NO_EXPIRATION
78
+ creationTimestamp: Long = UNINITIALIZED_TIMESTAMP ,
79
+ expirationTimestamp: Long = UNINITIALIZED_TIMESTAMP
66
80
) : this (
67
81
id,
68
82
singletonFields.associateWith { null },
@@ -73,17 +87,21 @@ data class RawEntity(
73
87
74
88
companion object {
75
89
const val NO_REFERENCE_ID = " NO REFERENCE ID"
76
- const val NO_EXPIRATION : Long = - 1
90
+ const val UNINITIALIZED_TIMESTAMP : Long = - 1
77
91
}
78
92
}
79
93
80
94
fun RawEntity (
81
95
id : String ,
82
96
singletons : Map <FieldName , Referencable ?>,
83
97
collections : Map <FieldName , Set <Referencable >>,
98
+ creationTimestamp : Long ,
84
99
expirationTimestamp : Long
85
100
) = RawEntity (
86
101
id,
87
102
singletons,
88
103
collections
89
- ).also { it.expirationTimestamp = expirationTimestamp }
104
+ ).also {
105
+ it.creationTimestamp = creationTimestamp
106
+ it.expirationTimestamp = expirationTimestamp
107
+ }
0 commit comments