mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-11-03 01:29:33 +00:00
working on the last generics compile error regarding the constructor call to ClientServerOperationPair
This commit is contained in:
1 parent
353342ecbf
commit
cd44c2f5f6
5 files changed
+17
-17
No files matched your search
+3
-3
@@ -53,9 +53,9 @@ public class OperationalTransformationTest {
|
||||
}
|
||||
}
|
||||
|
||||
public static class StringInsertTransformer implements Transformer<StringInsertOperation> {
|
||||
public static class StringInsertTransformer implements Transformer<StringState, StringInsertOperation> {
|
||||
@Override
|
||||
public ClientServerOperationPair<StringInsertOperation> transform(StringInsertOperation clientOp, StringInsertOperation serverOp) {
|
||||
public ClientServerOperationPair<StringState, StringInsertOperation> transform(StringInsertOperation clientOp, StringInsertOperation serverOp) {
|
||||
final StringInsertOperation resultClientOp;
|
||||
final StringInsertOperation resultServerOp;
|
||||
if (clientOp == null || serverOp == null) {
|
||||
@@ -68,7 +68,7 @@ public class OperationalTransformationTest {
|
||||
resultClientOp = clientOp;
|
||||
resultServerOp = new StringInsertOperation(serverOp.getPos()+clientOp.getS().length(), serverOp.getS());
|
||||
}
|
||||
return new ClientServerOperationPair<StringInsertOperation>(resultClientOp, resultServerOp);
|
||||
return new ClientServerOperationPair<StringState, StringInsertOperation>(resultClientOp, resultServerOp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package com.sap.sse.operationaltransformation;
|
||||
|
||||
public class ClientServerOperationPair<O extends Operation<?>> {
|
||||
public class ClientServerOperationPair<S, O extends Operation<S>> {
|
||||
private O clientOp;
|
||||
private O serverOp;
|
||||
|
||||
|
||||
+3
-3
@@ -9,10 +9,10 @@ package com.sap.sse.operationaltransformation;
|
||||
* @param <S>
|
||||
* @param <O>
|
||||
*/
|
||||
public class OperationalTransformer<S, O extends OperationWithTransformationSupport<S, O>> implements Transformer<O> {
|
||||
public class OperationalTransformer<S, O extends OperationWithTransformationSupport<S, O>> implements Transformer<S, O> {
|
||||
@Override
|
||||
public ClientServerOperationPair<O> transform(O clientOp, O serverOp) {
|
||||
ClientServerOperationPair<O> result = new ClientServerOperationPair<O>(
|
||||
public ClientServerOperationPair<S, O> transform(O clientOp, O serverOp) {
|
||||
ClientServerOperationPair<O> result = new ClientServerOperationPair<S, O>(
|
||||
clientOp == null ? null : clientOp.transformClientOp(serverOp),
|
||||
serverOp == null ? null : serverOp.transformServerOp(clientOp));
|
||||
return result;
|
||||
|
||||
+8
-8
@@ -53,21 +53,21 @@ public class PeerImpl<O extends Operation<S>, S> implements Peer<O, S> {
|
||||
*/
|
||||
private final Map<Peer<O, S>, Integer> numberOfMergedOperations = new HashMap<Peer<O, S>, Integer>();
|
||||
|
||||
private final Transformer<O> transformer;
|
||||
private final Transformer<S, O> transformer;
|
||||
|
||||
/**
|
||||
* The background task handler which sends out the asynchronous updates to the peers.
|
||||
*/
|
||||
private final ExecutorService merger;
|
||||
|
||||
public PeerImpl(Transformer<O> transformer, S initialState, Role role) {
|
||||
public PeerImpl(Transformer<S, O> transformer, S initialState, Role role) {
|
||||
this.transformer = transformer;
|
||||
currentState = initialState;
|
||||
this.role = role;
|
||||
this.merger = Executors.newSingleThreadExecutor();
|
||||
}
|
||||
|
||||
public PeerImpl(String name, Transformer<O> transformer, S initialState, Role role) {
|
||||
public PeerImpl(String name, Transformer<S, O> transformer, S initialState, Role role) {
|
||||
this(transformer, initialState, role);
|
||||
this.name = name;
|
||||
}
|
||||
@@ -77,7 +77,7 @@ public class PeerImpl<O extends Operation<S>, S> implements Peer<O, S> {
|
||||
* the two-way link between client and server peers. The initial state is taken from
|
||||
* the server.
|
||||
*/
|
||||
public PeerImpl(Transformer<O> transformer, Peer<O, S> server) {
|
||||
public PeerImpl(Transformer<S, O> transformer, Peer<O, S> server) {
|
||||
this.transformer = transformer;
|
||||
S initialState = server.addPeer(this);
|
||||
currentState = initialState;
|
||||
@@ -91,7 +91,7 @@ public class PeerImpl<O extends Operation<S>, S> implements Peer<O, S> {
|
||||
* <tt>server</tt> peer, establishing the two-way link between client and
|
||||
* server peers. The initial state is taken from the server.
|
||||
*/
|
||||
public PeerImpl(String name, Transformer<O> transformer, Peer<O, S> server) {
|
||||
public PeerImpl(String name, Transformer<S, O> transformer, Peer<O, S> server) {
|
||||
this(transformer, server);
|
||||
this.name = name;
|
||||
}
|
||||
@@ -101,7 +101,7 @@ public class PeerImpl<O extends Operation<S>, S> implements Peer<O, S> {
|
||||
merger.shutdown();
|
||||
}
|
||||
|
||||
private Transformer<O> getTransformer() {
|
||||
private Transformer<S, O> getTransformer() {
|
||||
return transformer;
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ public class PeerImpl<O extends Operation<S>, S> implements Peer<O, S> {
|
||||
for (O unconfirmedOperation : unmergedOperationsForSource
|
||||
.getUnmergedOperations(numberOfOperationsSourceHasMergedFromThis)) {
|
||||
if (role == Role.SERVER) {
|
||||
final ClientServerOperationPair<O> pair;
|
||||
final ClientServerOperationPair<S, O> pair;
|
||||
if (transformedOp == null || unconfirmedOperation == null) {
|
||||
pair = new ClientServerOperationPair<>(transformedOp, unconfirmedOperation);
|
||||
} else {
|
||||
@@ -163,7 +163,7 @@ public class PeerImpl<O extends Operation<S>, S> implements Peer<O, S> {
|
||||
transformedOp = pair.getClientOp();
|
||||
unmergedOperationsForSource.updateWithTransformed(localOpNumber, pair.getServerOp());
|
||||
} else {
|
||||
final ClientServerOperationPair<O> pair;
|
||||
final ClientServerOperationPair<S, O> pair;
|
||||
if (transformedOp == null || unconfirmedOperation == null) {
|
||||
pair = new ClientServerOperationPair<>(unconfirmedOperation, transformedOp);
|
||||
} else {
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
package com.sap.sse.operationaltransformation;
|
||||
|
||||
public interface Transformer<O extends Operation<?>> {
|
||||
public interface Transformer<S, O extends Operation<S>> {
|
||||
/**
|
||||
* Takes an operation from the client and an operation from the server, both based on the same state. The
|
||||
* complementary pair of operations is computed such that if the client applies the server operation returned, and
|
||||
@@ -15,5 +15,5 @@ public interface Transformer<O extends Operation<?>> {
|
||||
* @param serverOp
|
||||
* operation that was executed on the SERVER; never called with <code>null</code>
|
||||
*/
|
||||
ClientServerOperationPair<O> transform(O clientOp, O serverOp);
|
||||
ClientServerOperationPair<S, O> transform(O clientOp, O serverOp);
|
||||
}
|
||||
Reference in new issue
Block a user