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
-
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
ConstructorsConstructorDescriptionEnumValidator(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
Modifier and TypeMethodDescriptionstatic <E extends Enum<E>>
EnumValidator<E>Creates a new validator for the enum type that accepts all enum values.static <E extends Enum<E>>
EnumValidator<E>Creates a new validator for the enum type with the allowed values defined in theallowedparameter.static <E extends Enum<E>>
EnumValidator<E>Creates a new validator for the enum type with the allowed values defined in theallowedparameter.List<org.jboss.dmr.ModelNode>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 Details
-
EnumValidator
Creates a validator where the specified enum values are allowed- Parameters:
enumType- the type of the enumallowed- the allowed values. Cannot benull
-
EnumValidator
Creates a validator where the specified enum values are allowed- Parameters:
enumType- the type of the enumallowed- the allowed values. Cannot benull
-
-
Method Details
-
create
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
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
Description copied from interface:AllowedValuesValidatorGets the allowed values, ornullif any value is allowed.- Specified by:
getAllowedValuesin interfaceAllowedValuesValidator- Returns:
- the allowed values, or
null
-