|
1 | 1 | /* |
2 | | - * Copyright 2025 ObjectBox Ltd. |
| 2 | + * Copyright 2026 ObjectBox Ltd. <https://objectbox.io> |
3 | 3 | * |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
@@ -103,5 +103,29 @@ private PropertyFlags() { } |
103 | 103 | * However, the deletion process can be triggered by an API call. |
104 | 104 | */ |
105 | 105 | 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; |
106 | 130 | } |
107 | 131 |
|
0 commit comments