Class ConfigUtil

java.lang.Object
io.github.douira.glsl_transformer.util.ConfigUtil

public class ConfigUtil extends Object
Holds utility methods for configuring core transformations and transformation phases.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static <V> V
    withDefault​(Supplier<V> setValueSupplier, V defaultValue)
    Uses a default value if the given value generator is null.
    static <V> V
    withDefault​(V setValue, Supplier<V> defaultGenerator)
    Uses a default generator to return a value if the given set value is null.
    static <V> V
    withDefault​(V setValue, V defaultValue)
    Returns the set value if it is not null and returns the default value otherwise.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ConfigUtil

      public ConfigUtil()
  • Method Details

    • withDefault

      public static <V> V withDefault(V setValue, Supplier<V> defaultGenerator)
      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 user
      defaultGenerator - The default value generator
      Returns:
      The set value or the generated value
    • withDefault

      public static <V> V withDefault(Supplier<V> setValueSupplier, V defaultValue)
      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 user
      defaultValue - 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 user
      defaultValue - The default value
      Returns:
      The set value or the default value