Merge branch 'release/0.9-rc1'
[Sone.git] / src / main / java / net / pterodactylus / sone / utils / Option.java
1 package net.pterodactylus.sone.utils;
2
3 /**
4  * Contains current and default value of an option.
5  *
6  * @param <T>
7  *            The type of the option
8  * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
9  */
10 public interface Option<T> {
11
12         /**
13          * Returns the current value of the option. If the current value is not
14          * set (usually {@code null}), the default value is returned.
15          *
16          * @return The current value of the option
17          */
18         public T get();
19
20         /**
21          * Returns the real value of the option. This will also return an unset
22          * value (usually {@code null})!
23          *
24          * @return The real value of the option
25          */
26         public T getReal();
27
28         /**
29          * Validates the given value. Note that {@code null} is always a valid
30          * value!
31          *
32          * @param value
33          *            The value to validate
34          * @return {@code true} if this option does not have a validator, or the
35          *         validator validates this object, {@code false} otherwise
36          */
37         public boolean validate(T value);
38
39         /**
40          * Sets the current value of the option.
41          *
42          * @param value
43          *            The new value of the option
44          * @throws IllegalArgumentException
45          *             if the value is not valid for this option
46          */
47         public void set(T value) throws IllegalArgumentException;
48
49 }