Skip to content

Commit 6d20ffe

Browse files
committed
[ECO-5076] Updated ObjectsState enum to use PascalCase instead of all uppercase
1 parent 2e5a811 commit 6d20ffe

6 files changed

Lines changed: 21 additions & 21 deletions

File tree

live-objects/src/main/kotlin/io/ably/lib/objects/DefaultLiveObjects.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ internal class DefaultLiveObjects(internal val channelName: String, internal val
2222
*/
2323
internal val objectsPool = ObjectsPool(this)
2424

25-
internal var state = ObjectsState.INITIALIZED
25+
internal var state = ObjectsState.Initialized
2626

2727
/**
2828
* @spec RTO4 - Used for handling object messages and object sync messages
@@ -155,7 +155,7 @@ internal class DefaultLiveObjects(internal val channelName: String, internal val
155155
Log.v(tag, "Objects.onAttached() channel=$channelName, hasObjects=$hasObjects")
156156

157157
// RTO4a
158-
val fromInitializedState = this@DefaultLiveObjects.state == ObjectsState.INITIALIZED
158+
val fromInitializedState = this@DefaultLiveObjects.state == ObjectsState.Initialized
159159
if (hasObjects || fromInitializedState) {
160160
// should always start a new sync sequence if we're in the initialized state, no matter the HAS_OBJECTS flag value.
161161
// this guarantees we emit both "syncing" -> "synced" events in that order.

live-objects/src/main/kotlin/io/ably/lib/objects/ObjectsManager.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ internal class ObjectsManager(private val liveObjects: DefaultLiveObjects): Obje
2727
* @spec RTO8 - Buffers messages if not synced, applies immediately if synced
2828
*/
2929
internal fun handleObjectMessages(objectMessages: List<ObjectMessage>) {
30-
if (liveObjects.state != ObjectsState.SYNCED) {
30+
if (liveObjects.state != ObjectsState.Synced) {
3131
// RTO7 - The client receives object messages in realtime over the channel concurrently with the sync sequence.
3232
// Some of the incoming object messages may have already been applied to the objects described in
3333
// the sync sequence, but others may not; therefore we must buffer these messages so that we can apply
@@ -77,7 +77,7 @@ internal class ObjectsManager(private val liveObjects: DefaultLiveObjects): Obje
7777
bufferedObjectOperations.clear() // RTO5a2b
7878
syncObjectsDataPool.clear() // RTO5a2a
7979
currentSyncId = syncId
80-
stateChange(ObjectsState.SYNCING, false)
80+
stateChange(ObjectsState.Syncing, false)
8181
}
8282

8383
/**
@@ -95,7 +95,7 @@ internal class ObjectsManager(private val liveObjects: DefaultLiveObjects): Obje
9595
bufferedObjectOperations.clear() // RTO5c5
9696
syncObjectsDataPool.clear() // RTO5c4
9797
currentSyncId = null // RTO5c3
98-
stateChange(ObjectsState.SYNCED, deferStateEvent)
98+
stateChange(ObjectsState.Synced, deferStateEvent)
9999
}
100100

101101
/**

live-objects/src/main/kotlin/io/ably/lib/objects/ObjectsState.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ import kotlinx.coroutines.*
1010
* @spec RTO2 - enum representing objects state
1111
*/
1212
internal enum class ObjectsState {
13-
INITIALIZED,
14-
SYNCING,
15-
SYNCED
13+
Initialized,
14+
Syncing,
15+
Synced
1616
}
1717

1818
/**
@@ -21,9 +21,9 @@ internal enum class ObjectsState {
2121
* INITIALIZED maps to null (no event), while SYNCING and SYNCED map to their respective events.
2222
*/
2323
private val objectsStateToEventMap = mapOf(
24-
ObjectsState.INITIALIZED to null,
25-
ObjectsState.SYNCING to ObjectsStateEvent.SYNCING,
26-
ObjectsState.SYNCED to ObjectsStateEvent.SYNCED
24+
ObjectsState.Initialized to null,
25+
ObjectsState.Syncing to ObjectsStateEvent.SYNCING,
26+
ObjectsState.Synced to ObjectsStateEvent.SYNCED
2727
)
2828

2929
/**
@@ -82,7 +82,7 @@ internal abstract class ObjectsStateCoordinator : ObjectsStateChange, HandlesObj
8282
}
8383

8484
override suspend fun ensureSynced(currentState: ObjectsState) {
85-
if (currentState != ObjectsState.SYNCED) {
85+
if (currentState != ObjectsState.Synced) {
8686
val deferred = CompletableDeferred<Unit>()
8787
internalObjectStateEmitter.once(ObjectsStateEvent.SYNCED) {
8888
Log.v(tag, "Objects state changed to SYNCED, resuming ensureSynced")

live-objects/src/test/kotlin/io/ably/lib/objects/integration/DefaultLiveObjectsTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class DefaultLiveObjectsTest : IntegrationTest() {
3636
val objects = channel.objects
3737
assertNotNull(objects)
3838

39-
assertEquals(ObjectsState.INITIALIZED, objects.State, "Initial state should be INITIALIZED")
39+
assertEquals(ObjectsState.Initialized, objects.State, "Initial state should be INITIALIZED")
4040

4141
val syncStates = mutableListOf<ObjectsStateEvent>()
4242
objects.on(ObjectsStateEvent.SYNCING) {

live-objects/src/test/kotlin/io/ably/lib/objects/unit/objects/DefaultLiveObjectsTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class DefaultLiveObjectsTest {
3434
// RTO4a - If the HAS_OBJECTS flag is 1, the server will shortly perform an OBJECT_SYNC sequence
3535
defaultLiveObjects.handleStateChange(ChannelState.attached, true)
3636

37-
assertWaiter { defaultLiveObjects.state == ObjectsState.SYNCING }
37+
assertWaiter { defaultLiveObjects.state == ObjectsState.Syncing }
3838

3939
// It is expected that the client will start a new sync sequence
4040
verify(exactly = 1) {
@@ -59,7 +59,7 @@ class DefaultLiveObjectsTest {
5959
defaultLiveObjects.handleStateChange(ChannelState.attached, false)
6060

6161
// Verify expected outcomes
62-
assertWaiter { defaultLiveObjects.state == ObjectsState.SYNCED } // RTO4b4
62+
assertWaiter { defaultLiveObjects.state == ObjectsState.Synced } // RTO4b4
6363

6464
verify(exactly = 1) {
6565
defaultLiveObjects.objectsPool.resetToInitialPool(true)
@@ -80,7 +80,7 @@ class DefaultLiveObjectsTest {
8080
val defaultLiveObjects = getDefaultLiveObjectsWithMockedDeps()
8181

8282
// Ensure we're in INITIALIZED state
83-
defaultLiveObjects.state = ObjectsState.INITIALIZED
83+
defaultLiveObjects.state = ObjectsState.Initialized
8484

8585
// RTO4a - Should start sync even with HAS_OBJECTS flag false when in INITIALIZED state
8686
defaultLiveObjects.handleStateChange(ChannelState.attached, false)

live-objects/src/test/kotlin/io/ably/lib/objects/unit/objects/ObjectsManagerTest.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class ObjectsManagerTest {
1717
@Test
1818
fun `(RTO5) ObjectsManager should handle object sync messages`() {
1919
val defaultLiveObjects = getDefaultLiveObjectsWithMockedDeps()
20-
assertEquals(ObjectsState.INITIALIZED, defaultLiveObjects.state, "Initial state should be INITIALIZED")
20+
assertEquals(ObjectsState.Initialized, defaultLiveObjects.state, "Initial state should be INITIALIZED")
2121

2222
val objectsManager = defaultLiveObjects.ObjectsManager
2323

@@ -72,7 +72,7 @@ class ObjectsManagerTest {
7272
assertEquals("counter:testObject@2", newlyCreatedObjects[0].objectId)
7373
assertEquals("map:testObject@3", newlyCreatedObjects[1].objectId)
7474

75-
assertEquals(ObjectsState.SYNCED, defaultLiveObjects.state, "State should be SYNCED after sync sequence")
75+
assertEquals(ObjectsState.Synced, defaultLiveObjects.state, "State should be SYNCED after sync sequence")
7676
// After sync `counter:testObject@4` will be removed from pool
7777
assertNull(objectsPool.get("counter:testObject@4"))
7878
assertEquals(4, objectsPool.size(), "Objects pool should contain 4 objects after sync including root")
@@ -97,7 +97,7 @@ class ObjectsManagerTest {
9797
@Test
9898
fun `(RTO8) ObjectsManager should apply object operation when state is synced`() {
9999
val defaultLiveObjects = getDefaultLiveObjectsWithMockedDeps()
100-
defaultLiveObjects.state = ObjectsState.SYNCED // Ensure we're in SYNCED state
100+
defaultLiveObjects.state = ObjectsState.Synced // Ensure we're in SYNCED state
101101

102102
val objectsManager = defaultLiveObjects.ObjectsManager
103103

@@ -165,7 +165,7 @@ class ObjectsManagerTest {
165165
@Test
166166
fun `(RTO7) ObjectsManager should buffer operations when not in sync, apply them after synced`() {
167167
val defaultLiveObjects = getDefaultLiveObjectsWithMockedDeps()
168-
assertEquals(ObjectsState.INITIALIZED, defaultLiveObjects.state, "Initial state should be INITIALIZED")
168+
assertEquals(ObjectsState.Initialized, defaultLiveObjects.state, "Initial state should be INITIALIZED")
169169

170170
val objectsManager = defaultLiveObjects.ObjectsManager
171171
assertEquals(0, objectsManager.BufferedObjectOperations.size, "RTO7a1 - Initial buffer should be empty")
@@ -176,7 +176,7 @@ class ObjectsManagerTest {
176176
mockZeroValuedObjects()
177177

178178
// Set state to SYNCING
179-
defaultLiveObjects.state = ObjectsState.SYNCING
179+
defaultLiveObjects.state = ObjectsState.Syncing
180180

181181
val objectMessage = ObjectMessage(
182182
id = "testId",

0 commit comments

Comments
 (0)