Update year in copyright lines
[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  */
9 public interface Option<T> {
10
11         /**
12          * Returns the current value of the option. If the current value is not
13          * set (usually {@code null}), the default value is returned.
14          *
15          * @return The current value of the option
16          */
17         public T get();
18
19         /**
20          * Returns the real value of the option. This will also return an unset
21          * value (usually {@code null})!
22          *
23          * @return The real value of the option
24          */
25         public T getReal();
26
27         /**
28          * Validates the given value. Note that {@code null} is always a valid
29          * value!
30          *
31          * @param value
32          *            The value to validate
33          * @return {@code true} if this option does not have a validator, or the
34          *         validator validates this object, {@code false} otherwise
35          */
36         public boolean validate(T value);
37
38         /**
39          * Sets the current value of the option.
40          *
41          * @param value
42          *            The new value of the option
43          * @throws IllegalArgumentException
44          *             if the value is not valid for this option
45          */
46         public void set(T value) throws IllegalArgumentException;
47
48 }