Class ConfigUtil
java.lang.Object
io.github.douira.glsl_transformer.util.ConfigUtil
Holds utility methods for configuring core transformations and transformation
phases.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <V> VwithDefault(Supplier<V> setValueSupplier, V defaultValue)Uses a default value if the given value generator is null.static <V> VwithDefault(V setValue, Supplier<V> defaultGenerator)Uses a default generator to return a value if the given set value is null.static <V> VwithDefault(V setValue, V defaultValue)Returns the set value if it is not null and returns the default value otherwise.
-
Constructor Details
-
ConfigUtil
public ConfigUtil()
-
-
Method Details
-
withDefault
Uses a default generator to return a value if the given set value is null. If the generated value is also null, it throws an error. This is used for writing getter methods in core classes that use the chaining configuration pattern.- Type Parameters:
V- The value type- Parameters:
setValue- The value set for this configuration by the userdefaultGenerator- The default value generator- Returns:
- The set value or the generated value
-
withDefault
Uses a default value if the given value generator is null. If the default value is also null, an error is thrown. This is used for writing getter methods in core classes that use the chaining configuration pattern. Note that nothing special happens if the set value generator returns null.- Type Parameters:
V- The value type- Parameters:
setValueSupplier- The value generator set for this configuration by the userdefaultValue- The default value- Returns:
- The generated value or the default value
-
withDefault
public static <V> V withDefault(V setValue, V defaultValue)Returns the set value if it is not null and returns the default value otherwise. If the default is also null it throws an error.- Type Parameters:
V- The value type- Parameters:
setValue- The value set for this configuration by the userdefaultValue- The default value- Returns:
- The set value or the default value
-