View Javadoc

1   package org.sourceforge.jemm.collections.internal;
2   
3   import org.sourceforge.jemm.client.shared.ValueEncoder;
4   import org.sourceforge.jemm.lifecycle.TypeResponse;
5   import org.sourceforge.jemm.lifecycle.ValueVisitor;
6   
7   /**
8    * HashContainer ContainsResult, three options
9    * 1)  removed = true, possibles = null  ( successfully found and removed (exact match))
10   * 2)  removed  = false, possibles = null ( definately not found, no action )
11   * 3)  removed = false, possibles != null ( uncertain, possible matches returned )
12   * 
13   * @author Rory Graves
14   *
15   */
16  public class RemoveResponse extends TypeResponse<RemoveResponse> {
17  	private static final long serialVersionUID = 1L;
18  
19  	private final boolean removed;	
20  	private final Object[] potentialMatches;
21  
22  	public RemoveResponse(boolean removed) {
23  		this(removed,null);
24  	}
25  
26  	public RemoveResponse(boolean removed,Object[] potentialMatches) {
27  		this.removed = removed;
28  		this.potentialMatches = potentialMatches;
29  	}
30  	
31  	@Override
32  	public RemoveResponse encode(ValueEncoder encoder) {
33  		return new RemoveResponse(removed,encoder.encodeArray(potentialMatches));
34  	}
35  
36  	@Override
37  	public void visit(ValueVisitor visitor) {
38  		visitor.visit(getPotentialMatches());
39  	}
40  
41  	public boolean wasRemoved() {
42  		return removed;
43  	}
44  
45  	public Object[] getPotentialMatches() {
46  		return potentialMatches;
47  	}
48  }