Class ContextSearchNodeReference
- java.lang.Object
-
- com.hybris.cockpitng.core.config.impl.model.ContextSearchNodeReference
-
- All Implemented Interfaces:
ContextSearchNode
public class ContextSearchNodeReference extends java.lang.Object implements ContextSearchNode
Represents a reference to other search node.Searching for contexts is performed by traversing through context tree in regards to
merge-byattributes, obligatory merge attributes and/or appropriateCockpitConfigurationContextStrategy. Each step down the tree means that any contexts found are a little bit less relevant to actual request.During this traverse it is possible that some searches are required more then once. To avoid performing them once again, the reference may be put into tree instead.
-
-
Field Summary
-
Fields inherited from interface com.hybris.cockpitng.core.config.impl.model.ContextSearchNode
DEC_RELEVANCE_COMPARATOR, INC_RELEVANCE_COMPARATOR
-
-
Constructor Summary
Constructors Constructor Description ContextSearchNodeReference(ContextSearchNode reference)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddChild(ContextSearchNode child)Adds new child search node.booleanaddNodeResult(Context result)Adds new search result to current node.voidcommit()Marks node as committed.booleanequals(java.lang.Object o)java.util.Collection<ContextSearchNode>getChildren()Gets all child search nodes.intgetLevel()Return a level on which the node is situated - minimum number of steps needed to come from original request to this.java.util.List<Context>getNodeResult()Gets search results bound to this node.NodeRelevancegetNotEmptyRelevance()Gets highest relevance of all children with any result in regards to original requestContextSearchNodegetParent()Gets parent search node.NodeRelevancegetRelevance()Gets relevance of this node in regards to original requestjava.util.List<Context>getResult()Gets search results bound to this node and its children.ContextSearchNeedlegetSearchNeedle()Search request represented by this nodeinthashCode()booleanisCommitted()Checks if node is committed.booleanisEgalitarian()Checks how node is interpreting children results.voidremoveChild(ContextSearchNode child)Removes a child search node.voidsetEgalitarian(boolean egalitarian)Informs a node how it should interpret its children's results.voidsetParent(ContextSearchNode parent)Updates parent search node.java.lang.StringtoString()voidtoXML(java.io.OutputStream os)Writes XML representation of search node to provided stream
-
-
-
Constructor Detail
-
ContextSearchNodeReference
public ContextSearchNodeReference(ContextSearchNode reference)
- Parameters:
reference- search node to be referenced
-
-
Method Detail
-
getRelevance
public NodeRelevance getRelevance()
Description copied from interface:ContextSearchNodeGets relevance of this node in regards to original request- Specified by:
getRelevancein interfaceContextSearchNode- Returns:
- node relevance
-
getNotEmptyRelevance
public NodeRelevance getNotEmptyRelevance()
Description copied from interface:ContextSearchNodeGets highest relevance of all children with any result in regards to original request- Specified by:
getNotEmptyRelevancein interfaceContextSearchNode- Returns:
- node's relevance if any result is bound to it, highest relevance of children with result or
nullif no result is bound to this branch
-
getLevel
public int getLevel()
Description copied from interface:ContextSearchNodeReturn a level on which the node is situated - minimum number of steps needed to come from original request to this.- Specified by:
getLevelin interfaceContextSearchNode- Returns:
0for root level and 1 more for each level of relevance
-
getSearchNeedle
public ContextSearchNeedle getSearchNeedle()
Description copied from interface:ContextSearchNodeSearch request represented by this node- Specified by:
getSearchNeedlein interfaceContextSearchNode- Returns:
- search request or
nullif node is only container for other requests
-
isEgalitarian
public boolean isEgalitarian()
Description copied from interface:ContextSearchNodeChecks how node is interpreting children results. If a node is egalitarian, then result of all children are considered as a result of this node. Otherwise only a child with highest relevance is taken under consideration.- Specified by:
isEgalitarianin interfaceContextSearchNode- Returns:
trueif node is egalitarian- See Also:
ContextSearchNode.getNotEmptyRelevance(),ContextSearchNode.getResult()
-
setEgalitarian
public void setEgalitarian(boolean egalitarian)
Description copied from interface:ContextSearchNodeInforms a node how it should interpret its children's results. If a node is egalitarian, then result of all children are considered as a result of this node. Otherwise only a child with highest relevance is taken under consideration.- Specified by:
setEgalitarianin interfaceContextSearchNode- Parameters:
egalitarian-trueif node should be egalitarian
-
addNodeResult
public boolean addNodeResult(Context result)
Description copied from interface:ContextSearchNodeAdds new search result to current node.- Specified by:
addNodeResultin interfaceContextSearchNode- Parameters:
result- context that matches node's request- Returns:
trueif result has not yet been known and changed nodes result set.
-
getNodeResult
public java.util.List<Context> getNodeResult()
Description copied from interface:ContextSearchNodeGets search results bound to this node.- Specified by:
getNodeResultin interfaceContextSearchNode- Returns:
- list of contexts that matches this node's needle
-
getResult
public java.util.List<Context> getResult()
Description copied from interface:ContextSearchNodeGets search results bound to this node and its children. Result should be ordered by their relevance (from most relevant to least).- Specified by:
getResultin interfaceContextSearchNode- Returns:
- list of contexts that matches all requests in this branch
- See Also:
ContextSearchNode.isEgalitarian()
-
getParent
public ContextSearchNode getParent()
Description copied from interface:ContextSearchNodeGets parent search node.Parent node is a search needle that caused search represented by this node.
- Specified by:
getParentin interfaceContextSearchNode- Returns:
- parent search node or
nullif it is root search
-
setParent
public void setParent(ContextSearchNode parent)
Description copied from interface:ContextSearchNodeUpdates parent search node.Parent node is a search needle that caused search represented by this node.
- Specified by:
setParentin interfaceContextSearchNode- Parameters:
parent- parent search node ornullif it is root search
-
addChild
public void addChild(ContextSearchNode child)
Description copied from interface:ContextSearchNodeAdds new child search node.A child search node is a search that is related to this node and comes from its dependencies.
- Specified by:
addChildin interfaceContextSearchNode- Parameters:
child- child node
-
removeChild
public void removeChild(ContextSearchNode child)
Description copied from interface:ContextSearchNodeRemoves a child search node.A child search node is a search that is related to this node and comes from its dependencies.
- Specified by:
removeChildin interfaceContextSearchNode- Parameters:
child- child node
-
getChildren
public java.util.Collection<ContextSearchNode> getChildren()
Description copied from interface:ContextSearchNodeGets all child search nodes.A child search node is a search that is related to this node and comes from its dependencies.
- Specified by:
getChildrenin interfaceContextSearchNode- Returns:
- collection of child nodes
-
toXML
public void toXML(java.io.OutputStream os) throws java.io.IOExceptionDescription copied from interface:ContextSearchNodeWrites XML representation of search node to provided stream- Specified by:
toXMLin interfaceContextSearchNode- Parameters:
os- destination stream- Throws:
java.io.IOException- thrown, if there were problems during writing to stream
-
commit
public void commit()
Description copied from interface:ContextSearchNodeMarks node as committed.Search node should be committed after all searches bound to this node has been performed, all results has been assigned and nothing should be changed regarding this node and all its children.
Committed node becomes immutable and any action that may change it's result will result in
IllegalStateException.- Specified by:
commitin interfaceContextSearchNode
-
isCommitted
public boolean isCommitted()
Description copied from interface:ContextSearchNodeChecks if node is committed.Search node should be committed after all searches bound to this node has been performed, all results has been assigned and nothing should be changed regarding this node and all its children.
Committed node becomes immutable and any action that may change it's result will result in
IllegalStateException.- Specified by:
isCommittedin interfaceContextSearchNode- Returns:
trueif search bound to this node has been performed and finished
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-