Class AbstractNode
- java.lang.Object
-
- java.util.AbstractMap<K,V>
-
- java.util.HashMap<K,V>
-
- java.util.LinkedHashMap<String,Object>
-
- com.composum.sling.core.pckgmgr.regpckg.tree.AbstractNode
-
- All Implemented Interfaces:
RegistryItem
,Serializable
,Cloneable
,Map<String,Object>
- Direct Known Subclasses:
GroupNode
,PackageNode
,RegistryNode
,RegistryTree
,VersionNode
public abstract class AbstractNode extends LinkedHashMap<String,Object> implements RegistryItem
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class java.util.AbstractMap
AbstractMap.SimpleEntry<K extends Object,V extends Object>, AbstractMap.SimpleImmutableEntry<K extends Object,V extends Object>
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractNode(RegistryItem parent)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
combineChildren(GroupNode otherNode)
WithincompactSubTree()
: we add the children of the otherNode (which has the same name) to our children, so that the otherNode can be removed.void
compactSubTree()
We clear up the rare case that there are two items with the sameTreeItem.getName()
(can happen if there is, e.g., a group that has the same name as a package), which would lead to trouble with tree display since the same id was used twice.RegistryItem
compactTree()
CallsRegistryItem.compactSubTree()
(see there for the why) on theRegistryItem.getParent()
, since the compaction might join same named siblings and replace this node for it to have all children.boolean
equals(Object other)
RegistryItem
getItem(String name)
Iterable<RegistryItem>
getItems()
protected Map<String,RegistryItem>
getItemsMap()
String
getName()
RegistryItem
getParent()
String
getPath()
String
getText()
String
getType()
int
hashCode()
boolean
isLoaded()
protected void
setLoaded(boolean loaded)
void
toJson(com.google.gson.stream.JsonWriter writer)
void
toTree(com.google.gson.stream.JsonWriter writer, boolean children, boolean showRoot)
protected void
toTreeChildren(com.google.gson.stream.JsonWriter writer)
protected void
toTreeProperties(com.google.gson.stream.JsonWriter writer)
protected void
toTreeState(com.google.gson.stream.JsonWriter writer)
-
Methods inherited from class java.util.LinkedHashMap
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, removeEldestEntry, replaceAll, values
-
Methods inherited from class java.util.HashMap
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
-
Methods inherited from class java.util.AbstractMap
toString
-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Map
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, forEach, get, getOrDefault, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
-
Methods inherited from interface com.composum.sling.core.pckgmgr.regpckg.tree.RegistryItem
load, loadForItems
-
-
-
-
Field Detail
-
KEY_NAME
public static final String KEY_NAME
- See Also:
- Constant Field Values
-
KEY_PATH
public static final String KEY_PATH
- See Also:
- Constant Field Values
-
KEY_TEXT
public static final String KEY_TEXT
- See Also:
- Constant Field Values
-
KEY_TYPE
public static final String KEY_TYPE
- See Also:
- Constant Field Values
-
KEY_STATE
public static final String KEY_STATE
- See Also:
- Constant Field Values
-
KEY_LOADED
public static final String KEY_LOADED
- See Also:
- Constant Field Values
-
KEY_ITEMS
public static final String KEY_ITEMS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractNode
protected AbstractNode(RegistryItem parent)
-
-
Method Detail
-
getParent
@Nullable public RegistryItem getParent()
- Specified by:
getParent
in interfaceRegistryItem
-
isLoaded
public boolean isLoaded()
- Specified by:
isLoaded
in interfaceRegistryItem
-
setLoaded
protected void setLoaded(boolean loaded)
-
getItems
@Nonnull public Iterable<RegistryItem> getItems()
- Specified by:
getItems
in interfaceRegistryItem
-
getItem
@Nullable public RegistryItem getItem(@Nonnull String name)
- Specified by:
getItem
in interfaceRegistryItem
-
getItemsMap
@Nullable protected Map<String,RegistryItem> getItemsMap()
-
getName
public String getName()
- Specified by:
getName
in interfaceRegistryItem
-
getPath
public String getPath()
- Specified by:
getPath
in interfaceRegistryItem
-
getText
public String getText()
- Specified by:
getText
in interfaceRegistryItem
-
getType
public String getType()
- Specified by:
getType
in interfaceRegistryItem
-
toTree
public void toTree(@Nonnull com.google.gson.stream.JsonWriter writer, boolean children, boolean showRoot) throws IOException
- Specified by:
toTree
in interfaceRegistryItem
- Throws:
IOException
-
toTreeChildren
protected void toTreeChildren(@Nonnull com.google.gson.stream.JsonWriter writer) throws IOException
- Throws:
IOException
-
toTreeProperties
protected void toTreeProperties(@Nonnull com.google.gson.stream.JsonWriter writer) throws IOException
- Throws:
IOException
-
toTreeState
protected void toTreeState(@Nonnull com.google.gson.stream.JsonWriter writer) throws IOException
- Throws:
IOException
-
toJson
public void toJson(@Nonnull com.google.gson.stream.JsonWriter writer) throws IOException
- Specified by:
toJson
in interfaceRegistryItem
- Throws:
IOException
-
compactSubTree
public void compactSubTree()
We clear up the rare case that there are two items with the sameTreeItem.getName()
(can happen if there is, e.g., a group that has the same name as a package), which would lead to trouble with tree display since the same id was used twice. We take what's more specific (that is, not GroupNode) and add the children there.- Specified by:
compactSubTree
in interfaceRegistryItem
-
combineChildren
protected void combineChildren(GroupNode otherNode)
WithincompactSubTree()
: we add the children of the otherNode (which has the same name) to our children, so that the otherNode can be removed.
-
compactTree
public RegistryItem compactTree()
Description copied from interface:RegistryItem
CallsRegistryItem.compactSubTree()
(see there for the why) on theRegistryItem.getParent()
, since the compaction might join same named siblings and replace this node for it to have all children.- Specified by:
compactTree
in interfaceRegistryItem
- Returns:
- the new node to use instead of this one (might or might not be the same instance)
-
equals
public boolean equals(Object other)
-
-