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, boolean nullable, boolean allowExpressions)Deprecated.useEnumValidator(Class, EnumSet)withEnumSet.allOf(Class)sinceAttributeDefinitionhandles the nullable and expression checks.EnumValidator(Class<E> enumType, boolean nullable, boolean allowExpressions, E... allowed)Deprecated.useEnumValidator(Class, Enum[])withEnumSet.allOf(Class)sinceAttributeDefinitionhandles the nullable and expression checks.EnumValidator(Class<E> enumType, boolean nullable, E... allowed)Deprecated.useEnumValidator(Class, Enum[])withEnumSet.allOf(Class)sinceAttributeDefinitionhandles the nullable and expressions checks.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 Deprecated Methods Modifier and Type Method Description static <E extends Enum<E>>
EnumValidator<E>create(Class<E> enumType, boolean nullable, boolean allowExpressions)Deprecated.usecreate(Class, EnumSet)withEnumSet.allOf(Class)sinceAttributeDefinitionhandles the nullable and expression checks.static <E extends Enum<E>>
EnumValidator<E>create(Class<E> enumType, boolean nullable, boolean allowExpressions, E... allowed)Deprecated.usecreate(Class, Enum[])sinceAttributeDefinitionhandles the nullable and expression checks.static <E extends Enum<E>>
EnumValidator<E>create(Class<E> enumType, boolean nullable, E... allowed)Deprecated.usecreate(Class, Enum[])sinceAttributeDefinitionhandles the nullable check.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.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jboss.as.controller.operations.validation.ParameterValidator
validateResolvedParameter
-
-
-
-
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
-
EnumValidator
public EnumValidator(Class<E> enumType, EnumSet<E> allowed)
Creates a validator where the specified enum values are allowed- Parameters:
enumType- the type of the enumallowed- the allowed values. Cannot benull
-
EnumValidator
@SafeVarargs @Deprecated public EnumValidator(Class<E> enumType, boolean nullable, E... allowed)
Deprecated.useEnumValidator(Class, Enum[])withEnumSet.allOf(Class)sinceAttributeDefinitionhandles the nullable and expressions checks.
-
EnumValidator
@Deprecated public EnumValidator(Class<E> enumType, boolean nullable, boolean allowExpressions)
Deprecated.useEnumValidator(Class, EnumSet)withEnumSet.allOf(Class)sinceAttributeDefinitionhandles the nullable and expression checks.
-
EnumValidator
@SafeVarargs @Deprecated public EnumValidator(Class<E> enumType, boolean nullable, boolean allowExpressions, E... allowed)
Deprecated.useEnumValidator(Class, Enum[])withEnumSet.allOf(Class)sinceAttributeDefinitionhandles the nullable and expression checks.
-
-
Method Detail
-
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.
-
create
@SafeVarargs @Deprecated public static <E extends Enum<E>> EnumValidator<E> create(Class<E> enumType, boolean nullable, E... allowed)
Deprecated.usecreate(Class, Enum[])sinceAttributeDefinitionhandles the nullable check.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.nullable-trueif the value is allowed to benull, otherwisefalse.allowed- the enum values that are allowed.- Returns:
- a new validator.
-
create
@Deprecated public static <E extends Enum<E>> EnumValidator<E> create(Class<E> enumType, boolean nullable, boolean allowExpressions)
Deprecated.usecreate(Class, EnumSet)withEnumSet.allOf(Class)sinceAttributeDefinitionhandles the nullable and expression checks.Creates a new validator for the enum type with all values of the enum allowed.- Type Parameters:
E- the type of the enum.- Parameters:
enumType- the type of the enum.nullable-trueif the value is allowed to benull, otherwisefalse.allowExpressions-trueif an expression is allowed to define the value, otherwisefalse.- Returns:
- a new validator.
-
create
@SafeVarargs @Deprecated public static <E extends Enum<E>> EnumValidator<E> create(Class<E> enumType, boolean nullable, boolean allowExpressions, E... allowed)
Deprecated.usecreate(Class, Enum[])sinceAttributeDefinitionhandles the nullable and expression checks.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.nullable-trueif the value is allowed to benull, otherwisefalse.allowExpressions-trueif an expression is allowed to define the value, otherwisefalse.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
-
-