summaryrefslogtreecommitdiff
path: root/base/src/main/java/bjc/utils/data/Toggle.java
blob: a1467e40329de8b44c37e27d49f7f862de807380 (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
36
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
	 * value to the new one.
	 *
	 * @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);
}