Class ModelNode

    • Constructor Summary

      Constructors 
      Constructor Description
      ModelNode()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      ModelNode add()
      Add a node to the end of this node's value list and return it.
      ModelNode add​(boolean newValue)
      Add the given value to the end of this node's value list.
      ModelNode add​(byte[] newValue)
      Add the given value to the end of this node's value list.
      ModelNode add​(double newValue)
      Add the given value to the end of this node's value list.
      ModelNode add​(int newValue)
      Add the given value to the end of this node's value list.
      ModelNode add​(long newValue)
      Add the given value to the end of this node's value list.
      ModelNode add​(String newValue)
      Add the given value to the end of this node's value list.
      ModelNode add​(String propertyName, boolean propertyValue)
      Add a property with the given name and value to the end of this node's value list.
      ModelNode add​(String propertyName, byte[] propertyValue)
      Add a property with the given name and value to the end of this node's value list.
      ModelNode add​(String propertyName, double propertyValue)
      Add a property with the given name and value to the end of this node's value list.
      ModelNode add​(String propertyName, int propertyValue)
      Add a property with the given name and value to the end of this node's value list.
      ModelNode add​(String propertyName, long propertyValue)
      Add a property with the given name and value to the end of this node's value list.
      ModelNode add​(String propertyName, String propertyValue)
      Add a property with the given name and value to the end of this node's value list.
      ModelNode add​(String propertyName, BigDecimal propertyValue)
      Add a property with the given name and value to the end of this node's value list.
      ModelNode add​(String propertyName, BigInteger propertyValue)
      Add a property with the given name and value to the end of this node's value list.
      ModelNode add​(String propertyName, ModelNode propertyValue)
      Add a property with the given name and value to the end of this node's value list.
      ModelNode add​(BigDecimal newValue)
      Add the given value to the end of this node's value list.
      ModelNode add​(BigInteger newValue)
      Add the given value to the end of this node's value list.
      ModelNode add​(ModelNode newValue)
      Add a copy of the given value to the end of this node's value list.
      ModelNode addEmptyList()
      Add a node of type ModelType.LIST to the end of this node's value list and return it.
      ModelNode addEmptyObject()
      Add a node of type ModelType.OBJECT to the end of this node's value list and return it.
      ModelNode addExpression​(String newValue)
      Add the given expression to the end of this node's value list.
      Object as​(ModelType type)
      Get the value of this node as type.
      BigDecimal asBigDecimal()
      Get the value of this node as a BigDecimal.
      BigInteger asBigInteger()
      Get the value of this node as a BigInteger.
      boolean asBoolean()
      Get the value of this node as a boolean.
      boolean asBoolean​(boolean defVal)
      Get the value of this node as a boolean.
      byte[] asBytes()
      Get the value of this node as a byte array.
      double asDouble()
      Get the value of this node as a double.
      double asDouble​(double defVal)
      Get the value of this node as an double.
      int asInt()
      Get the value of this node as number.
      int asInt​(int defVal)
      Get the value of this node as number.
      List<ModelNode> asList()
      Get the list of entries contained in this object.
      long asLong()
      Get the value of this node as a long.
      long asLong​(long defVal)
      Get the value of this node as a long.
      ModelNode asObject()
      Get a copy of this value as an object.
      Property asProperty()
      Get the value of this node as a property.
      List<Property> asPropertyList()
      Get the value of this node as a property list.
      String asString()
      Get the value as a string.
      ModelType asType()
      Get the value of this node as a type, expressed using the ModelType enum.
      ModelNode clear()
      Clear this node's value and change its type to undefined.
      ModelNode clone()
      Clone this model node.
      boolean equals​(Object other)
      Determine whether this object is equal to another.
      boolean equals​(ModelNode other)
      Determine whether this object is equal to another.
      static ModelNode fromBase64​(String encoded)
      Creates a new node from a base64 encoded string
      ModelNode get​(int index)
      Get the child of this node with the given index.
      ModelNode get​(String name)
      Get the child of this node with the given name.
      ModelNode get​(String... names)
      Recursively get the children of this node with the given names.
      String getFailureDescription()  
      ModelType getType()
      Get the current type of this node.
      boolean has​(int index)
      Determine whether this node has a child with the given index.
      boolean has​(String key)
      Determine whether this node has a child with the given name.
      boolean hasDefined​(int index)
      Determine whether this node has a defined child with the given index.
      boolean hasDefined​(String key)
      Determine whether this node has a defined child with the given name.
      int hashCode()
      Get the hash code of this node object.
      boolean isDefined()
      Determine whether this node is defined.
      boolean isFailure()  
      Set<String> keys()
      Get the set of keys contained in this object.
      void protect()
      Prevent further modifications to this node and its sub-nodes.
      ModelNode remove​(String name)
      Remove a child of this node, returning the child.
      ModelNode require​(int index)
      Require the existence of a child of this node with the given index, returning the child.
      ModelNode require​(String name)
      Require the existence of a child of this node with the given name, returning the child.
      ModelNode resolve()
      Return a copy of this model node, with all system property expressions locally resolved.
      ModelNode set​(boolean newValue)
      Change this node's value to the given value.
      ModelNode set​(byte[] newValue)
      Change this node's value to the given value.
      ModelNode set​(double newValue)
      Change this node's value to the given value.
      ModelNode set​(int newValue)
      Change this node's value to the given value.
      ModelNode set​(long newValue)
      Change this node's value to the given value.
      ModelNode set​(String newValue)
      Change this node's value to the given value.
      ModelNode set​(String propertyName, boolean propertyValue)
      Change this node's value to a property with the given name and value.
      ModelNode set​(String propertyName, byte[] propertyValue)
      Change this node's value to a property with the given name and value.
      ModelNode set​(String propertyName, double propertyValue)
      Change this node's value to a property with the given name and value.
      ModelNode set​(String propertyName, int propertyValue)
      Change this node's value to a property with the given name and value.
      ModelNode set​(String propertyName, long propertyValue)
      Change this node's value to a property with the given name and value.
      ModelNode set​(String propertyName, String propertyValue)
      Change this node's value to a property with the given name and value.
      ModelNode set​(String propertyName, BigDecimal propertyValue)
      Change this node's value to a property with the given name and value.
      ModelNode set​(String propertyName, BigInteger propertyValue)
      Change this node's value to a property with the given name and value.
      ModelNode set​(String propertyName, ModelNode propertyValue)
      Change this node's value to a property with the given name and value.
      ModelNode set​(String propertyName, ModelType propertyValue)
      Change this node's value to a property with the given name and value.
      ModelNode set​(BigDecimal newValue)
      Change this node's value to the given value.
      ModelNode set​(BigInteger newValue)
      Change this node's value to the given value.
      ModelNode set​(Collection<ModelNode> newValue)
      Change this node's value to a list whose values are copied from the given collection.
      ModelNode set​(ModelNode newValue)
      Change this node's value to the given value.
      ModelNode set​(ModelType newValue)
      Change this node's value to the given value.
      ModelNode set​(ModelType type, Object propValue)  
      ModelNode set​(Property newValue)
      Change this node's value to the given value.
      ModelNode setEmptyList()
      Change this node's value to an empty list.
      ModelNode setEmptyObject()
      Change this node's value to an empty object.
      ModelNode setExpression​(String newValue)
      Change this node's value to the given expression value.
      ModelNode setExpression​(String propertyName, String propertyValue)
      Change this node's value to a property with the given name and expression value.
      String toBase64String()  
      String toJSONString()  
      String toJSONString​(boolean compact)
      Get a JSON string representation of this model node, formatted nicely, if requested.
      String toString()
      Get a human-readable string representation of this model node, formatted nicely (possibly on multiple lines).
      void writeExternal​(org.jboss.hal.dmr.DataOutput out)
      Write this node's content in binary format to the given target.
    • Constructor Detail

      • ModelNode

        public ModelNode()
    • Method Detail

      • fromBase64

        public static ModelNode fromBase64​(String encoded)
        Creates a new node from a base64 encoded string
        Parameters:
        encoded - The base64 encoded string.
        Returns:
        the new model node
      • protect

        public void protect()
        Prevent further modifications to this node and its sub-nodes. Note that copies of this node made after this method call will not be protected.
      • asLong

        public long asLong()
                    throws IllegalArgumentException
        Get the value of this node as a long. Collection types will return the size of the collection for this value. Other types may attempt a string conversion.
        Returns:
        the long value
        Throws:
        IllegalArgumentException - if no conversion is possible
      • asLong

        public long asLong​(long defVal)
        Get the value of this node as a long. Collection types will return the size of the collection for this value. Other types may attempt a string conversion.
        Parameters:
        defVal - the default value if no conversion is possible
        Returns:
        the long value
      • asInt

        public int asInt()
                  throws IllegalArgumentException
        Get the value of this node as number. Collection types will return the size of the collection for this value. Other types may attempt a string conversion.
        Returns:
        the numeric value
        Throws:
        IllegalArgumentException - if no conversion is possible
      • asInt

        public int asInt​(int defVal)
        Get the value of this node as number. Collection types will return the size of the collection for this value. Other types may attempt a string conversion.
        Parameters:
        defVal - the default value if no conversion is possible
        Returns:
        the int value
      • asBoolean

        public boolean asBoolean()
                          throws IllegalArgumentException
        Get the value of this node as a boolean. Collection types return true for non-empty collections. Numerical types return true for non-zero values.
        Returns:
        the boolean value
        Throws:
        IllegalArgumentException - if no conversion is possible
      • asBoolean

        public boolean asBoolean​(boolean defVal)
        Get the value of this node as a boolean. Collection types return true for non-empty collections. Numerical types return true for non-zero values.
        Parameters:
        defVal - the default value if no conversion is possible
        Returns:
        the boolean value
      • asString

        public String asString()
        Get the value as a string. This is the literal value of this model node. More than one node type may yield the same value for this method.
        Returns:
        the string value
      • asDouble

        public double asDouble()
                        throws IllegalArgumentException
        Get the value of this node as a double. Collection types will return the size of the collection for this value. Other types may attempt a string conversion.
        Returns:
        the double value
        Throws:
        IllegalArgumentException - if no conversion is possible
      • asDouble

        public double asDouble​(double defVal)
        Get the value of this node as an double. Collection types will return the size of the collection for this value. Other types may attempt a string conversion.
        Parameters:
        defVal - the default value if no conversion is possible
        Returns:
        the int value
      • asType

        public ModelType asType()
                         throws IllegalArgumentException
        Get the value of this node as a type, expressed using the ModelType enum. The string value of this node must be convertible to a type.
        Returns:
        the ModelType value
        Throws:
        IllegalArgumentException - if no conversion is possible
      • asBigDecimal

        public BigDecimal asBigDecimal()
                                throws IllegalArgumentException
        Get the value of this node as a BigDecimal. Collection types will return the size of the collection for this value. Other types may attempt a string conversion.
        Returns:
        the BigDecimal value
        Throws:
        IllegalArgumentException - if no conversion is possible
      • asBigInteger

        public BigInteger asBigInteger()
                                throws IllegalArgumentException
        Get the value of this node as a BigInteger. Collection types will return the size of the collection for this value. Other types may attempt a string conversion.
        Returns:
        the BigInteger value
        Throws:
        IllegalArgumentException - if no conversion is possible
      • asBytes

        public byte[] asBytes()
                       throws IllegalArgumentException
        Get the value of this node as a byte array. Strings and string-like values will return the UTF-8 encoding of the string. Numerical values will return the byte representation of the number.
        Returns:
        the bytes
        Throws:
        IllegalArgumentException - if no conversion is possible
      • asProperty

        public Property asProperty()
                            throws IllegalArgumentException
        Get the value of this node as a property. Object values will return a property if there is exactly one property in the object. List values will return a property if there are exactly two items in the list, and if the first is convertible to a string.
        Returns:
        the property value
        Throws:
        IllegalArgumentException - if no conversion is possible
      • asPropertyList

        public List<Property> asPropertyList()
                                      throws IllegalArgumentException
        Get the value of this node as a property list. Object values will return a list of properties representing each key-value pair in the object. List values will return all the values of the list, failing if any of the values are not convertible to a property value.
        Returns:
        the property list value
        Throws:
        IllegalArgumentException - if no conversion is possible
      • asObject

        public ModelNode asObject()
                           throws IllegalArgumentException
        Get a copy of this value as an object. Object values will simply copy themselves.

        Property values will return a single-entry object whose key and value are copied from the property key and value.

        List values will attempt to interpolate the list into an object by iterating each item, mapping each property into an object entry and otherwise taking pairs of list entries, converting the first to a string, and using the pair of entries as a single object entry. If an object key appears more than once in the source object, the last key takes precedence.

        Returns:
        the object value
        Throws:
        IllegalArgumentException - if no conversion is possible
      • as

        public Object as​(ModelType type)
        Get the value of this node as type. This method simply delegates to the various asXXX() methods depending on the specified type.
        Returns:
        the value as type or null if the type is ModelType.UNDEFINED
        Throws:
        IllegalArgumentException - if no conversion is possible
      • isDefined

        public boolean isDefined()
        Determine whether this node is defined.
        Returns:
        true if this node's value is defined, false otherwise
      • set

        public ModelNode set​(int newValue)
        Change this node's value to the given value.
        Parameters:
        newValue - the new value
        Returns:
        this node
      • set

        public ModelNode set​(long newValue)
        Change this node's value to the given value.
        Parameters:
        newValue - the new value
        Returns:
        this node
      • set

        public ModelNode set​(double newValue)
        Change this node's value to the given value.
        Parameters:
        newValue - the new value
        Returns:
        this node
      • set

        public ModelNode set​(boolean newValue)
        Change this node's value to the given value.
        Parameters:
        newValue - the new value
        Returns:
        this node
      • setExpression

        public ModelNode setExpression​(String newValue)
        Change this node's value to the given expression value.
        Parameters:
        newValue - the new value
        Returns:
        this node
      • set

        public ModelNode set​(String newValue)
        Change this node's value to the given value.
        Parameters:
        newValue - the new value
        Returns:
        this node
      • set

        public ModelNode set​(BigDecimal newValue)
        Change this node's value to the given value.
        Parameters:
        newValue - the new value
        Returns:
        this node
      • set

        public ModelNode set​(BigInteger newValue)
        Change this node's value to the given value.
        Parameters:
        newValue - the new value
        Returns:
        this node
      • set

        public ModelNode set​(ModelNode newValue)
        Change this node's value to the given value. The value is copied from the parameter.
        Parameters:
        newValue - the new value
        Returns:
        this node
      • set

        public ModelNode set​(byte[] newValue)
        Change this node's value to the given value.
        Parameters:
        newValue - the new value
        Returns:
        this node
      • set

        public ModelNode set​(ModelType newValue)
        Change this node's value to the given value.
        Parameters:
        newValue - the new value
        Returns:
        this node
      • set

        public ModelNode set​(Property newValue)
        Change this node's value to the given value.
        Parameters:
        newValue - the new value
        Returns:
        this node
      • set

        public ModelNode set​(String propertyName,
                             ModelNode propertyValue)
        Change this node's value to a property with the given name and value.
        Parameters:
        propertyName - the property name
        propertyValue - the property value
        Returns:
        this node
      • set

        public ModelNode set​(String propertyName,
                             int propertyValue)
        Change this node's value to a property with the given name and value.
        Parameters:
        propertyName - the property name
        propertyValue - the property value
        Returns:
        this node
      • set

        public ModelNode set​(String propertyName,
                             long propertyValue)
        Change this node's value to a property with the given name and value.
        Parameters:
        propertyName - the property name
        propertyValue - the property value
        Returns:
        this node
      • set

        public ModelNode set​(String propertyName,
                             double propertyValue)
        Change this node's value to a property with the given name and value.
        Parameters:
        propertyName - the property name
        propertyValue - the property value
        Returns:
        this node
      • set

        public ModelNode set​(String propertyName,
                             boolean propertyValue)
        Change this node's value to a property with the given name and value.
        Parameters:
        propertyName - the property name
        propertyValue - the property value
        Returns:
        this node
      • set

        public ModelNode set​(String propertyName,
                             String propertyValue)
        Change this node's value to a property with the given name and value.
        Parameters:
        propertyName - the property name
        propertyValue - the property value
        Returns:
        this node
      • setExpression

        public ModelNode setExpression​(String propertyName,
                                       String propertyValue)
        Change this node's value to a property with the given name and expression value.
        Parameters:
        propertyName - the property name
        propertyValue - the property expression value
        Returns:
        this node
      • set

        public ModelNode set​(String propertyName,
                             BigDecimal propertyValue)
        Change this node's value to a property with the given name and value.
        Parameters:
        propertyName - the property name
        propertyValue - the property value
        Returns:
        this node
      • set

        public ModelNode set​(String propertyName,
                             BigInteger propertyValue)
        Change this node's value to a property with the given name and value.
        Parameters:
        propertyName - the property name
        propertyValue - the property value
        Returns:
        this node
      • set

        public ModelNode set​(String propertyName,
                             byte[] propertyValue)
        Change this node's value to a property with the given name and value.
        Parameters:
        propertyName - the property name
        propertyValue - the property value
        Returns:
        this node
      • set

        public ModelNode set​(String propertyName,
                             ModelType propertyValue)
        Change this node's value to a property with the given name and value.
        Parameters:
        propertyName - the property name
        propertyValue - the property value
        Returns:
        this node
      • set

        public ModelNode set​(Collection<ModelNode> newValue)
        Change this node's value to a list whose values are copied from the given collection.
        Parameters:
        newValue - the list value
        Returns:
        this node
      • setEmptyList

        public ModelNode setEmptyList()
        Change this node's value to an empty list.
        Returns:
        this node
      • setEmptyObject

        public ModelNode setEmptyObject()
        Change this node's value to an empty object.
        Returns:
        this node
      • clear

        public ModelNode clear()
        Clear this node's value and change its type to undefined.
        Returns:
        this node
      • get

        public ModelNode get​(String name)
        Get the child of this node with the given name. If no such child exists, create it. If the node is undefined, it will be initialized to be of type object.

        When called on property values, the name must match the property name.

        Parameters:
        name - the child name
        Returns:
        the child
        Throws:
        IllegalArgumentException - if this node does not support getting a child with the given name
      • require

        public ModelNode require​(String name)
                          throws NoSuchElementException
        Require the existence of a child of this node with the given name, returning the child. If no such child exists, an exception is thrown.

        When called on property values, the name must match the property name.

        Parameters:
        name - the child name
        Returns:
        the child
        Throws:
        NoSuchElementException - if the element does not exist
      • remove

        public ModelNode remove​(String name)
                         throws NoSuchElementException
        Remove a child of this node, returning the child. If no such child exists, an exception is thrown.

        When called on property values, the name must match the property name.

        Parameters:
        name - the child name
        Returns:
        the child
        Throws:
        NoSuchElementException - if the element does not exist
      • get

        public ModelNode get​(int index)
        Get the child of this node with the given index. If no such child exists, create it (adding list entries as needed). If the node is undefined, it will be initialized to be of type ModelType.LIST.

        When called on property values, the index must be zero.

        Parameters:
        index - the child index
        Returns:
        the child
        Throws:
        IllegalArgumentException - if this node does not support getting a child with the given index
      • require

        public ModelNode require​(int index)
        Require the existence of a child of this node with the given index, returning the child. If no such child exists, an exception is thrown.

        When called on property values, the index must be zero.

        Parameters:
        index - the child index
        Returns:
        the child
        Throws:
        NoSuchElementException - if the element does not exist
      • add

        public ModelNode add​(int newValue)
        Add the given value to the end of this node's value list. If the node is undefined, it will be initialized to be of type ModelType.LIST.
        Parameters:
        newValue - the new value to add
        Returns:
        this node
      • add

        public ModelNode add​(long newValue)
        Add the given value to the end of this node's value list. If the node is undefined, it will be initialized to be of type ModelType.LIST.
        Parameters:
        newValue - the new value to add
        Returns:
        this node
      • add

        public ModelNode add​(double newValue)
        Add the given value to the end of this node's value list. If the node is undefined, it will be initialized to be of type ModelType.LIST.
        Parameters:
        newValue - the new value to add
        Returns:
        this node
      • add

        public ModelNode add​(boolean newValue)
        Add the given value to the end of this node's value list. If the node is undefined, it will be initialized to be of type ModelType.LIST.
        Parameters:
        newValue - the new value to add
        Returns:
        this node
      • addExpression

        public ModelNode addExpression​(String newValue)
        Add the given expression to the end of this node's value list. If the node is undefined, it will be initialized to be of type ModelType.LIST.
        Parameters:
        newValue - the new value to add
        Returns:
        this node
      • add

        public ModelNode add​(String newValue)
        Add the given value to the end of this node's value list. If the node is undefined, it will be initialized to be of type ModelType.LIST.
        Parameters:
        newValue - the new value to add
        Returns:
        this node
      • add

        public ModelNode add​(BigDecimal newValue)
        Add the given value to the end of this node's value list. If the node is undefined, it will be initialized to be of type ModelType.LIST.
        Parameters:
        newValue - the new value to add
        Returns:
        this node
      • add

        public ModelNode add​(BigInteger newValue)
        Add the given value to the end of this node's value list. If the node is undefined, it will be initialized to be of type ModelType.LIST.
        Parameters:
        newValue - the new value to add
        Returns:
        this node
      • add

        public ModelNode add​(ModelNode newValue)
        Add a copy of the given value to the end of this node's value list. If the node is undefined, it will be initialized to be of type ModelType.LIST.
        Parameters:
        newValue - the new value to add
        Returns:
        this node
      • add

        public ModelNode add​(byte[] newValue)
        Add the given value to the end of this node's value list. If the node is undefined, it will be initialized to be of type ModelType.LIST.
        Parameters:
        newValue - the new value to add
        Returns:
        this node
      • add

        public ModelNode add​(String propertyName,
                             int propertyValue)
        Add a property with the given name and value to the end of this node's value list. If the node is undefined, it will be initialized to be of type ModelType.LIST.
        Parameters:
        propertyName - the property name
        propertyValue - the property value
        Returns:
        this node
      • add

        public ModelNode add​(String propertyName,
                             long propertyValue)
        Add a property with the given name and value to the end of this node's value list. If the node is undefined, it will be initialized to be of type ModelType.LIST.
        Parameters:
        propertyName - the property name
        propertyValue - the property value
        Returns:
        this node
      • add

        public ModelNode add​(String propertyName,
                             double propertyValue)
        Add a property with the given name and value to the end of this node's value list. If the node is undefined, it will be initialized to be of type ModelType.LIST.
        Parameters:
        propertyName - the property name
        propertyValue - the property value
        Returns:
        this node
      • add

        public ModelNode add​(String propertyName,
                             boolean propertyValue)
        Add a property with the given name and value to the end of this node's value list. If the node is undefined, it will be initialized to be of type ModelType.LIST.
        Parameters:
        propertyName - the property name
        propertyValue - the property value
        Returns:
        this node
      • add

        public ModelNode add​(String propertyName,
                             String propertyValue)
        Add a property with the given name and value to the end of this node's value list. If the node is undefined, it will be initialized to be of type ModelType.LIST.
        Parameters:
        propertyName - the property name
        propertyValue - the property value
        Returns:
        this node
      • add

        public ModelNode add​(String propertyName,
                             BigDecimal propertyValue)
        Add a property with the given name and value to the end of this node's value list. If the node is undefined, it will be initialized to be of type ModelType.LIST.
        Parameters:
        propertyName - the property name
        propertyValue - the property value
        Returns:
        this node
      • add

        public ModelNode add​(String propertyName,
                             BigInteger propertyValue)
        Add a property with the given name and value to the end of this node's value list. If the node is undefined, it will be initialized to be of type ModelType.LIST.
        Parameters:
        propertyName - the property name
        propertyValue - the property value
        Returns:
        this node
      • add

        public ModelNode add​(String propertyName,
                             ModelNode propertyValue)
        Add a property with the given name and value to the end of this node's value list. If the node is undefined, it will be initialized to be of type ModelType.LIST.
        Parameters:
        propertyName - the property name
        propertyValue - the property value
        Returns:
        this node
      • add

        public ModelNode add​(String propertyName,
                             byte[] propertyValue)
        Add a property with the given name and value to the end of this node's value list. If the node is undefined, it will be initialized to be of type ModelType.LIST.
        Parameters:
        propertyName - the property name
        propertyValue - the property value
        Returns:
        this node
      • add

        public ModelNode add()
        Add a node to the end of this node's value list and return it. If the node is undefined, it will be initialized to be of type list.
        Returns:
        the new node
      • addEmptyList

        public ModelNode addEmptyList()
        Add a node of type ModelType.LIST to the end of this node's value list and return it. If this node is undefined, it will be initialized to be of type ModelType.LIST.
        Returns:
        the new node
      • addEmptyObject

        public ModelNode addEmptyObject()
        Add a node of type ModelType.OBJECT to the end of this node's value list and return it. If this node is undefined, it will be initialized to be of type ModelType.LIST.
        Returns:
        the new node
      • has

        public boolean has​(int index)
        Determine whether this node has a child with the given index. Property node types always contain exactly one value.
        Parameters:
        index - the index
        Returns:
        true if there is a (possibly undefined) node at the given index
      • has

        public boolean has​(String key)
        Determine whether this node has a child with the given name. Property node types always contain exactly one value with a key equal to the property name.
        Parameters:
        key - the name
        Returns:
        true if there is a (possibly undefined) node at the given key
      • hasDefined

        public boolean hasDefined​(int index)
        Determine whether this node has a defined child with the given index. Property node types always contain exactly one value.
        Parameters:
        index - the index
        Returns:
        true if there is a node at the given index and its type is not ModelType.UNDEFINED
      • hasDefined

        public boolean hasDefined​(String key)
        Determine whether this node has a defined child with the given name. Property node types always contain exactly one value with a key equal to the property name.
        Parameters:
        key - the name
        Returns:
        true if there is a node at the given index and its type is not undefined
      • keys

        public Set<String> keys()
        Get the set of keys contained in this object. Property node types always contain exactly one value with a key equal to the property name. Other non-object types will return an empty set.
        Returns:
        the key set
      • asList

        public List<ModelNode> asList()
        Get the list of entries contained in this object. Property node types always contain exactly one entry (itself). Lists will return an unmodifiable view of their contained list. Objects will return a list of properties corresponding to the mappings within the object. Other types will return an empty list.
        Returns:
        the entry list
      • get

        public ModelNode get​(String... names)
        Recursively get the children of this node with the given names. If any child along the path does not exist, create it. If any node is the path is undefined, it will be initialized to be of type ModelType.OBJECT.
        Parameters:
        names - the child names
        Returns:
        the child
        Throws:
        IllegalArgumentException - if a node does not support getting a child with the given name path
      • toString

        public String toString()
        Get a human-readable string representation of this model node, formatted nicely (possibly on multiple lines).
        Overrides:
        toString in class Object
        Returns:
        the string representation
      • toJSONString

        public String toJSONString​(boolean compact)
        Get a JSON string representation of this model node, formatted nicely, if requested.
        Parameters:
        compact - Flag that indicates whether or not the string should be all on one line (i.e. true) or should be printed on multiple lines (false).
        Returns:
        The JSON string.
      • toJSONString

        public String toJSONString()
      • toBase64String

        public String toBase64String()
      • resolve

        public ModelNode resolve()
        Return a copy of this model node, with all system property expressions locally resolved. The caller must have permission to access all of the system properties named in the node tree.
        Returns:
        the resolved copy
      • equals

        public boolean equals​(Object other)
        Determine whether this object is equal to another.
        Overrides:
        equals in class Object
        Parameters:
        other - the other object
        Returns:
        true if they are equal, false otherwise
      • equals

        public boolean equals​(ModelNode other)
        Determine whether this object is equal to another.
        Parameters:
        other - the other object
        Returns:
        true if they are equal, false otherwise
      • hashCode

        public int hashCode()
        Get the hash code of this node object. Note that unless the value is protect()ed, the hash code may change over time, thus making unprotected nodes unsuitable for use as hash table keys.
        Overrides:
        hashCode in class Object
        Returns:
        the hash code
      • clone

        public ModelNode clone()
        Clone this model node.
        Returns:
        the clone
      • getType

        public ModelType getType()
        Get the current type of this node.
        Returns:
        the node type
      • writeExternal

        public void writeExternal​(org.jboss.hal.dmr.DataOutput out)
        Write this node's content in binary format to the given target.
        Parameters:
        out - the target to which the content should be written
      • isFailure

        public boolean isFailure()
        Returns:
        true if this node has an outcome and the outcome does not equal "success"
      • getFailureDescription

        public String getFailureDescription()
        Returns:
        the failure description or "No failure-description provided"