public class ModelTypeValidator extends Object implements ParameterValidator
Note on strict type matching:
The constructor takes a parameter strictType
. If strictType
is false
, nodes being validated do not
need to precisely match the type(s) passed to the constructor; rather a limited set of value conversions
will be attempted, and if the node value can be converted, the node is considered to match the required type.
The conversions are:
Modifier and Type | Field and Description |
---|---|
protected static BigDecimal |
BIGDECIMAL_MAX |
protected static BigDecimal |
BIGDECIMAL_MIN |
protected static BigInteger |
BIGINTEGER_MAX |
protected static BigInteger |
BIGINTEGER_MIN |
protected boolean |
nullable |
protected boolean |
strictType |
protected EnumSet<org.jboss.dmr.ModelType> |
validTypes |
Constructor and Description |
---|
ModelTypeValidator(boolean nullable,
boolean allowExpressions,
boolean strictType,
org.jboss.dmr.ModelType firstValidType,
org.jboss.dmr.ModelType... otherValidTypes)
Creates a ModelTypeValidator that allows potentially more than one type.
|
ModelTypeValidator(org.jboss.dmr.ModelType type)
Same as
ModelTypeValidator(type, false, false, false) . |
ModelTypeValidator(org.jboss.dmr.ModelType type,
boolean nullable)
Same as
ModelTypeValidator(type, nullable, false, false) . |
ModelTypeValidator(org.jboss.dmr.ModelType type,
boolean nullable,
boolean allowExpressions)
Same as
ModelTypeValidator(type, nullable, allowExpressions, false) . |
ModelTypeValidator(org.jboss.dmr.ModelType type,
boolean nullable,
boolean allowExpressions,
boolean strictType)
Creates a ModelTypeValidator that allows the given type.
|
Modifier and Type | Method and Description |
---|---|
void |
validateParameter(String parameterName,
org.jboss.dmr.ModelNode value)
Validate the parameter with the given name.
|
void |
validateResolvedParameter(String parameterName,
org.jboss.dmr.ModelNode value)
Validate the parameter with the given name, after first
resolving the given value . |
protected static final BigDecimal BIGDECIMAL_MAX
protected static final BigDecimal BIGDECIMAL_MIN
protected static final BigInteger BIGINTEGER_MAX
protected static final BigInteger BIGINTEGER_MIN
protected final EnumSet<org.jboss.dmr.ModelType> validTypes
protected final boolean nullable
protected final boolean strictType
public ModelTypeValidator(org.jboss.dmr.ModelType type)
ModelTypeValidator(type, false, false, false)
.type
- the valid type. Cannot be null
public ModelTypeValidator(org.jboss.dmr.ModelType type, boolean nullable)
ModelTypeValidator(type, nullable, false, false)
.type
- the valid type. Cannot be null
nullable
- whether ModelType.UNDEFINED
is allowedpublic ModelTypeValidator(org.jboss.dmr.ModelType type, boolean nullable, boolean allowExpressions)
ModelTypeValidator(type, nullable, allowExpressions, false)
.type
- the valid type. Cannot be null
nullable
- whether ModelType.UNDEFINED
is allowedallowExpressions
- whether ModelType.EXPRESSION
is allowedpublic ModelTypeValidator(org.jboss.dmr.ModelType type, boolean nullable, boolean allowExpressions, boolean strictType)
type
- the valid type. Cannot be null
nullable
- whether ModelType.UNDEFINED
is allowedallowExpressions
- whether ModelType.EXPRESSION
is allowedstrictType
- true
if the type of a node must precisely match type
; false
if the value
conversions described in the class javadoc can be performed to check for compatible typespublic ModelTypeValidator(boolean nullable, boolean allowExpressions, boolean strictType, org.jboss.dmr.ModelType firstValidType, org.jboss.dmr.ModelType... otherValidTypes)
nullable
- whether ModelType.UNDEFINED
is allowedallowExpressions
- whether ModelType.EXPRESSION
is allowedstrictType
- true
if the type of a node must precisely match type
; false
if the value
conversions described in the class javadoc can be performed to check for compatible typesfirstValidType
- a valid type. Cannot be null
otherValidTypes
- additional valid types. May be null
public void validateParameter(String parameterName, org.jboss.dmr.ModelNode value) throws OperationFailedException
validateParameter
in interface ParameterValidator
parameterName
- the name of the parameter. Cannot be null
value
- the parameter value. Cannot be null
OperationFailedException
- if the value is not validpublic void validateResolvedParameter(String parameterName, org.jboss.dmr.ModelNode value) throws OperationFailedException
resolving
the given value
.validateResolvedParameter
in interface ParameterValidator
parameterName
- the name of the parameter. Cannot be null
value
- the parameter value. Cannot be null
OperationFailedException
- if the value is not validCopyright © 2023 JBoss by Red Hat. All rights reserved.