Class ModelTypeValidator

java.lang.Object
org.jboss.as.controller.operations.validation.ModelTypeValidator
All Implemented Interfaces:
ParameterValidator
Direct Known Subclasses:
BytesValidator, CharsetValidator, EnumValidator, InetAddressValidator, IntAllowedValuesValidator, IntRangeValidator, ListValidator, LongRangeValidator, MapValidator, MaskedAddressValidator, ModuleNameValidator, ObjectTypeValidator, PropertyValidator, StringAllowedValuesValidator, StringBytesLengthValidator, StringLengthValidator, TimeUnitValidator

public class ModelTypeValidator extends Object implements ParameterValidator
Validates that the given parameter is of the correct type.

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:

  • For BIG_DECIMAL, BIG_INTEGER, DOUBLE, INT, LONG and PROPERTY, the related ModelNode.asXXX() method is invoked; if no exception is thrown the type is considered to match.
  • For BOOLEAN, if the node is of type BOOLEAN it is considered to match. If it is of type STRING with a value ignoring case of "true" or "false" it is considered to match.
  • For OBJECT, if the node is of type OBJECT or PROPERTY it is considered to match. If it is of type LIST and each element in the list is of type PROPERTY it is considered to match.
  • For STRING, if the node is of type STRING, BIG_DECIMAL, BIG_INTEGER, DOUBLE, INT or LONG it is considered to match.
For all other types, an exact match is required.

Author:
Brian Stansberry (c) 2011 Red Hat Inc.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected static final BigDecimal
     
    protected static final BigDecimal
     
    protected static final BigInteger
     
    protected static final BigInteger
     
    protected final boolean
     
    protected final boolean
     
    protected final Set<org.jboss.dmr.ModelType>
     
  • Constructor Summary

    Constructors
    Constructor
    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.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    validateParameter(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
  • Field Details

    • BIGDECIMAL_MAX

      protected static final BigDecimal BIGDECIMAL_MAX
    • BIGDECIMAL_MIN

      protected static final BigDecimal BIGDECIMAL_MIN
    • BIGINTEGER_MAX

      protected static final BigInteger BIGINTEGER_MAX
    • BIGINTEGER_MIN

      protected static final BigInteger BIGINTEGER_MIN
    • validTypes

      protected final Set<org.jboss.dmr.ModelType> validTypes
    • nullable

      protected final boolean nullable
    • strictType

      protected final boolean strictType
  • Constructor Details

    • ModelTypeValidator

      public ModelTypeValidator(org.jboss.dmr.ModelType type)
      Same as ModelTypeValidator(type, false, false, false).
      Parameters:
      type - the valid type. Cannot be null
    • ModelTypeValidator

      public ModelTypeValidator(org.jboss.dmr.ModelType type, boolean nullable)
      Same as ModelTypeValidator(type, nullable, false, false).
      Parameters:
      type - the valid type. Cannot be null
      nullable - whether ModelType.UNDEFINED is allowed
    • ModelTypeValidator

      public ModelTypeValidator(org.jboss.dmr.ModelType type, boolean nullable, boolean allowExpressions)
      Same as ModelTypeValidator(type, nullable, allowExpressions, false).
      Parameters:
      type - the valid type. Cannot be null
      nullable - whether ModelType.UNDEFINED is allowed
      allowExpressions - whether ModelType.EXPRESSION is allowed
    • ModelTypeValidator

      public ModelTypeValidator(org.jboss.dmr.ModelType type, boolean nullable, boolean allowExpressions, boolean strictType)
      Creates a ModelTypeValidator that allows the given type.
      Parameters:
      type - the valid type. Cannot be null
      nullable - whether ModelType.UNDEFINED is allowed
      allowExpressions - whether ModelType.EXPRESSION is allowed
      strictType - 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 types
    • ModelTypeValidator

      public 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.
      Parameters:
      nullable - whether ModelType.UNDEFINED is allowed
      allowExpressions - whether ModelType.EXPRESSION is allowed
      strictType - 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 types
      firstValidType - a valid type. Cannot be null
      otherValidTypes - additional valid types. May be null
  • Method Details