1 package org.sourceforge.jemm.collections.internal.map;
2
3 import org.sourceforge.jemm.client.shared.ValueEncoder;
4 import org.sourceforge.jemm.collections.internal.StoredValue;
5 import org.sourceforge.jemm.lifecycle.TypeResponse;
6 import org.sourceforge.jemm.lifecycle.ValueVisitor;
7
8 public class MapRemoveKVResponse extends TypeResponse<MapRemoveKVResponse> {
9 private static final long serialVersionUID = 1L;
10
11 private final boolean success;
12 private final StoredValue[] potentialKeyMatches;
13 private final StoredValue[] potentialValueMatches;
14
15 private MapRemoveKVResponse(boolean success, StoredValue[] potentialKeyMatches,
16 StoredValue[] potentialValueMatches) {
17 this.success = success;
18 this.potentialKeyMatches = potentialKeyMatches;
19 this.potentialValueMatches = potentialValueMatches;
20 }
21
22 public MapRemoveKVResponse(boolean success) {
23 this(success,null,null);
24 }
25
26 public MapRemoveKVResponse(StoredValue[] potentialKeyMatches,
27 StoredValue[] potentialValueMatches) {
28 this(false,potentialKeyMatches,potentialValueMatches);
29 }
30
31 @Override
32 public MapRemoveKVResponse encode(ValueEncoder encoder) {
33 return new MapRemoveKVResponse(success,encoder.encodeArray(potentialKeyMatches),
34 encoder.encodeArray(potentialValueMatches));
35 }
36
37 public boolean isSuccess() {
38 return success;
39 }
40
41 public StoredValue[] getPotentialKeyMatches() {
42 return potentialKeyMatches;
43 }
44
45 public StoredValue[] getPotentialValueMatches() {
46 return potentialValueMatches;
47 }
48
49 public boolean hasPotentials() {
50 return potentialKeyMatches != null;
51 }
52
53 @Override
54 public void visit(ValueVisitor visitor) {
55 visitor.visit(potentialKeyMatches);
56 visitor.visit(potentialValueMatches);
57 }
58 }