/** * Creates a handler that users the given {@code attributeDefinition} * to validate values before applying them to the model. * * @param attributeDefinition the definition of the attribute being written */ public ServerWriteAttributeOperationHandler(AttributeDefinition attributeDefinition) { this(attributeDefinition.getValidator(), attributeDefinition.getValidator()); }
/** * Creates a handler that users the given {@code attributeDefinition} * to validate values before applying them to the model. * * @param attributeDefinition the definition of the attribute being written */ public ServerWriteAttributeOperationHandler(AttributeDefinition attributeDefinition) { this(attributeDefinition.getValidator(), attributeDefinition.getValidator()); }
public AttributeDefinitionValidatingHandler(AttributeDefinition definition) { super(definition.getValidator()); this.attributeDefinition = definition; }
public AttributeDefinitionValidatingHandler(AttributeDefinition definition) { super(definition.getValidator()); this.attributeDefinition = definition; }
protected SimpleListAttributeDefinition(final String name, final String xmlName, final AttributeDefinition valueType, final boolean allowNull, final int minSize, final int maxSize, final String[] alternatives, final String[] requires, AttributeMarshaller attributeMarshaller,final boolean resourceOnly, final DeprecationData deprecated, final AttributeAccess.Flag... flags) { super(name, xmlName, allowNull, false, minSize, maxSize, valueType.getValidator(), alternatives, requires, attributeMarshaller, resourceOnly, deprecated, flags); this.valueType = valueType; }
/** * @deprecated use a {@link org.jboss.as.controller.SimpleListAttributeDefinition.Builder builder} */ @Deprecated @SuppressWarnings("deprecation") protected SimpleListAttributeDefinition(final String name, final String xmlName, final AttributeDefinition valueType, final boolean allowNull, final int minSize, final int maxSize, final String[] alternatives, final String[] requires, AttributeMarshaller attributeMarshaller, final boolean resourceOnly, final DeprecationData deprecated, final AccessConstraintDefinition[] accessConstraints, final Boolean nullSignificant, final AttributeParser parser, final AttributeAccess.Flag... flags) { super(name, xmlName, allowNull, false, minSize, maxSize, valueType.getValidator(), alternatives, requires, attributeMarshaller, resourceOnly, deprecated, accessConstraints, nullSignificant, parser, flags); this.valueType = valueType; }
public Builder(final String name, final AttributeDefinition valueType) { super(name); this.valueType = valueType; setElementValidator(valueType.getValidator()); }
public Builder(final String name, final AttributeDefinition valueType) { super(name); this.valueType = valueType; setElementValidator(valueType.getValidator()); }
public Builder(final String name, final AttributeDefinition valueType) { super(name); this.valueType = valueType; setElementValidator(valueType.getValidator()); }
public Builder(final SimpleListAttributeDefinition basis) { super(basis); valueType = basis.getValueType(); setElementValidator(valueType.getValidator()); }
@Override public void validateParameter(final String parameterName, final ModelNode value) throws OperationFailedException { super.validateParameter(parameterName, value); if (value.isDefined()) { for (String key : value.keys()) { if (allowedValues.containsKey(key)) { allowedValues.get(key).getValidator().validateParameter(key, value.get(key)); } else { throw new OperationFailedException(new ModelNode().set("invalid type key")); } } } }
@Override public void validateParameter(final String parameterName, final ModelNode value) throws OperationFailedException { super.validateParameter(parameterName, value); if (value.isDefined()) { for (String key : value.keys()) { if (allowedValues.containsKey(key)) { allowedValues.get(key).getValidator().validateParameter(key, value.get(key)); } else { throw new OperationFailedException(new ModelNode().set("invalid type key")); } } } }
@Override public void validateParameter(final String parameterName, final ModelNode value) throws OperationFailedException { super.validateParameter(parameterName, value); if (value.isDefined()) { for (AttributeDefinition ad : allowedValues.values()) { String key = ad.getName(); // Don't modify the value by calls to get(), because that's best in general. // Plus modifying it results in an irrelevant test failure in full where the test // isn't expecting the modification and complains. // Changing the test is too much trouble. ModelNode toTest = value.has(key) ? value.get(key) : new ModelNode(); ad.getValidator().validateParameter(key, toTest); } } } }
@Override public void validateParameter(final String parameterName, final ModelNode value) throws OperationFailedException { super.validateParameter(parameterName, value); if (value.isDefined()) { for (AttributeDefinition ad : allowedValues.values()) { String key = ad.getName(); // Don't modify the value by calls to get(), because that's best in general. // Plus modifying it results in an irrelevant test failure in full where the test // isn't expecting the modification and complains. // Changing the test is too much trouble. ModelNode toTest = value.has(key) ? value.get(key) : new ModelNode(); ad.getValidator().validateParameter(key, toTest); } } } }
@Override public void validateParameter(final String parameterName, final ModelNode value) throws OperationFailedException { super.validateParameter(parameterName, value); for (final AttributeDefinition def : NESTED_ATTRIBUTES) { final String name = def.getName(); if (value.hasDefined(name)) { final ModelNode v = value.get(name); if (NESTED_LIST_ATTRIBUTES.contains(def)) { if (ModelType.LIST != v.getType()) { throw new OperationFailedException(new ModelNode().set(MESSAGES.invalidType(v.getType()))); } } else { def.getValidator().validateParameter(name, v); } } } } };
@Override public void validateParameter(final String parameterName, final ModelNode value) throws OperationFailedException { super.validateParameter(parameterName, value); for (final AttributeDefinition def : NESTED_ATTRIBUTES) { final String name = def.getName(); if (value.hasDefined(name)) { final ModelNode v = value.get(name); if (NESTED_LIST_ATTRIBUTES.contains(def)) { if (ModelType.LIST != v.getType()) { throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.invalidType(v.getType())); } } else { def.getValidator().validateParameter(name, v); } } } } };
@Override public void validateParameter(final String parameterName, final ModelNode value) throws OperationFailedException { super.validateParameter(parameterName, value); for (final AttributeDefinition def : NESTED_ATTRIBUTES) { final String name = def.getName(); if (value.hasDefined(name)) { final ModelNode v = value.get(name); if (NESTED_LIST_ATTRIBUTES.contains(def)) { if (ModelType.LIST != v.getType()) { throw new OperationFailedException(ControllerLogger.ROOT_LOGGER.invalidType(v.getType())); } } else { def.getValidator().validateParameter(name, v); } } } } };
public AbstractAttributeDefinitionBuilder(final String attributeName, final AttributeDefinition basis) { this.name = attributeName != null ? attributeName : basis.getName(); this.type = basis.getType(); this.xmlName = basis.getXmlName(); this.allowNull = basis.isAllowNull(); this.allowExpression = basis.isAllowExpression(); this.defaultValue = basis.getDefaultValue(); this.measurementUnit = basis.getMeasurementUnit(); this.alternatives = basis.getAlternatives(); this.requires = basis.getRequires(); this.validator = basis.getValidator(); Set<AttributeAccess.Flag> basisFlags = basis.getFlags(); this.flags = basisFlags.toArray(new AttributeAccess.Flag[basisFlags.size()]); this.attributeMarshaller = basis.getAttributeMarshaller(); }
private ModelNode parse(final AttributeDefinition attribute, final String value) throws OperationFailedException { ModelNode node = ParseUtils.parseAttributeValue(value, attribute.isAllowExpression(), attribute.getType()); final ParameterValidator validator; // A bit yuck, but I didn't want to introduce a new type just for this if (attribute instanceof ListAttributeDefinition) { validator = ((ListAttributeDefinition) attribute).getElementValidator(); } else if (attribute instanceof MapAttributeDefinition) { validator = ((MapAttributeDefinition) attribute).getElementValidator(); } else { validator = attribute.getValidator(); } validator.validateParameter(attribute.getXmlName(), node); return node; }
private ModelNode parse(final AttributeDefinition attribute, final String value) throws OperationFailedException { ModelNode node = ParseUtils.parseAttributeValue(value, attribute.isAllowExpression(), attribute.getType()); final ParameterValidator validator; // A bit yuck, but I didn't want to introduce a new type just for this if (attribute instanceof ListAttributeDefinition) { validator = ((ListAttributeDefinition) attribute).getElementValidator(); } else if (attribute instanceof MapAttributeDefinition) { validator = ((MapAttributeDefinition) attribute).getElementValidator(); } else { validator = attribute.getValidator(); } validator.validateParameter(attribute.getXmlName(), node); return node; }