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
ParameterValidatorthat validates the value is a string matching one of theEnumtypes.- Author:
- Jason T. Greene, Brian Stansberry, James R. Perkins
-
-
Field Summary
-
Fields inherited from class org.jboss.as.controller.operations.validation.ModelTypeValidator
BIGDECIMAL_MAX, BIGDECIMAL_MIN, BIGINTEGER_MAX, BIGINTEGER_MIN, nullable, strictType, validTypes
-
-
Constructor Summary
Constructors Constructor Description EnumValidator(Class<E> enumType, E... allowed)Creates a validator where the specified enum values are allowedEnumValidator(Class<E> enumType, Set<E> allowed)Creates a validator where the specified enum values are allowed
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <E extends Enum<E>>
EnumValidator<E>create(Class<E> enumType)Creates a new validator for the enum type that accepts all enum values.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 theallowedparameter.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 theallowedparameter.List<org.jboss.dmr.ModelNode>getAllowedValues()Gets the allowed values, ornullif any value is allowed.voidvalidateParameter(String parameterName, org.jboss.dmr.ModelNode value)Validate the parameter with the given name.
-
-
-
Constructor Detail
-
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 enumallowed- the allowed values. Cannot benull
-
-
Method Detail
-
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 theallowedparameter.- Type Parameters:
E- the type of the enum.- Parameters:
enumType- the type of the enum.allowed- the enum values that are allowed. Ifnullor 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 theallowedparameter.- 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:ModelTypeValidatorValidate the parameter with the given name.- Specified by:
validateParameterin interfaceParameterValidator- Overrides:
validateParameterin classModelTypeValidator- Parameters:
parameterName- the name of the parameter. Cannot benullvalue- the parameter value. Cannot benull- Throws:
OperationFailedException- if the value is not valid
-
getAllowedValues
public List<org.jboss.dmr.ModelNode> getAllowedValues()
Description copied from interface:AllowedValuesValidatorGets the allowed values, ornullif any value is allowed.- Specified by:
getAllowedValuesin interfaceAllowedValuesValidator- Returns:
- the allowed values, or
null
-
-