Package org.jboss.hal.dmr
Class ModelNodeHelper
- java.lang.Object
-
- org.jboss.hal.dmr.ModelNodeHelper
-
public class ModelNodeHelper extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <E extends Enum<E>>
StringasAttributeValue(E enumValue)The reverse operation toasEnumValue(ModelNode, String, Function, Enum).static <E extends Enum<E>>
EasEnumValue(ModelNode modelNode, String attribute, Function<String,E> valueOf, E defaultValue)Looks for the specified attribute and tries to convert it to an enum constant usingLOWER_HYPHEN.to(UPPER_UNDERSCORE, modelNode.get(attribute).asString()).static <E extends Enum<E>>
EasEnumValue(ModelNode modelNodeValue, Function<String,E> valueOf, E defaultValue)static List<NamedNode>asNamedNodes(List<Property> properties)Turns a list of properties into a list of named model nodes which contains aModelDescriptionConstants.NAMEkey with the properties name.static StringdecodeValue(String value)static StringencodeValue(String value)static booleanfailSafeBoolean(ModelNode modelNode, String path)Tries to get a deeply nested boolean value from the specified model node.static DatefailSafeDate(ModelNode modelNode, String path)static ModelNodefailSafeGet(ModelNode modelNode, String path)Tries to get a deeply nested model node from the specified model node.static List<ModelNode>failSafeList(ModelNode modelNode, String path)static List<Property>failSafePropertyList(ModelNode modelNode, String path)static ModelNodeflatToNested(ModelNode modelNode)Turns all properties which contain one or more '.' into nested model nodes.static <T> TgetOrDefault(ModelNode modelNode, String attribute, Supplier<T> supplier, T defaultValue)static voidmove(ModelNode modelNode, String source, String destination)Moves an attribute to another destination.static ModelNodeproperties(String... properties)Turns a list of properties (keys and values) into a model node.static <T extends ModelNode>
voidstoreIndex(List<T> modelNodes)
-
-
-
Method Detail
-
failSafeGet
public static ModelNode failSafeGet(ModelNode modelNode, String path)
Tries to get a deeply nested model node from the specified model node. Nested paths must be separated with "/".- Parameters:
modelNode- The model node to read frompath- A path separated with "/"- Returns:
- The nested node or an empty / undefined model node
-
failSafeBoolean
public static boolean failSafeBoolean(ModelNode modelNode, String path)
Tries to get a deeply nested boolean value from the specified model node. Nested paths must be separated with "/".- Parameters:
modelNode- The model node to read frompath- A path separated with "/"- Returns:
- the boolean value or false.
-
failSafePropertyList
public static List<Property> failSafePropertyList(ModelNode modelNode, String path)
-
getOrDefault
public static <T> T getOrDefault(ModelNode modelNode, String attribute, Supplier<T> supplier, T defaultValue)
-
asNamedNodes
public static List<NamedNode> asNamedNodes(List<Property> properties)
Turns a list of properties into a list of named model nodes which contains aModelDescriptionConstants.NAMEkey with the properties name.
-
asEnumValue
public static <E extends Enum<E>> E asEnumValue(ModelNode modelNode, String attribute, Function<String,E> valueOf, E defaultValue)
Looks for the specified attribute and tries to convert it to an enum constant usingLOWER_HYPHEN.to(UPPER_UNDERSCORE, modelNode.get(attribute).asString()).
-
asEnumValue
public static <E extends Enum<E>> E asEnumValue(ModelNode modelNodeValue, Function<String,E> valueOf, E defaultValue)
-
asAttributeValue
public static <E extends Enum<E>> String asAttributeValue(E enumValue)
The reverse operation toasEnumValue(ModelNode, String, Function, Enum).
-
move
public static void move(ModelNode modelNode, String source, String destination)
Moves an attribute to another destination. Both source and destination can be a paths.
-
properties
public static ModelNode properties(String... properties)
Turns a list of properties (keys and values) into a model node.- Parameters:
properties- A list of properties with even size.- Returns:
- a model node with the specified properties.
-
-