Class AbstractAttributeDefinitionBuilder<BUILDER extends AbstractAttributeDefinitionBuilder<BUILDER,ATTRIBUTE>,ATTRIBUTE extends AttributeDefinition>

java.lang.Object
org.jboss.as.controller.AbstractAttributeDefinitionBuilder<BUILDER,ATTRIBUTE>
Type Parameters:
BUILDER - the specific subclass type returned by the various builder API methods
ATTRIBUTE - the type of AttributeDefinition produced by the build() method
Direct Known Subclasses:
ListAttributeDefinition.Builder, MapAttributeDefinition.Builder, ObjectTypeAttributeDefinition.Builder, SimpleAttributeDefinitionBuilder

public abstract class AbstractAttributeDefinitionBuilder<BUILDER extends AbstractAttributeDefinitionBuilder<BUILDER,ATTRIBUTE>,ATTRIBUTE extends AttributeDefinition> extends Object
Provides a builder API for creating an AttributeDefinition.
Author:
Tomaz Cerar
  • Constructor Details

    • AbstractAttributeDefinitionBuilder

      public AbstractAttributeDefinitionBuilder(String attributeName, org.jboss.dmr.ModelType type)
      Creates a builder for an attribute with the give name and type. Equivalent to AbstractAttributeDefinitionBuilder(attributeName, type, false
      Parameters:
      attributeName - the name of the attribute. Cannot be null
      type - the type of the attribute. Cannot be null
    • AbstractAttributeDefinitionBuilder

      public AbstractAttributeDefinitionBuilder(String attributeName, org.jboss.dmr.ModelType type, boolean optional)
      Creates a builder for an attribute with the give name and type and nullability setting.
      Parameters:
      attributeName - the name of the attribute. Cannot be null
      type - the type of the attribute. Cannot be null
      optional - true if the attribute allows undefined values in the absence of alternatives
    • AbstractAttributeDefinitionBuilder

      public AbstractAttributeDefinitionBuilder(AttributeDefinition basis)
      Creates a builder populated with the values of an existing attribute definition.
      Parameters:
      basis - the existing attribute definition. Cannot be null
    • AbstractAttributeDefinitionBuilder

      public AbstractAttributeDefinitionBuilder(String attributeName, AttributeDefinition basis)
      Creates a builder populated with the values of an existing attribute definition, with an optional change of the attribute's name.
      Parameters:
      attributeName - the name of the attribute, or null if the name from basis should be used
      basis - the existing attribute definition. Cannot be null
  • Method Details

    • build

      public abstract ATTRIBUTE build()
      Returns:
      the attribute definition. Will not return null
    • setXmlName

      public BUILDER setXmlName(String xmlName)
      Sets the xml name for the attribute, which is only needed if the name used for the attribute is different from its ordinary name in the model. If not set the default value is the name passed to the builder constructor.
      Parameters:
      xmlName - the xml name. null is allowed
      Returns:
      a builder that can be used to continue building the attribute definition
    • setRequired

      public BUILDER setRequired(boolean required)
      Sets whether the attribute should require a defined value in the absence of alternatives. If not set the default value is the value provided to the builder constructor, or true if no value is provided.
      Parameters:
      required - true if undefined values should not be allowed in the absence of alternatives
      Returns:
      a builder that can be used to continue building the attribute definition
    • setAllowExpression

      public BUILDER setAllowExpression(boolean allowExpression)
      Sets whether the attribute should allow expressions If not set the default value is false.
      Parameters:
      allowExpression - true if expression values should be allowed
      Returns:
      a builder that can be used to continue building the attribute definition
    • setDefaultValue

      public BUILDER setDefaultValue(org.jboss.dmr.ModelNode defaultValue)
      Sets a default value to use for the attribute if no user-provided value is available.
      Parameters:
      defaultValue - the default value, or null if no default should be used
      Returns:
      a builder that can be used to continue building the attribute definition
    • setMeasurementUnit

      public BUILDER setMeasurementUnit(MeasurementUnit unit)
      Sets a measurement unit to describe the unit in which a numeric attribute is expressed.
      Parameters:
      unit - the unit. null is allowed
      Returns:
      a builder that can be used to continue building the attribute definition
    • setCorrector

      public BUILDER setCorrector(ParameterCorrector corrector)
      Sets a ParameterCorrector to use to adjust any user provided values before validation occurs.
      Parameters:
      corrector - the corrector. May be null
      Returns:
      a builder that can be used to continue building the attribute definition
    • setValidator

      public BUILDER setValidator(ParameterValidator validator)
      Sets the validator that should be used to validate attribute values. The resulting attribute definition will wrap this validator in one that enforces the attribute's allow null and allow expression settings, so the given validator need not be properly configured for those validations.
      Parameters:
      validator - the validator. null is allowed
      Returns:
      a builder that can be used to continue building the attribute definition
    • setAlternatives

      public BUILDER setAlternatives(String... alternatives)
      Sets names of alternative attributes that should not be defined if this attribute is defined.
      Parameters:
      alternatives - the attribute names
      Returns:
      a builder that can be used to continue building the attribute definition
    • addAlternatives

      public BUILDER addAlternatives(String... alternatives)
      Adds names of alternative attributes that should not be defined if this attribute is defined.
      Parameters:
      alternatives - the attribute names
      Returns:
      a builder that can be used to continue building the attribute definition
    • removeAlternatives

      public final BUILDER removeAlternatives(String... alternatives)
      Removes names of alternative attributes from the set of those that should not be defined if this attribute is defined.
      Parameters:
      alternatives - the attribute names
      Returns:
      a builder that can be used to continue building the attribute definition
    • addArbitraryDescriptor

      public BUILDER addArbitraryDescriptor(String arbitraryDescriptor, org.jboss.dmr.ModelNode value)
      Parameters:
      arbitraryDescriptor - the arbitrary descriptor name.
      value - the value of the arbitrary descriptor.
      Returns:
      a builder that can be used to continue building the attribute definition
    • getArbitraryDescriptors

      public Map<String,org.jboss.dmr.ModelNode> getArbitraryDescriptors()
    • setRequires

      public BUILDER setRequires(String... requires)
      Sets names of required attributes that must be defined if this attribute is defined.
      Parameters:
      requires - the attribute names
      Returns:
      a builder that can be used to continue building the attribute definition
    • setFlags

      public BUILDER setFlags(AttributeAccess.Flag... flags)
      Sets the special purpose flags that are relevant to the attribute
      Parameters:
      flags - the flags
      Returns:
      a builder that can be used to continue building the attribute definition
    • addFlag

      public BUILDER addFlag(AttributeAccess.Flag flag)
      Adds a special purpose flag that is relevant to the attribute
      Parameters:
      flag - the flag
      Returns:
      a builder that can be used to continue building the attribute definition
    • removeFlag

      public BUILDER removeFlag(AttributeAccess.Flag flag)
      Removes a special purpose flag from the set of those relevant to the attribute
      Parameters:
      flag - the flag
      Returns:
      a builder that can be used to continue building the attribute definition
    • isFlagPresent

      protected boolean isFlagPresent(AttributeAccess.Flag flag)
      Checks if a special purpose flag has been recorded as relevant to the attribute
      Parameters:
      flag - the flag
      Returns:
      a builder that can be used to continue building the attribute definition
    • setStorageRuntime

      public BUILDER setStorageRuntime()
      Adds the AttributeAccess.Flag.STORAGE_RUNTIME flag and removes any conflicting flag.
      Returns:
      a builder that can be used to continue building the attribute definition
    • setRuntimeServiceNotRequired

      public BUILDER setRuntimeServiceNotRequired()
      Returns:
      a builder that can be used to continue building the attribute definition
    • setRestartAllServices

      public BUILDER setRestartAllServices()
      Adds the AttributeAccess.Flag.RESTART_ALL_SERVICES flag and removes any conflicting flag.
      Returns:
      a builder that can be used to continue building the attribute definition
    • setRestartJVM

      public BUILDER setRestartJVM()
      Adds the AttributeAccess.Flag.RESTART_JVM flag and removes any conflicting flag.
      Returns:
      a builder that can be used to continue building the attribute definition
    • setMaxSize

      public BUILDER setMaxSize(int maxSize)
      Sets a maximum size for a collection-type attribute or one whose value is a string or byte[]. The value represents the maximum number of elements in the collection, or the maximum length of the string or array. It does not represent a maximum value for a numeric attribute and should not be configured for numeric attributes.
      Parameters:
      maxSize - the maximum size
      Returns:
      a builder that can be used to continue building the attribute definition
    • setMinSize

      public BUILDER setMinSize(int minSize)
      Sets a minimum size description for a collection-type attribute or one whose value is a string or byte[]. The value represents the minimum number of elements in the collection, or the minimum length of the string or array. It does not represent a minimum value for a numeric attribute and should not be configured for numeric attributes.
      Parameters:
      minSize - the minimum size
      Returns:
      a builder that can be used to continue building the attribute definition
    • setAttributeMarshaller

      public BUILDER setAttributeMarshaller(AttributeMarshaller marshaller)
      Sets a custom AttributeMarshaller to use for marshalling the attribute to xml. If not set, a DefaultAttributeMarshaller will be used.
      Parameters:
      marshaller - the marshaller. Can be null
      Returns:
      a builder that can be used to continue building the attribute definition
    • setAttributeParser

      public BUILDER setAttributeParser(AttributeParser parser)
      Sets a custom AttributeParser to use for parsing attribute from xml. If not set, a AttributeParser.SIMPLE will be used.
      Parameters:
      parser - the parser. Can be null
      Returns:
      a builder that can be used to continue building the attribute definition
    • setResourceOnly

      public BUILDER setResourceOnly()
      Marks an attribute as only relevant to a resource, and not a valid parameter to an "add" operation that creates that resource. Typically used for legacy "name" attributes that display the final value in the resource's address as an attribute.
      Returns:
      a builder that can be used to continue building the attribute definition
    • setDeprecated

      public BUILDER setDeprecated(ModelVersion since)
      Marks the attribute as deprecated since the given API version. This is equivalent to calling setDeprecated(ModelVersion, boolean) with the notificationUseful parameter set to true.
      Parameters:
      since - the API version, with the API being the one (core or a subsystem) in which the attribute is used
      Returns:
      a builder that can be used to continue building the attribute definition
    • setDeprecated

      public BUILDER setDeprecated(ModelVersion since, boolean notificationUseful)
      Marks the attribute as deprecated since the given API version, with the ability to configure that notifications to the user (e.g. via a log message) about deprecation of the attribute should not be emitted. Notifying the user should only be done if the user can take some action in response. Advising that something will be removed in a later release is not useful if there is no alternative in the current release. If the notificationUseful param is true the text description of the attribute deprecation available from the read-resource-description management operation should provide useful information about how the user can avoid using the attribute.
      Parameters:
      since - the API version, with the API being the one (core or a subsystem) in which the attribute is used
      notificationUseful - whether actively advising the user about the deprecation is useful
      Returns:
      a builder that can be used to continue building the attribute definition
    • setExpressionsDeprecated

      public final BUILDER setExpressionsDeprecated()
      Marks that support for use of an expression for the attribute's value is deprecated and may be removed in a future release.
      Returns:
      a builder that can be used to continue building the attribute definition
    • setAccessConstraints

      public BUILDER setAccessConstraints(AccessConstraintDefinition... accessConstraints)
      Sets access constraints to use with the attribute
      Parameters:
      accessConstraints - the constraints
      Returns:
      a builder that can be used to continue building the attribute definition
    • addAccessConstraint

      public BUILDER addAccessConstraint(AccessConstraintDefinition accessConstraint)
      Adds an access constraint to the set used with the attribute
      Parameters:
      accessConstraint - the constraint
      Returns:
      a builder that can be used to continue building the attribute definition
    • setNullSignificant

      public BUILDER setNullSignificant(boolean nullSignificant)
      Sets whether an access control check is required to implicitly set an attribute to undefined in a resource "add" operation. "Implicitly" setting an attribute refers to not providing a value for it in the add operation, leaving the attribute in an undefined state. If not set the default value is whether the attribute AttributeDefinition.isRequired() () is not required} and has a default value.
      Parameters:
      nullSignificant - true if an undefined value is significant; false if it is not significant, even if a default value is configured
      Returns:
      a builder that can be used to continue building the attribute definition
    • setAttributeGroup

      public BUILDER setAttributeGroup(String attributeGroup)
      Sets the name of the attribute group with which this attribute is associated.
      Parameters:
      attributeGroup - the attribute group name. Cannot be an empty string but can be null if the attribute is not associated with a group.
      Returns:
      a builder that can be used to continue building the attribute definition
    • setAllowedValues

      public BUILDER setAllowedValues(org.jboss.dmr.ModelNode... allowedValues)
      Sets allowed values for attribute
      Parameters:
      allowedValues - values that are legal as part in this attribute
      Returns:
      a builder that can be used to continue building the attribute definition
    • setAllowedValues

      public BUILDER setAllowedValues(String... allowedValues)
      Sets allowed values for attribute
      Parameters:
      allowedValues - values that are legal as part in this attribute
      Returns:
      a builder that can be used to continue building the attribute definition
    • setAllowedValues

      public BUILDER setAllowedValues(int... allowedValues)
      Sets allowed values for attribute
      Parameters:
      allowedValues - values that are legal as part in this attribute
      Returns:
      a builder that can be used to continue building the attribute definition
    • setCapabilityReference

      public BUILDER setCapabilityReference(String referencedCapability, RuntimeCapability<?> dependentCapability)
      Records that this attribute's value represents a reference to an instance of a dynamic capability.

      This method is a convenience method equivalent to calling setCapabilityReference(CapabilityReferenceRecorder) passing in a CapabilityReferenceRecorder.DefaultCapabilityReferenceRecorder constructed using the parameters passed to this method.

      Parameters:
      referencedCapability - the name of the dynamic capability the dynamic portion of whose name is represented by the attribute's value
      dependentCapability - the capability that depends on referencedCapability
      Returns:
      the builder
      See Also:
    • setCapabilityReference

      public BUILDER setCapabilityReference(String referencedCapability)
      Records that this attribute's value represents a reference to an instance of a dynamic capability.

      This method is a convenience method equivalent to calling setCapabilityReference(CapabilityReferenceRecorder) passing in a CapabilityReferenceRecorder.ContextDependencyRecorder constructed using the parameters passed to this method.

      NOTE: This method of recording capability references is only suitable for use in attributes only used in resources that themselves expose a single capability. If your resource exposes more than single you should use setCapabilityReference(RuntimeCapability, String, AttributeDefinition...) variant When the capability requirement is registered, the dependent capability will be that capability.

      Parameters:
      referencedCapability - the name of the dynamic capability the dynamic portion of whose name is represented by the attribute's value
      Returns:
      the builder
      See Also:
    • setCapabilityReference

      public BUILDER setCapabilityReference(String referencedCapability, AttributeDefinition... dependantAttributes)
      Records that this attribute's value represents a reference to an instance of a dynamic capability.

      This method is a convenience method equivalent to calling * setCapabilityReference(CapabilityReferenceRecorder) passing in a CapabilityReferenceRecorder.CompositeAttributeDependencyRecorder constructed using the parameters passed to this method.

      NOTE: This method of recording capability references is only suitable for use in attributes only used in resources that themselves expose a single capability. If your resource exposes more than single capability, you should use setCapabilityReference(RuntimeCapability, String, AttributeDefinition...) When the capability requirement is registered, the dependent capability will be that capability.

      Parameters:
      referencedCapability - the name of the dynamic capability the dynamic portion of whose name is represented by the attribute's value
      dependantAttributes - attribute from same resource that will be used to derive multiple dynamic parts for the dependant capability
      Returns:
      the builder
      See Also:
    • setCapabilityReference

      public BUILDER setCapabilityReference(RuntimeCapability capability, String referencedCapability, AttributeDefinition... dependantAttributes)
      Records that this attribute's value represents a reference to an instance of a dynamic capability.

      This method is a convenience method equivalent to calling setCapabilityReference(CapabilityReferenceRecorder) passing in a CapabilityReferenceRecorder.CompositeAttributeDependencyRecorder constructed using the parameters passed to this method.

      When the capability requirement is registered, the dependent capability will be that capability.

      Parameters:
      capability - requirement capability
      referencedCapability - the name of the dynamic capability the dynamic portion of whose name is represented by the attribute's value
      dependantAttributes - attributes on resource which will be used for registering capability reference, can be multiple.
      Returns:
      the builder
      See Also:
    • setCapabilityReference

      public BUILDER setCapabilityReference(String referencedCapability, String dependentCapability)
      Records that this attribute's value represents a reference to an instance of a dynamic capability.

      This method is a convenience method equivalent to calling setCapabilityReference(CapabilityReferenceRecorder) passing in a CapabilityReferenceRecorder.DefaultCapabilityReferenceRecorder constructed using the parameters passed to this method.

      Parameters:
      referencedCapability - the name of the dynamic capability the dynamic portion of whose name is represented by the attribute's value
      dependentCapability - the name of the capability that depends on referencedCapability
      Returns:
      the builder
      See Also:
    • setCapabilityReference

      public BUILDER setCapabilityReference(CapabilityReferenceRecorder referenceRecorder)
      Records that this attribute's value represents a reference to an instance of a dynamic capability and assigns the object that should be used to handle adding and removing capability requirements.
      Parameters:
      referenceRecorder - recorder to handle adding and removing capability requirements. May be null
      Returns:
      the builder
      See Also:
    • setUndefinedMetricValue

      public BUILDER setUndefinedMetricValue(org.jboss.dmr.ModelNode undefinedMetricValue)
      Sets a default value to use for the metric if no runtime value is available (e.g. we are a server running in admin-only mode).
      Parameters:
      undefinedMetricValue - the default value, or null if no default should be used
      Returns:
      a builder that can be used to continue building the attribute definition
    • setStability

      public BUILDER setStability(Stability stability)
      Defines the stability level of the feature enabled by this attribute.
      Parameters:
      stability - a stability level
      Returns:
      a reference to this builder
    • getName

      public String getName()
    • getType

      public org.jboss.dmr.ModelType getType()
    • getXmlName

      public String getXmlName()
    • isNillable

      public boolean isNillable()
    • isAllowExpression

      public boolean isAllowExpression()
    • getDefaultValue

      public org.jboss.dmr.ModelNode getDefaultValue()
    • getMeasurementUnit

      public MeasurementUnit getMeasurementUnit()
    • getAlternatives

      public String[] getAlternatives()
    • getRequires

      public String[] getRequires()
    • getCorrector

      public ParameterCorrector getCorrector()
    • getValidator

      public ParameterValidator getValidator()
    • getMinSize

      public int getMinSize()
    • getMaxSize

      public int getMaxSize()
    • getFlags

      public AttributeAccess.Flag[] getFlags()
    • getAttributeMarshaller

      public AttributeMarshaller getAttributeMarshaller()
    • isResourceOnly

      public boolean isResourceOnly()
    • getDeprecated

      public DeprecationData getDeprecated()
    • getAccessConstraints

      public AccessConstraintDefinition[] getAccessConstraints()
    • getNullSignificant

      public Boolean getNullSignificant()
    • getUndefinedMetricValue

      public org.jboss.dmr.ModelNode getUndefinedMetricValue()
    • getParser

      public AttributeParser getParser()
    • getAttributeGroup

      public String getAttributeGroup()
    • getAllowedValues

      public org.jboss.dmr.ModelNode[] getAllowedValues()
    • getCapabilityReferenceRecorder

      protected final CapabilityReferenceRecorder getCapabilityReferenceRecorder()
    • getStability

      public Stability getStability()