public final class ModelNode extends java.lang.Object implements java.lang.Iterable<ModelNode>, java.lang.Cloneable
PolicySourceModel instance.
The model node is created via factory methods of the PolicySourceModel instance.
It may also hold AssertionData instance in case its type is ModelNode.Type.ASSERTION.| Modifier and Type | Class and Description |
|---|---|
static class |
ModelNode.Type
Policy source model node type enumeration
|
| Modifier and Type | Field and Description |
|---|---|
private java.util.LinkedList<ModelNode> |
children |
private static PolicyLogger |
LOGGER |
private AssertionData |
nodeData |
private PolicySourceModel |
parentModel |
private ModelNode |
parentNode |
private PolicyReferenceData |
referenceData |
private PolicySourceModel |
referencedModel |
private ModelNode.Type |
type |
private java.util.Collection<ModelNode> |
unmodifiableViewOnContent |
| Modifier | Constructor and Description |
|---|---|
private |
ModelNode(ModelNode.Type type,
PolicySourceModel parentModel) |
private |
ModelNode(ModelNode.Type type,
PolicySourceModel parentModel,
AssertionData data) |
private |
ModelNode(PolicySourceModel parentModel,
PolicyReferenceData data) |
| Modifier and Type | Method and Description |
|---|---|
private boolean |
addChild(ModelNode child)
Appends the specified child node to the end of the children list of this node and sets it's parent to reference
this node.
|
private void |
checkCreateChildOperationSupportForType(ModelNode.Type type) |
int |
childrenSize()
Returns the number of child policy source model nodes.
|
protected ModelNode |
clone() |
ModelNode |
createChildAllNode()
Factory method that creates new policy source model node as specified by a factory method name and input parameters.
|
ModelNode |
createChildAssertionNode()
Factory method that creates new policy source model node as specified by a factory method name and input parameters.
|
ModelNode |
createChildAssertionNode(AssertionData nodeData)
Factory method that creates new policy source model node as specified by a factory method name and input parameters.
|
ModelNode |
createChildAssertionParameterNode()
Factory method that creates new policy source model node as specified by a factory method name and input parameters.
|
(package private) ModelNode |
createChildAssertionParameterNode(AssertionData nodeData)
Factory method that creates new policy source model node as specified by a factory method name and input parameters.
|
ModelNode |
createChildExactlyOneNode()
Factory method that creates new policy source model node as specified by a factory method name and input parameters.
|
ModelNode |
createChildPolicyNode()
Factory method that creates new policy source model node as specified by a factory method name and input parameters.
|
(package private) ModelNode |
createChildPolicyReferenceNode(PolicyReferenceData referenceData)
Factory method that creates new policy source model node as specified by a factory method name and input parameters.
|
(package private) static ModelNode |
createRootPolicyNode(PolicySourceModel model)
The factory method creates and initializes the POLICY model node and sets it's parent model reference to point to
the model supplied as an input parameter.
|
boolean |
equals(java.lang.Object obj)
An
Object.equals(Object obj) method override. |
(package private) java.util.Collection<ModelNode> |
getChildren() |
AssertionData |
getNodeData()
Returns the data for this policy source model node (if any).
|
PolicySourceModel |
getParentModel()
Returns the parent policy source model that contains this model node.
|
ModelNode |
getParentNode()
Returns the parent referenced by this policy source model node.
|
(package private) PolicyReferenceData |
getPolicyReferenceData()
Returns the policy reference data for this policy source model node.
|
(package private) PolicyReferenceData |
getReferenceData() |
(package private) PolicySourceModel |
getReferencedModel() |
ModelNode.Type |
getType()
Returns the type of this policy source model node.
|
boolean |
hasChildren()
Returns true if the node has at least one child node.
|
int |
hashCode()
An
Object.hashCode() method override. |
(package private) boolean |
isDomainSpecific()
The method specifies whether the model node instance represents assertion related node, it means whether its type
is 'ASSERTION' or 'ASSERTION_PARAMETER_NODE'.
|
java.util.Iterator<ModelNode> |
iterator()
Iterates through all child nodes.
|
AssertionData |
setOrReplaceNodeData(AssertionData newData)
The method may be used to set or replace assertion data set for this node.
|
(package private) void |
setParentModel(PolicySourceModel model)
Sets the parent model reference on the node and its children.
|
(package private) void |
setReferencedModel(PolicySourceModel model) |
java.lang.String |
toString()
Returns a string representation of the object.
|
java.lang.StringBuffer |
toString(int indentLevel,
java.lang.StringBuffer buffer)
A helper method that appends indented string representation of this instance to the input string buffer.
|
private void |
updateParentModelReference(PolicySourceModel model)
The method updates the parentModel reference on current model node instance and all of it's children
|
private static final PolicyLogger LOGGER
private java.util.LinkedList<ModelNode> children
private java.util.Collection<ModelNode> unmodifiableViewOnContent
private final ModelNode.Type type
private ModelNode parentNode
private PolicySourceModel parentModel
private PolicyReferenceData referenceData
private PolicySourceModel referencedModel
private AssertionData nodeData
private ModelNode(ModelNode.Type type, PolicySourceModel parentModel)
private ModelNode(ModelNode.Type type, PolicySourceModel parentModel, AssertionData data)
private ModelNode(PolicySourceModel parentModel, PolicyReferenceData data)
static ModelNode createRootPolicyNode(PolicySourceModel model) throws java.lang.IllegalArgumentException
PolicySourceModel during
the initialization of its own internal structures.model - policy source model to be used as a parent model of the newly created ModelNode. Must not be nulljava.lang.IllegalArgumentException - if the model input parameter is nullprivate void checkCreateChildOperationSupportForType(ModelNode.Type type) throws java.lang.UnsupportedOperationException
java.lang.UnsupportedOperationExceptionpublic ModelNode createChildPolicyNode()
public ModelNode createChildAllNode()
public ModelNode createChildExactlyOneNode()
public ModelNode createChildAssertionNode()
public ModelNode createChildAssertionNode(AssertionData nodeData)
nodeData - The policy assertion data.public ModelNode createChildAssertionParameterNode()
ModelNode createChildAssertionParameterNode(AssertionData nodeData)
nodeData - The assertion parameter data.ModelNode createChildPolicyReferenceNode(PolicyReferenceData referenceData)
referenceData - The PolicyReference data.java.util.Collection<ModelNode> getChildren()
void setParentModel(PolicySourceModel model) throws java.lang.IllegalAccessException
model - new parent policy source model to be set.java.lang.IllegalAccessException - in case this node references a parent node (i.e. is not a root node of the model).private void updateParentModelReference(PolicySourceModel model)
model - new policy source model reference.public PolicySourceModel getParentModel()
public ModelNode.Type getType()
public ModelNode getParentNode()
null if the node does not have a parent currently.public AssertionData getNodeData()
null only in
case the type of this node is ASSERTION or ASSERTION_PARAMETER_NODE.null if the node does not have any data associated to it
attached.PolicyReferenceData getPolicyReferenceData()
null only in
case the type of this node is POLICY_REFERENCE.null if the node does not have any policy reference data
attached.public AssertionData setOrReplaceNodeData(AssertionData newData)
ASSERTION or ASSERTION_PARAMETER_NODE.
If used from other node types, an exception is thrown.newData - new assertion data to be set.null otherwise.java.lang.UnsupportedOperationException - in case this method is called on nodes of type other than ASSERTION
or ASSERTION_PARAMETER_NODEboolean isDomainSpecific()
AssertionData object via setOrReplaceNodeData(AssertionData) method or not.true or false according to whether the node instance represents assertion related node or not.private boolean addChild(ModelNode child)
child - node to be appended to the children list of this node.true (as per the general contract of the Collection.add method).java.lang.NullPointerException - if the specified node is null.java.lang.IllegalArgumentException - if child has a parent node set already to point to some nodevoid setReferencedModel(PolicySourceModel model)
PolicySourceModel getReferencedModel()
public int childrenSize()
Integer.MAX_VALUE children, returns Integer.MAX_VALUE.public boolean hasChildren()
public java.util.Iterator<ModelNode> iterator()
iterator in interface java.lang.Iterable<ModelNode>public boolean equals(java.lang.Object obj)
Object.equals(Object obj) method override. Method ignores the parent source model. It means that two
model nodes may be the same even if they belong to different models.
If parent model comparison is desired, it must be accomplished separately. To perform that, the reference equality
test is sufficient (nodeA.getParentModel() == nodeB.getParentModel()), since all model nodes are created
for specific model instances.equals in class java.lang.Objectpublic int hashCode()
Object.hashCode() method override.hashCode in class java.lang.Objectpublic java.lang.String toString()
toString method
returns a string that "textually represents" this object.toString in class java.lang.Objectpublic java.lang.StringBuffer toString(int indentLevel,
java.lang.StringBuffer buffer)
indentLevel - indentation level to be used.buffer - buffer to be used for appending string representation of this instanceprotected ModelNode clone() throws java.lang.CloneNotSupportedException
clone in class java.lang.Objectjava.lang.CloneNotSupportedExceptionPolicyReferenceData getReferenceData()