public class SimpleAttributeDefinition extends AttributeDefinition
Resource
or a
parameter or reply value type field in an OperationDefinition
, with utility
methods for conversion to and from xml and for validation.AttributeDefinition.NameAndGroup
attributeMarshaller, COMPLEX_TYPES, referenceRecorder
Modifier | Constructor and Description |
---|---|
protected |
SimpleAttributeDefinition(AbstractAttributeDefinitionBuilder<?,? extends SimpleAttributeDefinition> builder) |
|
SimpleAttributeDefinition(String name,
org.jboss.dmr.ModelNode defaultValue,
org.jboss.dmr.ModelType type,
boolean allowNull)
Creates a new attribute definition.
|
|
SimpleAttributeDefinition(String name,
org.jboss.dmr.ModelNode defaultValue,
org.jboss.dmr.ModelType type,
boolean allowNull,
AttributeAccess.Flag... flags)
Creates a new attribute definition.
|
|
SimpleAttributeDefinition(String name,
org.jboss.dmr.ModelType type,
boolean allowNull)
Creates a new attribute definition.
|
|
SimpleAttributeDefinition(String name,
org.jboss.dmr.ModelType type,
boolean allowNull,
AttributeAccess.Flag... flags)
Creates a new attribute definition.
|
|
SimpleAttributeDefinition(String name,
org.jboss.dmr.ModelType type,
boolean allowNull,
MeasurementUnit measurementUnit)
Creates a new attribute definition.
|
|
SimpleAttributeDefinition(String name,
org.jboss.dmr.ModelType type,
boolean allowNull,
MeasurementUnit measurementUnit,
AttributeAccess.Flag... flags)
Creates a new attribute definition.
|
Modifier and Type | Method and Description |
---|---|
void |
marshallAsAttribute(org.jboss.dmr.ModelNode resourceModel,
boolean marshallDefault,
XMLStreamWriter writer)
Marshalls the value from the given
resourceModel as an xml attribute, if it
is marshallable . |
void |
marshallAsAttribute(org.jboss.dmr.ModelNode resourceModel,
XMLStreamWriter writer)
Marshalls the value from the given
resourceModel as an xml attribute, if it
is marshallable . |
void |
marshallAsElement(org.jboss.dmr.ModelNode resourceModel,
boolean marshallDefault,
XMLStreamWriter writer)
Marshalls the value from the given
resourceModel as an xml element, if it
is marshallable . |
org.jboss.dmr.ModelNode |
parse(String value,
XMLStreamReader reader)
Creates and returns a
ModelNode using the given value after first validating the node
against this object's validator . |
void |
parseAndSetParameter(String value,
org.jboss.dmr.ModelNode operation,
XMLStreamReader reader)
Creates a
ModelNode using the given value after first validating the node
against this object's validator , and then stores it in the given operation
model node as a key/value pair whose key is this attribute's name . |
addAccessConstraints, addAllowedValuesToDescription, addCapabilityRequirements, addDeprecatedInfo, addOperationParameterDescription, addOperationParameterDescription, addResourceAttributeDescription, addResourceAttributeDescription, convertParameterExpressions, convertStringExpression, correctValue, getAccessConstraints, getAllowedValues, getAlternatives, getArbitraryDescriptors, getAttributeDeprecatedDescription, getAttributeGroup, getAttributeMarshaller, getAttributeTextDescription, getCorrector, getDefaultValue, getDeprecationData, getFlags, getMeasurementUnit, getName, getNoTextDescription, getParser, getReferenceRecorder, getRequires, getType, getUndefinedMetricValue, getValidator, getXmlName, hasAlternative, hasCapabilityRequirements, isAllowed, isAllowExpression, isAllowNull, isDeprecated, isMarshallable, isMarshallable, isNullSignificant, isRequired, isResourceOnly, isValidatingNull, marshallAsElement, removeCapabilityRequirements, resolveModelAttribute, resolveModelAttribute, resolveValue, resolveValue, validateAndSet, validateOperation
public SimpleAttributeDefinition(String name, org.jboss.dmr.ModelType type, boolean allowNull)
name
- the name of the attribute. Cannot be null
type
- the type of the attribute value. Cannot be null
allowNull
- true
if ModelType.UNDEFINED
is a valid type for the valuepublic SimpleAttributeDefinition(String name, org.jboss.dmr.ModelType type, boolean allowNull, AttributeAccess.Flag... flags)
name
- the name of the attribute. Cannot be null
type
- the type of the attribute value. Cannot be null
allowNull
- true
if ModelType.UNDEFINED
is a valid type for the valueflags
- any flags to indicate special characteristics of the attributepublic SimpleAttributeDefinition(String name, org.jboss.dmr.ModelType type, boolean allowNull, MeasurementUnit measurementUnit)
name
- the name of the attribute. Cannot be null
type
- the type of the attribute value. Cannot be null
allowNull
- true
if ModelType.UNDEFINED
is a valid type for the valuemeasurementUnit
- a measurement unit for the attribute's value. Can be null
public SimpleAttributeDefinition(String name, org.jboss.dmr.ModelType type, boolean allowNull, MeasurementUnit measurementUnit, AttributeAccess.Flag... flags)
name
- the name of the attribute. Cannot be null
type
- the type of the attribute value. Cannot be null
allowNull
- true
if ModelType.UNDEFINED
is a valid type for the valuemeasurementUnit
- a measurement unit for the attribute's value. Can be null
flags
- any flags to indicate special characteristics of the attributepublic SimpleAttributeDefinition(String name, org.jboss.dmr.ModelNode defaultValue, org.jboss.dmr.ModelType type, boolean allowNull)
name
- the name of the attribute. Cannot be null
defaultValue
- a default value to use for the attribute if none is specified by the user. Can be null
type
- the type of the attribute value. Cannot be null
allowNull
- true
if ModelType.UNDEFINED
is a valid type for the valuepublic SimpleAttributeDefinition(String name, org.jboss.dmr.ModelNode defaultValue, org.jboss.dmr.ModelType type, boolean allowNull, AttributeAccess.Flag... flags)
name
- the name of the attribute. Cannot be null
defaultValue
- a default value to use for the attribute if none is specified by the user. Can be null
type
- the type of the attribute value. Cannot be null
allowNull
- true
if ModelType.UNDEFINED
is a valid type for the valueflags
- any flags to indicate special characteristics of the attributeprotected SimpleAttributeDefinition(AbstractAttributeDefinitionBuilder<?,? extends SimpleAttributeDefinition> builder)
public org.jboss.dmr.ModelNode parse(String value, XMLStreamReader reader) throws XMLStreamException
ModelNode
using the given value
after first validating the node
against this object's validator
.
If value
is null
an undefined
node will be returned.
value
- the value. Will be trimmed
before use if not null
.reader
- XMLStreamReader
from which the location
from which
the attribute value was read can be obtained and used in any XMLStreamException
, in case
the given value is invalid.ModelNode
representing the parsed valueXMLStreamException
- if value
is not validparseAndSetParameter(String, ModelNode, XMLStreamReader)
public void parseAndSetParameter(String value, org.jboss.dmr.ModelNode operation, XMLStreamReader reader) throws XMLStreamException
ModelNode
using the given value
after first validating the node
against this object's validator
, and then stores it in the given operation
model node as a key/value pair whose key is this attribute's name
.
If value
is null
an undefined
node will be stored if such a value
is acceptable to the validator.
The expected usage of this method is in parsers seeking to build up an operation to store their parsed data into the configuration.
value
- the value. Will be trimmed
before use if not null
.operation
- model node of type ModelType.OBJECT
into which the parsed value should be storedreader
- XMLStreamReader
from which the location
from which
the attribute value was read can be obtained and used in any XMLStreamException
, in case
the given value is invalid.XMLStreamException
- if value
is not validpublic void marshallAsAttribute(org.jboss.dmr.ModelNode resourceModel, XMLStreamWriter writer) throws XMLStreamException
resourceModel
as an xml attribute, if it
is marshallable
.
Invoking this method is the same as calling marshallAsAttribute(resourceModel, true, writer)
resourceModel
- the model, a non-null node of ModelType.OBJECT
.writer
- stream writer to use for writing the attributeXMLStreamException
- if writer
throws an exceptionpublic void marshallAsAttribute(org.jboss.dmr.ModelNode resourceModel, boolean marshallDefault, XMLStreamWriter writer) throws XMLStreamException
resourceModel
as an xml attribute, if it
is marshallable
.resourceModel
- the model, a non-null node of ModelType.OBJECT
.marshallDefault
- true
if the value should be marshalled even if it matches the default valuewriter
- stream writer to use for writing the attributeXMLStreamException
- if writer
throws an exceptionpublic void marshallAsElement(org.jboss.dmr.ModelNode resourceModel, boolean marshallDefault, XMLStreamWriter writer) throws XMLStreamException
resourceModel
as an xml element, if it
is marshallable
.
This implementation marshalls the attribute value as text content of the element.marshallAsElement
in class AttributeDefinition
marshallDefault
- resourceModel
- the model, a non-null node of ModelType.OBJECT
.writer
- stream writer to use for writing the attributeXMLStreamException
Copyright © 2023 JBoss by Red Hat. All rights reserved.