public abstract class AttributeDefinition extends Object
Resource
, with utility
methods for conversion to and from xml and for validation.Modifier and Type | Field and Description |
---|---|
protected AttributeMarshaller |
attributeMarshaller |
protected static Set<org.jboss.dmr.ModelType> |
COMPLEX_TYPES
The
ModelType types that reflect complex DMR structures -- LIST , OBJECT , PROPERTY } |
Modifier | Constructor and Description |
---|---|
protected |
AttributeDefinition(String name,
String xmlName,
org.jboss.dmr.ModelNode defaultValue,
org.jboss.dmr.ModelType type,
boolean allowNull,
boolean allowExpression,
MeasurementUnit measurementUnit,
ParameterCorrector valueCorrector,
ParameterValidator validator,
boolean validateNull,
String[] alternatives,
String[] requires,
AttributeMarshaller attributeMarshaller,
boolean resourceOnly,
DeprecationData deprecationData,
AccessConstraintDefinition[] accessConstraints,
AttributeAccess.Flag... flags) |
protected |
AttributeDefinition(String name,
String xmlName,
org.jboss.dmr.ModelNode defaultValue,
org.jboss.dmr.ModelType type,
boolean allowNull,
boolean allowExpression,
MeasurementUnit measurementUnit,
ParameterCorrector valueCorrector,
ParameterValidator validator,
boolean validateNull,
String[] alternatives,
String[] requires,
AttributeMarshaller attributeMarshaller,
boolean resourceOnly,
DeprecationData deprecationData,
AccessConstraintDefinition[] accessConstraints,
Boolean nilSignificant,
AttributeAccess.Flag... flags) |
protected |
AttributeDefinition(String name,
String xmlName,
org.jboss.dmr.ModelNode defaultValue,
org.jboss.dmr.ModelType type,
boolean allowNull,
boolean allowExpression,
MeasurementUnit measurementUnit,
ParameterCorrector valueCorrector,
ParameterValidator validator,
boolean validateNull,
String[] alternatives,
String[] requires,
AttributeMarshaller attributeMarshaller,
boolean resourceOnly,
DeprecationData deprecationData,
AttributeAccess.Flag... flags) |
protected |
AttributeDefinition(String name,
String xmlName,
org.jboss.dmr.ModelNode defaultValue,
org.jboss.dmr.ModelType type,
boolean allowNull,
boolean allowExpression,
MeasurementUnit measurementUnit,
ParameterValidator validator,
String[] alternatives,
String[] requires,
AttributeAccess.Flag... flags) |
Modifier and Type | Method and Description |
---|---|
protected void |
addAccessConstraints(org.jboss.dmr.ModelNode result,
Locale locale) |
protected void |
addAllowedValuesToDescription(org.jboss.dmr.ModelNode result,
ParameterValidator validator)
Adds the allowed values.
|
org.jboss.dmr.ModelNode |
addDeprecatedInfo(org.jboss.dmr.ModelNode model) |
org.jboss.dmr.ModelNode |
addOperationParameterDescription(org.jboss.dmr.ModelNode resourceDescription,
String operationName,
ResourceDescriptionResolver resolver,
Locale locale,
ResourceBundle bundle)
Creates a returns a basic model node describing a parameter that sets this attribute, after attaching it to the
given overall operation description model node.
|
org.jboss.dmr.ModelNode |
addOperationParameterDescription(ResourceBundle bundle,
String prefix,
org.jboss.dmr.ModelNode operationDescription)
Creates a returns a basic model node describing a parameter that sets this attribute, after attaching it to the
given overall operation description model node.
|
org.jboss.dmr.ModelNode |
addResourceAttributeDescription(org.jboss.dmr.ModelNode resourceDescription,
ResourceDescriptionResolver resolver,
Locale locale,
ResourceBundle bundle)
Creates a returns a basic model node describing the attribute, after attaching it to the given overall resource
description model node.
|
org.jboss.dmr.ModelNode |
addResourceAttributeDescription(ResourceBundle bundle,
String prefix,
org.jboss.dmr.ModelNode resourceDescription)
Creates a returns a basic model node describing the attribute, after attaching it to the given overall resource
description model node.
|
protected org.jboss.dmr.ModelNode |
convertParameterExpressions(org.jboss.dmr.ModelNode parameter)
Examine the given operation parameter value for any expression syntax, converting the relevant node to
ModelType.EXPRESSION if such is supported. |
protected static org.jboss.dmr.ModelNode |
convertStringExpression(org.jboss.dmr.ModelNode node)
Checks if the given node is of
ModelType.STRING with a string value that includes expression syntax. |
protected org.jboss.dmr.ModelNode |
correctValue(org.jboss.dmr.ModelNode newValue,
org.jboss.dmr.ModelNode oldValue)
Corrects the value if the
value corrector is not null . |
List<AccessConstraintDefinition> |
getAccessConstraints() |
String[] |
getAlternatives() |
String |
getAttributeDeprecatedDescription(ResourceBundle bundle,
String prefix) |
AttributeMarshaller |
getAttributeMarshaller() |
String |
getAttributeTextDescription(ResourceBundle bundle,
String prefix) |
org.jboss.dmr.ModelNode |
getDefaultValue() |
DeprecationData |
getDeprecationData()
return deprecation data if there is any
|
EnumSet<AttributeAccess.Flag> |
getFlags() |
MeasurementUnit |
getMeasurementUnit() |
String |
getName() |
org.jboss.dmr.ModelNode |
getNoTextDescription(boolean forOperation) |
String[] |
getRequires() |
org.jboss.dmr.ModelType |
getType() |
ParameterValidator |
getValidator() |
String |
getXmlName() |
boolean |
hasAlternative(org.jboss.dmr.ModelNode operationObject) |
boolean |
isAllowed(org.jboss.dmr.ModelNode operationObject) |
boolean |
isAllowExpression() |
boolean |
isAllowNull() |
boolean |
isDeprecated() |
boolean |
isMarshallable(org.jboss.dmr.ModelNode resourceModel)
Gets whether the given
resourceModel has a value for this attribute that should be marshalled to XML. |
boolean |
isMarshallable(org.jboss.dmr.ModelNode resourceModel,
boolean marshallDefault)
Gets whether the given
resourceModel has a value for this attribute that should be marshalled to XML. |
boolean |
isNullSignificant() |
boolean |
isRequired(org.jboss.dmr.ModelNode operationObject) |
boolean |
isResourceOnly()
Show if attribute is resource only which means it wont be part of add operations but only present on resource
|
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 . |
void |
marshallAsElement(org.jboss.dmr.ModelNode resourceModel,
XMLStreamWriter writer)
Marshalls the value from the given
resourceModel as an xml attribute, if it
is marshallable . |
org.jboss.dmr.ModelNode |
resolveModelAttribute(ExpressionResolver resolver,
org.jboss.dmr.ModelNode model)
Finds a value in the given
model whose key matches this attribute's name ,
uses the given resolver to ExpressionResolver.resolveExpressions(org.jboss.dmr.ModelNode) resolve}
it and validates it using this attribute's validator . |
org.jboss.dmr.ModelNode |
resolveModelAttribute(OperationContext context,
org.jboss.dmr.ModelNode model)
|
org.jboss.dmr.ModelNode |
resolveValue(ExpressionResolver resolver,
org.jboss.dmr.ModelNode value)
Takes the given
value , resolves it using the given resolver
and validates it using this attribute's validator . |
org.jboss.dmr.ModelNode |
resolveValue(OperationContext context,
org.jboss.dmr.ModelNode value)
Takes the given
value , resolves it using the given context
and validates it using this attribute's validator . |
void |
validateAndSet(org.jboss.dmr.ModelNode operationObject,
org.jboss.dmr.ModelNode model)
|
org.jboss.dmr.ModelNode |
validateOperation(org.jboss.dmr.ModelNode operationObject)
|
protected static final Set<org.jboss.dmr.ModelType> COMPLEX_TYPES
ModelType
types that reflect complex DMR structures -- LIST
, OBJECT
, PROPERTY
}protected final AttributeMarshaller attributeMarshaller
protected AttributeDefinition(String name, String xmlName, org.jboss.dmr.ModelNode defaultValue, org.jboss.dmr.ModelType type, boolean allowNull, boolean allowExpression, MeasurementUnit measurementUnit, ParameterValidator validator, String[] alternatives, String[] requires, AttributeAccess.Flag... flags)
protected AttributeDefinition(String name, String xmlName, org.jboss.dmr.ModelNode defaultValue, org.jboss.dmr.ModelType type, boolean allowNull, boolean allowExpression, MeasurementUnit measurementUnit, ParameterCorrector valueCorrector, ParameterValidator validator, boolean validateNull, String[] alternatives, String[] requires, AttributeMarshaller attributeMarshaller, boolean resourceOnly, DeprecationData deprecationData, AttributeAccess.Flag... flags)
protected AttributeDefinition(String name, String xmlName, org.jboss.dmr.ModelNode defaultValue, org.jboss.dmr.ModelType type, boolean allowNull, boolean allowExpression, MeasurementUnit measurementUnit, ParameterCorrector valueCorrector, ParameterValidator validator, boolean validateNull, String[] alternatives, String[] requires, AttributeMarshaller attributeMarshaller, boolean resourceOnly, DeprecationData deprecationData, AccessConstraintDefinition[] accessConstraints, AttributeAccess.Flag... flags)
protected AttributeDefinition(String name, String xmlName, org.jboss.dmr.ModelNode defaultValue, org.jboss.dmr.ModelType type, boolean allowNull, boolean allowExpression, MeasurementUnit measurementUnit, ParameterCorrector valueCorrector, ParameterValidator validator, boolean validateNull, String[] alternatives, String[] requires, AttributeMarshaller attributeMarshaller, boolean resourceOnly, DeprecationData deprecationData, AccessConstraintDefinition[] accessConstraints, Boolean nilSignificant, AttributeAccess.Flag... flags)
public String getName()
public String getXmlName()
public org.jboss.dmr.ModelType getType()
public boolean isAllowNull()
public boolean isNullSignificant()
public boolean isAllowExpression()
public org.jboss.dmr.ModelNode getDefaultValue()
public MeasurementUnit getMeasurementUnit()
public ParameterValidator getValidator()
public String[] getAlternatives()
public String[] getRequires()
public EnumSet<AttributeAccess.Flag> getFlags()
public boolean isMarshallable(org.jboss.dmr.ModelNode resourceModel)
resourceModel
has a value for this attribute that should be marshalled to XML.
This is the same as isMarshallable(resourceModel, true)
.
resourceModel
- the model, a non-null node of ModelType.OBJECT
.true
if the given resourceModel
has a defined value under this attribute's getName()
() name}.public boolean isMarshallable(org.jboss.dmr.ModelNode resourceModel, boolean marshallDefault)
resourceModel
has a value for this attribute that should be marshalled to XML.resourceModel
- the model, a non-null node of ModelType.OBJECT
.marshallDefault
- true
if the value should be marshalled even if it matches the default valuetrue
if the given resourceModel
has a defined value under this attribute's getName()
() name}
and marshallDefault
is true
or that value differs from this attribute's default value
.public org.jboss.dmr.ModelNode validateOperation(org.jboss.dmr.ModelNode operationObject) throws OperationFailedException
operationObject
whose key matches this attribute's name
and
validates it using this attribute's validator
.operationObject
- model node of type ModelType.OBJECT
, typically representing an operation requestOperationFailedException
- if the value is not validpublic final void validateAndSet(org.jboss.dmr.ModelNode operationObject, org.jboss.dmr.ModelNode model) throws OperationFailedException
operationObject
whose key matches this attribute's name
,
validates it using this attribute's validator
, and, stores it under this attribute's name in the given model
.operationObject
- model node of type ModelType.OBJECT
, typically representing an operation requestmodel
- model node in which the value should be storedOperationFailedException
- if the value is not validpublic org.jboss.dmr.ModelNode resolveModelAttribute(OperationContext context, org.jboss.dmr.ModelNode model) throws OperationFailedException
model
whose key matches this attribute's name
,
uses the given context
to resolve
it and validates it using this attribute's validator
. If the value is
undefined and a default value
is available, the default value is used.context
- the operation contextmodel
- model node of type ModelType.OBJECT
, typically representing a model resourceOperationFailedException
- if the value is not validpublic org.jboss.dmr.ModelNode resolveModelAttribute(ExpressionResolver resolver, org.jboss.dmr.ModelNode model) throws OperationFailedException
model
whose key matches this attribute's name
,
uses the given resolver
to ExpressionResolver.resolveExpressions(org.jboss.dmr.ModelNode)
resolve}
it and validates it using this attribute's validator
. If the value is
undefined and a default value
is available, the default value is used.resolver
- the expression resolvermodel
- model node of type ModelType.OBJECT
, typically representing a model resourceOperationFailedException
- if the value is not validpublic org.jboss.dmr.ModelNode resolveValue(OperationContext context, org.jboss.dmr.ModelNode value) throws OperationFailedException
value
, resolves it using the given context
and validates it using this attribute's validator
. If the value is
undefined and a default value
is available, the default value is used.context
- the context to use to resolve
the valuevalue
- a node that is expected to be a valid value for an attribute defined by this definitionvalue
is not definedOperationFailedException
- if the value is not validpublic org.jboss.dmr.ModelNode resolveValue(ExpressionResolver resolver, org.jboss.dmr.ModelNode value) throws OperationFailedException
value
, resolves it using the given resolver
and validates it using this attribute's validator
. If the value is
undefined and a default value
is available, the default value is used.resolver
- the expression resolvervalue
- a node that is expected to be a valid value for an attribute defined by this definitionvalue
is not definedOperationFailedException
- if the value is not validpublic boolean isAllowed(org.jboss.dmr.ModelNode operationObject)
public boolean isRequired(org.jboss.dmr.ModelNode operationObject)
public boolean hasAlternative(org.jboss.dmr.ModelNode operationObject)
public void marshallAsElement(org.jboss.dmr.ModelNode resourceModel, XMLStreamWriter writer) throws XMLStreamException
resourceModel
as an xml attribute, if it
is marshallable
.resourceModel
- the model, a non-null node of ModelType.OBJECT
.writer
- stream writer to use for writing the attributeXMLStreamException
- if thrown by writer
public void marshallAsElement(org.jboss.dmr.ModelNode resourceModel, boolean marshallDefault, XMLStreamWriter writer) throws XMLStreamException
resourceModel
as an xml element, if it
is marshallable
.resourceModel
- the model, a non-null node of ModelType.OBJECT
.writer
- stream writer to use for writing the attributeXMLStreamException
- if thrown by writer
public org.jboss.dmr.ModelNode addResourceAttributeDescription(ResourceBundle bundle, String prefix, org.jboss.dmr.ModelNode resourceDescription)
bundle
- resource bundle to use for text descriptionsprefix
- prefix to prepend to the attribute name key when looking up descriptionsresourceDescription
- the overall resource descriptionpublic org.jboss.dmr.ModelNode addResourceAttributeDescription(org.jboss.dmr.ModelNode resourceDescription, ResourceDescriptionResolver resolver, Locale locale, ResourceBundle bundle)
resourceDescription
- the overall resource descriptionresolver
- provider of localized text descriptionslocale
- locale to pass to the resolverbundle
- bundle to pass to the resolverpublic org.jboss.dmr.ModelNode addOperationParameterDescription(ResourceBundle bundle, String prefix, org.jboss.dmr.ModelNode operationDescription)
bundle
- resource bundle to use for text descriptionsprefix
- prefix to prepend to the attribute name key when looking up descriptionsoperationDescription
- the overall resource descriptionpublic org.jboss.dmr.ModelNode addOperationParameterDescription(org.jboss.dmr.ModelNode resourceDescription, String operationName, ResourceDescriptionResolver resolver, Locale locale, ResourceBundle bundle)
resourceDescription
- the overall resource descriptionoperationName
- the operation nameresolver
- provider of localized text descriptionslocale
- locale to pass to the resolverbundle
- bundle to pass to the resolverpublic String getAttributeTextDescription(ResourceBundle bundle, String prefix)
public String getAttributeDeprecatedDescription(ResourceBundle bundle, String prefix)
public org.jboss.dmr.ModelNode addDeprecatedInfo(org.jboss.dmr.ModelNode model)
public org.jboss.dmr.ModelNode getNoTextDescription(boolean forOperation)
protected void addAllowedValuesToDescription(org.jboss.dmr.ModelNode result, ParameterValidator validator)
result
- the node to add the allowed values tovalidator
- the validator to get the allowed values fromprotected final org.jboss.dmr.ModelNode correctValue(org.jboss.dmr.ModelNode newValue, org.jboss.dmr.ModelNode oldValue)
value corrector
is not null
. If the value corrector
is null
, the newValue
parameter is returned.newValue
- the new value.oldValue
- the old value.newValue
if the value corrector
is null
.protected org.jboss.dmr.ModelNode convertParameterExpressions(org.jboss.dmr.ModelNode parameter)
ModelType.EXPRESSION
if such is supported.
This implementation checks if expressions are allowed
and if so, calls
convertStringExpression(ModelNode)
to convert a ModelType.STRING
to a ModelType.EXPRESSION
.
No other conversions are performed. For use cases requiring more complex behavior, a subclass that overrides
this method should be used.
If expressions are supported this implementation also checks if the attribute type
is one of
the complex DMR types
. If it is, an IllegalStateException
is thrown, as this
implementation cannot properly handle such a combination, and a subclass that overrides this method should be used.
parameter
- the node to examine. Cannot not be null
parameter
but with expressions converted, or the original parameter if no
conversion was performed. Will not return null
IllegalStateException
- if expressions are supported, but the attribute type
is complex
protected static org.jboss.dmr.ModelNode convertStringExpression(org.jboss.dmr.ModelNode node)
ModelType.STRING
with a string value that includes expression syntax.
If so returns a node of ModelType.EXPRESSION
, else simply returns node
unchangednode
- the node to examine. Will not be null
null
public AttributeMarshaller getAttributeMarshaller()
public boolean isResourceOnly()
public boolean isDeprecated()
public DeprecationData getDeprecationData()
DeprecationData
public List<AccessConstraintDefinition> getAccessConstraints()
protected void addAccessConstraints(org.jboss.dmr.ModelNode result, Locale locale)
Copyright © 2013 JBoss by Red Hat. All rights reserved.