Skip to content

Commit 8958d09

Browse files
committed
INTERNAL: Refactor Operation interface with default methods
1 parent f51c944 commit 8958d09

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+13
-546
lines changed

src/main/java/net/spy/memcached/ops/Operation.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,17 @@ public interface Operation {
123123

124124
boolean isReadOperation();
125125

126-
boolean isBulkOperation();
126+
default boolean isBulkOperation() {
127+
return false;
128+
}
127129

128-
boolean isPipeOperation();
130+
default boolean isPipeOperation() {
131+
return false;
132+
}
129133

130-
boolean isIdempotentOperation();
134+
default boolean isIdempotentOperation() {
135+
return true;
136+
}
131137

132138
/* ENABLE_MIGRATION if */
133139
RedirectHandler getAndClearRedirectHandler();

src/main/java/net/spy/memcached/protocol/BaseOperationImpl.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import net.spy.memcached.compat.SpyObject;
2929
import net.spy.memcached.ops.APIType;
3030
import net.spy.memcached.ops.CancelledOperationStatus;
31+
import net.spy.memcached.ops.Operation;
3132
import net.spy.memcached.ops.OperationCallback;
3233
import net.spy.memcached.ops.OperationErrorType;
3334
import net.spy.memcached.ops.OperationException;
@@ -39,7 +40,7 @@
3940
/**
4041
* Base class for protocol-specific operation implementations.
4142
*/
42-
public abstract class BaseOperationImpl extends SpyObject {
43+
public abstract class BaseOperationImpl extends SpyObject implements Operation {
4344

4445
/**
4546
* Status object for canceled operations.
@@ -289,8 +290,4 @@ public APIType getAPIType() {
289290
public void setAPIType(APIType type) {
290291
this.apiType = type;
291292
}
292-
293-
public abstract boolean isBulkOperation();
294-
295-
public abstract boolean isPipeOperation();
296293
}

src/main/java/net/spy/memcached/protocol/ascii/BTreeFindPositionOperationImpl.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -129,19 +129,4 @@ public Collection<String> getKeys() {
129129
return Collections.singleton(key);
130130
}
131131

132-
@Override
133-
public boolean isBulkOperation() {
134-
return false;
135-
}
136-
137-
@Override
138-
public boolean isPipeOperation() {
139-
return false;
140-
}
141-
142-
@Override
143-
public boolean isIdempotentOperation() {
144-
return true;
145-
}
146-
147132
}

src/main/java/net/spy/memcached/protocol/ascii/BTreeFindPositionWithGetOperationImpl.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -259,19 +259,4 @@ public Collection<String> getKeys() {
259259
return Collections.singleton(key);
260260
}
261261

262-
@Override
263-
public boolean isBulkOperation() {
264-
return false;
265-
}
266-
267-
@Override
268-
public boolean isPipeOperation() {
269-
return false;
270-
}
271-
272-
@Override
273-
public boolean isIdempotentOperation() {
274-
return true;
275-
}
276-
277262
}

src/main/java/net/spy/memcached/protocol/ascii/BTreeGetBulkOperationImpl.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -269,14 +269,4 @@ public boolean isBulkOperation() {
269269
return true;
270270
}
271271

272-
@Override
273-
public boolean isPipeOperation() {
274-
return false;
275-
}
276-
277-
@Override
278-
public boolean isIdempotentOperation() {
279-
return true;
280-
}
281-
282272
}

src/main/java/net/spy/memcached/protocol/ascii/BTreeGetByPositionOperationImpl.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -262,19 +262,4 @@ public Collection<String> getKeys() {
262262
return Collections.singleton(key);
263263
}
264264

265-
@Override
266-
public boolean isBulkOperation() {
267-
return false;
268-
}
269-
270-
@Override
271-
public boolean isPipeOperation() {
272-
return false;
273-
}
274-
275-
@Override
276-
public boolean isIdempotentOperation() {
277-
return true;
278-
}
279-
280265
}

src/main/java/net/spy/memcached/protocol/ascii/BTreeInsertAndGetOperationImpl.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -293,19 +293,4 @@ public Collection<String> getKeys() {
293293
return Collections.singleton(key);
294294
}
295295

296-
@Override
297-
public boolean isBulkOperation() {
298-
return false;
299-
}
300-
301-
@Override
302-
public boolean isPipeOperation() {
303-
return false;
304-
}
305-
306-
@Override
307-
public boolean isIdempotentOperation() {
308-
return true;
309-
}
310-
311296
}

src/main/java/net/spy/memcached/protocol/ascii/BTreeSortMergeGetOperationImpl.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -464,14 +464,4 @@ public boolean isBulkOperation() {
464464
return true;
465465
}
466466

467-
@Override
468-
public boolean isPipeOperation() {
469-
return false;
470-
}
471-
472-
@Override
473-
public boolean isIdempotentOperation() {
474-
return true;
475-
}
476-
477467
}

src/main/java/net/spy/memcached/protocol/ascii/BTreeSortMergeGetOperationOldImpl.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -317,14 +317,4 @@ public boolean isBulkOperation() {
317317
return true;
318318
}
319319

320-
@Override
321-
public boolean isPipeOperation() {
322-
return false;
323-
}
324-
325-
@Override
326-
public boolean isIdempotentOperation() {
327-
return true;
328-
}
329-
330320
}

src/main/java/net/spy/memcached/protocol/ascii/BaseGetOpImpl.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -237,14 +237,4 @@ public boolean isBulkOperation() {
237237
return keys.size() > 1;
238238
}
239239

240-
@Override
241-
public boolean isPipeOperation() {
242-
return false;
243-
}
244-
245-
@Override
246-
public boolean isIdempotentOperation() {
247-
return true;
248-
}
249-
250240
}

0 commit comments

Comments
 (0)