summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/data/Toggle.java
blob: 1e10dae580f5a64644a07de49ba5b20e789110dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package bjc.utils.data;

/**
 * A stateful holder that swaps between two values of the same type.
 *
 * @author EVE
 *
 * @param <E>
 *                The value stored in the toggle.
 */
public interface Toggle<E> {
	/**
	 * Retrieve the currently-aligned value of this toggle, and swap the
	 * alignment.
	 *
	 * @return The previously-aligned value.
	 */
	E get();

	/**
	 * Retrieve the currently-aligned value without altering the alignment.
	 *
	 * @return The currently-aligned value.
	 */
	E peek();

	/**
	 * Change the alignment of the toggle.
	 *
	 * @param isLeft
	 *                Whether the toggle should be left-aligned or not.
	 */
	void set(boolean isLeft);

}