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 final class MapReplaceKONResponse extends TypeResponse<MapReplaceKONResponse> {
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 MapReplaceKONResponse(boolean success,StoredValue[] potentialKeyMatches,
16 StoredValue[] potentialValueMatches) {
17 this.success = success;
18 this.potentialKeyMatches = potentialKeyMatches;
19 this.potentialValueMatches = potentialValueMatches;
20 }
21
22 public MapReplaceKONResponse(boolean success) {
23 this(success,null,null);
24 }
25
26 public MapReplaceKONResponse(StoredValue[] potentialKeyMatches,
27 StoredValue[] potentialValueMatches) {
28 this(false,potentialKeyMatches,potentialValueMatches);
29 }
30
31 public StoredValue[] getPotentialKeyMatches() {
32 return potentialKeyMatches;
33 }
34
35 public StoredValue[] getPotentialValueMatches() {
36 return potentialKeyMatches;
37 }
38
39 public boolean isSuccess() {
40 return success;
41 }
42
43 @Override
44 public MapReplaceKONResponse encode(ValueEncoder encoder) {
45 return new MapReplaceKONResponse(success,
46 encoder.encodeArray(potentialKeyMatches),
47 encoder.encodeArray(potentialValueMatches));
48 }
49
50 public boolean hasPotentialKeyMatches() {
51 return potentialKeyMatches != null;
52 }
53
54 @Override
55 public void visit(ValueVisitor visitor) {
56 visitor.visit(potentialKeyMatches);
57 visitor.visit(potentialValueMatches);
58 }
59 }