Skip to content

Commit 2f55194

Browse files
committedMar 24, 2015
remove fields in list commands which are no longer needed #16
1 parent e2c385f commit 2f55194

File tree

5 files changed

+7
-85
lines changed

5 files changed

+7
-85
lines changed
 

‎kryo-serializer/src/main/java/de/saxsys/synchronizefx/kryo/serializer/AddToListSerializer.java

+1-3
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,11 @@ public void write(final Kryo kryo, final Output output, final AddToList object)
4444
kryo.writeObject(output, object.getListVersionChange().getToVersion());
4545
kryo.writeObject(output, object.getValue());
4646
output.writeInt(object.getPosition());
47-
output.writeInt(object.getNewSize());
4847
}
4948

5049
@Override
5150
public AddToList read(final Kryo kryo, final Input input, final Class<AddToList> type) {
5251
return new AddToList(kryo.readObject(input, UUID.class), new ListVersionChange(kryo.readObject(input,
53-
UUID.class), kryo.readObject(input, UUID.class)), kryo.readObject(input, Value.class), input.readInt(),
54-
input.readInt());
52+
UUID.class), kryo.readObject(input, UUID.class)), kryo.readObject(input, Value.class), input.readInt());
5553
}
5654
}

‎kryo-serializer/src/main/java/de/saxsys/synchronizefx/kryo/serializer/RemoveFromListSerializer.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,12 @@ public void write(final Kryo kryo, final Output output, final RemoveFromList inp
4444
kryo.writeObject(output, input.getListVersionChange().getToVersion());
4545
output.writeInt(input.getStartPosition());
4646
output.writeInt(input.getRemoveCount());
47-
output.writeInt(input.getNewSize());
4847
}
4948

5049
@Override
5150
public RemoveFromList read(final Kryo kryo, final Input input, final Class<RemoveFromList> clazz) {
5251
return new RemoveFromList(kryo.readObject(input, UUID.class), new ListVersionChange(kryo.readObject(input,
53-
UUID.class), kryo.readObject(input, UUID.class)), input.readInt(), input.readInt(), input.readInt());
52+
UUID.class), kryo.readObject(input, UUID.class)), input.readInt(), input.readInt());
5453
}
5554

5655
}

‎synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/commands/AddToList.java

+1-36
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public class AddToList extends ListCommand {
3030

3131
private final Value value;
3232
private final int position;
33-
private final int newSize;
3433

3534
/**
3635
* Initializes an instance.
@@ -46,31 +45,9 @@ public class AddToList extends ListCommand {
4645
*/
4746
public AddToList(final UUID listId, final ListVersionChange listVersionChange, final Value value, //
4847
final int position) {
49-
this(listId, listVersionChange, value, position, -1);
50-
}
51-
52-
/**
53-
* Initializes an instance with a size value.
54-
*
55-
* @param listId
56-
* see {@link #getListId()}
57-
* @param listVersionChange
58-
* see {@link #getListVersionChange()}
59-
* @param value
60-
* see {@link #getValue()}
61-
* @param position
62-
* see {@link #getPosition()}
63-
* @param newSize
64-
* see {@link #getNewSize()}
65-
* @deprecated since newSize is no longer used in the new self repairing implementation.
66-
*/
67-
@Deprecated
68-
public AddToList(final UUID listId, final ListVersionChange listVersionChange, final Value value,
69-
final int position, final int newSize) {
7048
super(listId, listVersionChange);
7149
this.value = value;
7250
this.position = position;
73-
this.newSize = newSize;
7451
}
7552

7653
/**
@@ -94,21 +71,9 @@ public Value getValue() {
9471
return value;
9572
}
9673

97-
/**
98-
* The new size the list should have after this command has been executed on it.
99-
*
100-
* @deprecated The new self repairing algorithm will not use this information.
101-
* @return the new size
102-
*/
103-
@Deprecated
104-
public int getNewSize() {
105-
return newSize;
106-
}
107-
10874
@Override
10975
public String toString() {
110-
return "AddToList [value=" + value + ", position=" + position + ", newSize=" + newSize + ", ListVersionChange="
111-
+ super.toString() + "]";
76+
return "AddToList [value=" + value + ", position=" + position + ", ListVersionChange=" + super.toString() + "]";
11277
}
11378

11479
}

‎synchronizefx-core/src/main/java/de/saxsys/synchronizefx/core/metamodel/commands/RemoveFromList.java

