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 MapGetResponse extends TypeResponse<MapGetResponse> {
9 private static final long serialVersionUID = 1L;
10
11 private final boolean found;
12 private final Object value;
13 private final StoredValue[] possibleMatches;
14
15
16 private MapGetResponse(boolean found, Object value, StoredValue[] possibleMatches) {
17 this.found = found;
18 this.value = value;
19 this.possibleMatches = possibleMatches;
20 }
21
22 public MapGetResponse() {
23 this(false,null,null);
24 }
25
26 public MapGetResponse(Object value) {
27 this(true,value,null);
28 }
29
30 public MapGetResponse(StoredValue[] possibleMatches) {
31 this(false,null,possibleMatches);
32 }
33
34 public boolean isFound() {
35 return found;
36 }
37
38 public Object getValue() {
39 return value;
40 }
41
42 public StoredValue[] getPossibleMatches() {
43 return possibleMatches;
44 }
45
46 @Override
47 public MapGetResponse encode(ValueEncoder encoder) {
48 return new MapGetResponse(found,encoder.encode(value),encoder.encodeArray(getPossibleMatches()));
49 }
50
51 public boolean hasPossibleMatches() {
52 return possibleMatches != null;
53 }
54
55 @Override
56 public void visit(ValueVisitor visitor) {
57 visitor.visit(value);
58 visitor.visit(possibleMatches);
59 }
60 }