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