Rewrites a bunch of code to improve the structure as specified in #5, #4, #2, #1

This commit is contained in:
2022-02-18 19:39:20 +01:00
parent d2f152334f
commit 16faa1ddb2
8 changed files with 254 additions and 195 deletions

View File

@ -23,14 +23,15 @@ public enum OptionState {
/**
* Gets the boolean value of the given option state if it's boolean compatible
*
* @param optionState <p>The option state to get the boolean from</p>
* @return <p>The boolean value, or an illegal argument exception if called on DEFAULT</p>
* @param optionState <p>The option state to get the boolean from</p>
* @param defaultValue <p>The default value to use if the option state is DEFAULT</p>
* @return <p>The boolean value</p>
*/
public static boolean getBooleanValue(OptionState optionState) {
public static boolean getBooleanValue(OptionState optionState, boolean defaultValue) {
return switch (optionState) {
case TRUE -> true;
case FALSE -> false;
case DEFAULT -> throw new IllegalArgumentException("No boolean value available for DEFAULT");
case DEFAULT -> defaultValue;
};
}