Skip to content

Commit e24210b

Browse files
PropertyFlags: add Sync clock and precedence
1 parent 72dc25d commit e24210b

1 file changed

Lines changed: 25 additions & 1 deletion

File tree

objectbox-java/src/main/java/io/objectbox/model/PropertyFlags.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2025 ObjectBox Ltd.
2+
* Copyright 2026 ObjectBox Ltd. <https://objectbox.io>
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -103,5 +103,29 @@ private PropertyFlags() { }
103103
* However, the deletion process can be triggered by an API call.
104104
*/
105105
public static final int EXPIRATION_TIME = 65536;
106+
/**
107+
* Marks a Long (64-bit integer) property as a the sync clock, a "hybrid logical clock" to resolve Sync conflicts.
108+
* These clock values allow "last write wins" conflict resolution.
109+
* There can be only one sync clock per sync entity type; which is also recommended for basic conflict resolution.
110+
* For new objects, initialize a property value to 0 to reserve "a slot" in the object data.
111+
* ObjectBox Sync will update this property automatically on put operations.
112+
* As a hybrid clock, it combines a wall clock with a logical counter to compensate for some clock skew effects.
113+
*/
114+
public static final int SYNC_CLOCK = 131072;
115+
/**
116+
* Marks a Long (64-bit integer) property as a the "sync precedence" to customize Sync conflict resolution.
117+
* Developer-assigned precedence values are then used to resolve conflicts via "higher precedence wins".
118+
* Defining and assigning precedence values are completely in the hands of the developer (the ObjectBox user).
119+
* There can be only one sync precedence per sync entity type.
120+
* Typically, it is combined with a sync clock, with the latter being the tie-breaker for equal precedence values.
121+
* This can be used to model some business logic use cases, for example:
122+
* - Setting an object a special state, e.g. a final/closed state, which may not be overwritten by a lesser state
123+
* - Multiple workflow states that occur linearly (i.e. using an increasing precedence value)
124+
* - Role based, e.g. only admins set or increment the precedence..
125+
* - “Checkpoint timestamps:” e.g. when some changes are “checked” as in approved/applied,
126+
* the precedence is updated to the current timestamp.
127+
* “Non-checked” or previously checkpointed changes are disregarded.
128+
*/
129+
public static final int SYNC_PRECEDENCE = 262144;
106130
}
107131

0 commit comments

Comments
 (0)