+2-34
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public class RemoveFromList extends ListCommand {
3030

3131
private final int startPosition;
3232
private final int removeCount;
33-
private final int newSize;
3433

3534
/**
3635
* Initializes an instance.
@@ -46,31 +45,9 @@ public class RemoveFromList extends ListCommand {
4645
*/
4746
public RemoveFromList(final UUID listId, final ListVersionChange listVersionChange, final int startPosition,
4847
final int removeCount) {
49-
this(listId, listVersionChange, startPosition, removeCount, -1);
50-
}
51-
52-
/**
53-
* Initializes an instance.
54-
*
55-
* @param listId
56-
* see {@link #getListId()}
57-
* @param listVersionChange
58-
* see {@link #getListVersionChange()}
59-
* @param startPosition
60-
* see {@link #getStartPosition()}
61-
* @param removeCount
62-
* see {@link #getRemoveCount()}
63-
* @param newSize
64-
* see {@link #getNewSize()}
65-
* @deprecated since newSize is no longer used in the new self repairing implementation.
66-
*/
67-
@Deprecated
68-
public RemoveFromList(final UUID listId, final ListVersionChange listVersionChange, final int startPosition,
69-
final int removeCount, final int newSize) {
7048
super(listId, listVersionChange);
7149
this.startPosition = startPosition;
7250
this.removeCount = removeCount;
73-
this.newSize = newSize;
7451
}
7552

7653
/**
@@ -91,19 +68,10 @@ public int getRemoveCount() {
9168
return removeCount;
9269
}
9370

94-
/**
95-
* The new size the list should have after this command has been executed on it.
96-
*
97-
* @return the new size
98-
*/
99-
public int getNewSize() {
100-
return newSize;
101-
}
102-
10371
@Override
10472
public String toString() {
105-
return "RemoveFromList [startPosition=" + startPosition + ", removeCount=" + removeCount + ", newSize="
106-
+ newSize + ", ListVersionChange=" + super.toString() + "]";
73+
return "RemoveFromList [startPosition=" + startPosition + ", removeCount=" + removeCount
74+
+ ", ListVersionChange=" + super.toString() + "]";
10775
}
10876

10977
}

‎synchronizefx-core/src/test/java/de/saxsys/synchronizefx/core/metamodel/SyncListPropertyTest.java

+2-10
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ public void testAdd() {
9494
assertEquals("Test Value 257", msg1.getValue().getSimpleObjectValue());
9595
assertNull(msg1.getValue().getObservableObjectId());
9696
assertEquals(0, msg1.getPosition());
97-
assertEquals(1, msg1.getNewSize());
9897

9998
// test adding of a observable object
10099
root.childList.add(new Child());
@@ -105,14 +104,12 @@ public void testAdd() {
105104
assertEquals(Child.class.getName(), msg2.getClassName());
106105
assertNull(msg3.getValue().getSimpleObjectValue());
107106
assertEquals(msg2.getObjectId(), msg3.getValue().getObservableObjectId());
108-
assertEquals(1, msg3.getNewSize());
109107

110108
// test that the position is set correctly
111109
root.wrappedList.add("some text");
112110
root.wrappedList.add(1, "some more text");
113111
final AddToList msg4 = (AddToList) cb.getCommands().get(0);
114112
assertEquals(1, msg4.getPosition());
115-
assertEquals(3, msg4.getNewSize());
116113

117114
}
118115

@@ -128,25 +125,21 @@ public void testRemove() {
128125
final RemoveFromList msg0 = (RemoveFromList) cb.getCommands().get(0);
129126
assertEquals(2, msg0.getStartPosition());
130127
assertEquals(1, msg0.getRemoveCount());
131-
assertEquals(3, msg0.getNewSize());
132128

133129
root.wrappedList.remove("Test Value 0");
134130
final RemoveFromList msg1 = (RemoveFromList) cb.getCommands().get(0);
135131
assertEquals(0, msg1.getStartPosition());
136132
assertEquals(1, msg1.getRemoveCount());
137-
assertEquals(2, msg1.getNewSize());
138133

139134
root.childList.remove(new Child(2));
140135
final RemoveFromList msg2 = (RemoveFromList) cb.getCommands().get(0);
141136
assertEquals(2, msg2.getStartPosition());
142137
assertEquals(1, msg2.getRemoveCount());
143-
assertEquals(2, msg2.getNewSize());
144138

145139
root.childList.remove(1);
146140
final RemoveFromList msg3 = (RemoveFromList) cb.getCommands().get(0);
147141
assertEquals(1, msg3.getStartPosition());
148142
assertEquals(1, msg3.getRemoveCount());
149-
assertEquals(1, msg3.getNewSize());
150143
}
151144

152145
/**
@@ -175,22 +168,21 @@ public void testReplace() {
175168
assertNull(replaceCommand2.getValue().getSimpleObjectValue());
176169
assertNotNull(replaceCommand2.getValue().getObservableObjectId());
177170
}
178-
171+
179172
/**
180173
* Tests whether the {@link List#clear()} operation removes all elements from the list.
181174
*/
182175
@Test
183176
public void testClear() {
184177
simpleTestData();
185-
178+
186179
root.wrappedList.clear();
187180

188181
final Command command = cb.getCommands().get(0);
189182
assertTrue(command instanceof RemoveFromList);
190183
final RemoveFromList replaceCommand = (RemoveFromList) command;
191184
assertEquals(0, replaceCommand.getStartPosition());
192185
assertEquals(4, replaceCommand.getRemoveCount());
193-
assertEquals(0, replaceCommand.getNewSize());
194186
}
195187

196188
/**

0 commit comments

Comments
 (0)
Please sign in to comment.