View Javadoc

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