Synthia
Generic and flexible data structure generator
AllBooleans.java
Go to the documentation of this file.
1 package ca.uqac.lif.synthia.enumerative;
2 
3 import ca.uqac.lif.synthia.Bounded;
5 
6 /**
7  * Picker who implements EnumerativePicker. This picker enumerates the boolean value
8  * (<Boolean>false</Boolean>, <Boolean>true</Boolean>) and throws a
9  * {@link NoMoreElementException} if the picker picks another value after
10  * the picker has finished to enumerate the Boolean values.
11  * @ingroup API
12  */
13 public class AllBooleans implements Bounded<Boolean>
14 {
15 
16  /**
17  * Internal picker used to generate the objects generated by the AllBooleans picker
18  */
19  protected AllIntegers m_picker;
20 
21 
22 
23  /**
24  * Private constructor used for the duplication of the picker.
25  * @param picker The internal picker used by the Allbooleans picker to generate objects.
26  */
27  private AllBooleans(AllIntegers picker)
28  {
29  m_picker = picker;
30 
31  }
32 
33  /**
34  * Default constructor using the <tt>false</tt> default value of the {@link AllIntegers} scramble
35  * flag.
36  */
37  public AllBooleans()
38  {
39  m_picker = new AllIntegers(0, 1);
40  }
41 
42  /**
43  * Constructor taking a parameter for the scramble flag.
44  * @param scramble <tt>true</tt> to generate scramble values or <tt>false</tt> to generate
45  * values in order.
46  */
47  public AllBooleans(boolean scramble)
48  {
49  m_picker = new AllIntegers(0, 1, scramble);
50  }
51 
52  @Override
53  public void reset()
54  {
55  m_picker.reset();
56  }
57 
58  @Override
59  public Boolean pick()
60  {
61 
62  return m_picker.pick() == 1;
63  }
64 
65  @Override
66  public AllBooleans duplicate(boolean with_state)
67  {
68  return new AllBooleans( m_picker.duplicate(with_state));
69  }
70 
71  /**
72  * Signals if the AllBooleans picker picked all the objects from m_picker.
73  * Loop attributes must be false. If loop is true, the method will always return false.
74  * @return true if the picker picked all the objects from m_picker and false if it's not the case.
75  */
76  @Override
77  public boolean isDone()
78  {
79  return m_picker.isDone();
80  }
81 }
ca.uqac.lif.synthia.enumerative.AllBooleans.pick
Boolean pick()
Picks an object.
Definition: AllBooleans.java:59
ca.uqac.lif.synthia.enumerative.AllIntegers.duplicate
AllIntegers duplicate(boolean with_state)
Creates a copy of the picker.
Definition: AllIntegers.java:177
ca.uqac.lif.synthia.enumerative.AllIntegers
Picker who implements EnumerativePicker.
Definition: AllIntegers.java:17
ca.uqac.lif.synthia.enumerative.AllBooleans
Picker who implements EnumerativePicker.
Definition: AllBooleans.java:13
ca.uqac
ca.uqac.lif.synthia
Definition: Bounded.java:19
ca.uqac.lif.synthia.enumerative.AllIntegers.reset
void reset()
Puts the picker back into its initial state.
Definition: AllIntegers.java:121
ca.uqac.lif.synthia.enumerative.AllBooleans.AllBooleans
AllBooleans(boolean scramble)
Constructor taking a parameter for the scramble flag.
Definition: AllBooleans.java:47
ca.uqac.lif.synthia.enumerative.AllBooleans.reset
void reset()
Puts the picker back into its initial state.
Definition: AllBooleans.java:53
ca.uqac.lif
ca.uqac.lif.synthia.Bounded
Interface used to signal that a picker enumerates all values from a set.
Definition: Bounded.java:26
ca
ca.uqac.lif.synthia.enumerative.AllBooleans.m_picker
AllIntegers m_picker
Internal picker used to generate the objects generated by the AllBooleans picker.
Definition: AllBooleans.java:19
ca.uqac.lif.synthia.enumerative.AllIntegers.pick
Integer pick()
Picks an object.
Definition: AllIntegers.java:138
ca.uqac.lif.synthia.enumerative.AllBooleans.isDone
boolean isDone()
Signals if the AllBooleans picker picked all the objects from m_picker.
Definition: AllBooleans.java:77
ca.uqac.lif.synthia.NoMoreElementException
An exception to throw when a picker can't pick an other element.
Definition: NoMoreElementException.java:25
ca.uqac.lif.synthia.enumerative.AllBooleans.AllBooleans
AllBooleans()
Default constructor using the false default value of the AllIntegers scramble flag.
Definition: AllBooleans.java:37
ca.uqac.lif.synthia.enumerative.AllIntegers.isDone
boolean isDone()
Signals if the picker enumerates all values from a set.
Definition: AllIntegers.java:111
ca.uqac.lif.synthia.enumerative.AllBooleans.duplicate
AllBooleans duplicate(boolean with_state)
Creates a copy of the picker.
Definition: AllBooleans.java:66