summaryrefslogtreecommitdiff
path: root/base/src/main/java/bjc/utils/data/Toggle.java
blob: 4e7b7d8569773f850798cc541483151e16d68e52 (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
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);
}