public abstract class AttributeDefinition extends Object
Resource
, with utility
methods for conversion to and from xml and for validation.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,
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,
ParameterValidator validator,
String[] alternatives,
String[] requires,
AttributeAccess.Flag... flags) |
Modifier and Type | Method and Description |
---|---|
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 |
correctValue(org.jboss.dmr.ModelNode newValue,
org.jboss.dmr.ModelNode oldValue)
Corrects the value if the
value corrector is not null . |
String[] |
getAlternatives() |
String |
getAttributeTextDescription(ResourceBundle bundle,
String prefix) |
org.jboss.dmr.ModelNode |
getDefaultValue() |
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 |
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 |
isRequired(org.jboss.dmr.ModelNode operationObject) |
abstract void |
marshallAsElement(org.jboss.dmr.ModelNode resourceModel,
XMLStreamWriter writer)
Marshalls the value from the given
resourceModel as an xml element, if it
is marshallable . |
org.jboss.dmr.ModelNode |
resolveModelAttribute(OperationContext context,
org.jboss.dmr.ModelNode model)
|
void |
validateAndSet(org.jboss.dmr.ModelNode operationObject,
org.jboss.dmr.ModelNode model)
|
org.jboss.dmr.ModelNode |
validateOperation(org.jboss.dmr.ModelNode operationObject)
|
org.jboss.dmr.ModelNode |
validateResolvedOperation(org.jboss.dmr.ModelNode operationObject)
Deprecated.
|
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, String[] alternatives, String[] requires, AttributeAccess.Flag... flags)
public String getName()
public String getXmlName()
public org.jboss.dmr.ModelType getType()
public boolean isAllowNull()
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 valid@Deprecated public org.jboss.dmr.ModelNode validateResolvedOperation(org.jboss.dmr.ModelNode operationObject) throws OperationFailedException
resolveModelAttribute(OperationContext, ModelNode)
insteadOperationFailedException
public org.jboss.dmr.ModelNode resolveModelAttribute(OperationContext context, org.jboss.dmr.ModelNode model) throws OperationFailedException
model
whose key matches this attribute's name
,
resolves 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 boolean isAllowed(org.jboss.dmr.ModelNode operationObject)
public boolean isRequired(org.jboss.dmr.ModelNode operationObject)
public boolean hasAlternative(org.jboss.dmr.ModelNode operationObject)
public abstract void marshallAsElement(org.jboss.dmr.ModelNode resourceModel, 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 org.jboss.dmr.ModelNode getNoTextDescription(boolean forOperation)
protected 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
.Copyright © 2013 JBoss, a division of Red Hat, Inc.. All rights reserved.