Class ProcessorOption<T>

java.lang.Object
be.imgn.gaia.processing.ProcessorOption<T>
Type Parameters:
T - the type of the value

public final class ProcessorOption<T> extends Object
An option of an annotation processor, given to javac as -Aname=value, with its type and default value.
static final ProcessorOption<Boolean> VERBOSE = ProcessorOption.ofBoolean("mapper.verbose", false);

// in the processor
protected Set<ProcessorOption<?>> options() {
    return Set.of(VERBOSE);
}

// in a step
if (context.option(VERBOSE)) { ... }
  • Method Details

    • ofString

      public static ProcessorOption<String> ofString(String name, String defaultValue)
      Returns a text option.
      Parameters:
      name - the name of the option, as in -Aname=value: Java identifiers separated by dots
      defaultValue - the value when the option is not given
      Returns:
      the option
      Throws:
      IllegalArgumentException - if name is not Java identifiers separated by dots
    • ofBoolean

      public static ProcessorOption<Boolean> ofBoolean(String name, boolean defaultValue)
      Returns a boolean option. Given without a value, as -Aname, it is true.
      Parameters:
      name - the name of the option, as in -Aname=true: Java identifiers separated by dots
      defaultValue - the value when the option is not given
      Returns:
      the option
      Throws:
      IllegalArgumentException - if name is not Java identifiers separated by dots
    • ofInt

      public static ProcessorOption<Integer> ofInt(String name, int defaultValue)
      Returns an integer option.
      Parameters:
      name - the name of the option, as in -Aname=42: Java identifiers separated by dots
      defaultValue - the value when the option is not given
      Returns:
      the option
      Throws:
      IllegalArgumentException - if name is not Java identifiers separated by dots
    • ofEnum

      public static <E extends Enum<E>> ProcessorOption<E> ofEnum(String name, Class<E> type, E defaultValue)
      Returns an enum option, whose values are the names of the constants, in any case.
      Type Parameters:
      E - the enum type
      Parameters:
      name - the name of the option, as in -Aname=constant: Java identifiers separated by dots
      type - the enum class
      defaultValue - the value when the option is not given
      Returns:
      the option
      Throws:
      IllegalArgumentException - if name is not Java identifiers separated by dots, or type is not an enum class
    • name

      public String name()
      Returns the name of this option.
      Returns:
      the name, as in -Aname=value
    • defaultValue

      public T defaultValue()
      Returns the value of this option when it is not given.
      Returns:
      the default value
    • toString

      public String toString()
      Overrides:
      toString in class Object