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 theEnum
types.- 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, EnumSet<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 theallowed
parameter.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 theallowed
parameter.List<org.jboss.dmr.ModelNode>
getAllowedValues()
Gets the allowed values, ornull
if any value is allowed.void
validateParameter(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 theallowed
parameter.- Type Parameters:
E
- the type of the enum.- Parameters:
enumType
- the type of the enum.allowed
- the enum values that are allowed. Ifnull
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 theallowed
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 interfaceParameterValidator
- Overrides:
validateParameter
in classModelTypeValidator
- Parameters:
parameterName
- the name of the parameter. Cannot benull
value
- 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:AllowedValuesValidator
Gets the allowed values, ornull
if any value is allowed.- Specified by:
getAllowedValues
in interfaceAllowedValuesValidator
- Returns:
- the allowed values, or
null
-
-