X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=sidebyside;f=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Futils%2FOption.java;fp=src%2Fmain%2Fjava%2Fnet%2Fpterodactylus%2Fsone%2Futils%2FOption.java;h=9149c07ff453ea8b35d7d08fe5f0c1d9d37c7676;hb=754925ca491d60ddf92b3cb21fb38f0666169348;hp=0000000000000000000000000000000000000000;hpb=3f91e22e512f81a2e11fa584e30f83da74e62177;p=Sone.git diff --git a/src/main/java/net/pterodactylus/sone/utils/Option.java b/src/main/java/net/pterodactylus/sone/utils/Option.java new file mode 100644 index 0000000..9149c07 --- /dev/null +++ b/src/main/java/net/pterodactylus/sone/utils/Option.java @@ -0,0 +1,49 @@ +package net.pterodactylus.sone.utils; + +/** + * Contains current and default value of an option. + * + * @param + * The type of the option + * @author David ‘Bombe’ Roden + */ +public interface Option { + + /** + * Returns the current value of the option. If the current value is not + * set (usually {@code null}), the default value is returned. + * + * @return The current value of the option + */ + public T get(); + + /** + * Returns the real value of the option. This will also return an unset + * value (usually {@code null})! + * + * @return The real value of the option + */ + public T getReal(); + + /** + * Validates the given value. Note that {@code null} is always a valid + * value! + * + * @param value + * The value to validate + * @return {@code true} if this option does not have a validator, or the + * validator validates this object, {@code false} otherwise + */ + public boolean validate(T value); + + /** + * Sets the current value of the option. + * + * @param value + * The new value of the option + * @throws IllegalArgumentException + * if the value is not valid for this option + */ + public void set(T value) throws IllegalArgumentException; + +}