Class EnumValidator<E extends Enum<E>>

java.lang.Object
org.jboss.as.controller.operations.validation.ModelTypeValidator
org.jboss.as.controller.operations.validation.EnumValidator<E>
All Implemented Interfaces:
AllowedValuesValidator, ParameterValidator

public class EnumValidator<E extends Enum<E>> extends ModelTypeValidator implements AllowedValuesValidator
ParameterValidator that validates the value is a string matching one of the Enum types.
Author:
Jason T. Greene, Brian Stansberry, James R. Perkins
  • Constructor Details

    • EnumValidator

      @SafeVarargs public EnumValidator(Class<E> enumType, E... allowed)
      Creates a validator where the specified enum values are allowed
      Parameters:
      enumType - the type of the enum
      allowed - the allowed values. Cannot be null
    • EnumValidator

      public EnumValidator(Class<E> enumType, Set<E> allowed)
      Creates a validator where the specified enum values are allowed
      Parameters:
      enumType - the type of the enum
      allowed - the allowed values. Cannot be null
  • Method Details

    • create

      public static <E extends Enum<E>> EnumValidator<E> create(Class<E> enumType)
      Creates a new validator for the enum type that accepts all enum values.
      Type Parameters:
      E - the type of the enum.
      Parameters:
      enumType - the type of the enum.
      Returns:
      a new validator.
    • create

      @SafeVarargs public static <E extends Enum<E>> EnumValidator<E> create(Class<E> enumType, E... allowed)
      Creates a new validator for the enum type with the allowed values defined in the allowed parameter.
      Type Parameters:
      E - the type of the enum.
      Parameters:
      enumType - the type of the enum.
      allowed - the enum values that are allowed. If null or zero length this is interpreted as meaning all values
      Returns:
      a new validator.
    • create

      public static <E extends Enum<E>> EnumValidator<E> create(Class<E> enumType, EnumSet<E> allowed)
      Creates a new validator for the enum type with the allowed values defined in the allowed parameter.
      Type Parameters:
      E - the type of the enum.
      Parameters:
      enumType - the type of the enum.
      allowed - the enum values that are allowed.
      Returns:
      a new validator.
    • validateParameter

      public void validateParameter(String parameterName, org.jboss.dmr.ModelNode value) throws OperationFailedException
      Description copied from class: ModelTypeValidator
      Validate the parameter with the given name.
      Specified by:
      validateParameter in interface ParameterValidator
      Overrides:
      validateParameter in class ModelTypeValidator
      Parameters:
      parameterName - the name of the parameter. Cannot be null
      value - the parameter value. Cannot be null
      Throws:
      OperationFailedException - if the value is not valid
    • getAllowedValues

      public List<org.jboss.dmr.ModelNode> getAllowedValues()
      Description copied from interface: AllowedValuesValidator
      Gets the allowed values, or null if any value is allowed.
      Specified by:
      getAllowedValues in interface AllowedValuesValidator
      Returns:
      the allowed values, or null