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)  found = true, possibles = null  ( successfully found (exact match))
10   * 2)  found = false, possibles = null ( definately not in set )
11   * 3)  added = false, possibles != null ( uncertain, possible matches returned )
12   * 
13   * @author Rory Graves
14   *
15   */
16  public class ContainsResponse extends TypeResponse<ContainsResponse> {
17  	private static final long serialVersionUID = 1L;
18  
19  	private final boolean found;	
20  	private final Object[] possibles;
21  
22  	public ContainsResponse(boolean found) {
23  		this(found,null);
24  	}
25  
26  	public ContainsResponse(boolean found,Object[] possibles) {
27  		this.found = found;
28  		this.possibles = possibles;
29  	}
30  	
31  	@Override
32  	public ContainsResponse encode(ValueEncoder encoder) {
33  		return new ContainsResponse(isFound(),encoder.encodeArray(getPossibles()));
34  	}
35  
36  	@Override
37  	public void visit(ValueVisitor visitor) {
38  		visitor.visit(getPossibles());
39  	}
40  
41  	public boolean isFound() {
42  		return found;
43  	}
44  
45  	public Object[] getPossibles() {
46  		return possibles;
47  	}
48  }