|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sonyericsson.hudson.plugins.metadata.model.values.ParentUtil
public final class ParentUtil
Utility class for handling merge operation inside
MetadataParent
s.
Method Summary | ||
---|---|---|
static
|
addChildValue(MetadataParent<T> parent,
Collection<T> children,
T value)
Adds a value as a child to the parent. |
|
static
|
addChildValues(MetadataParent parent,
Collection<T> children,
Collection<T> values)
Adds the values as children to the parent. |
|
static
|
getChildIndex(List<T> children,
String name)
Utility method for MetadataParent.indexOf(String) }. |
|
static Collection<String> |
getChildNames(MetadataParent<MetadataValue> parent)
Gets the child names of the given parent. |
|
static
|
getChildValue(Collection<T> values,
String name)
Utility method for MetadataParent.getChild(String) . |
|
static void |
removeChild(Collection<? extends Metadata> list,
Metadata value)
Removes a child from a list of children. |
|
static void |
removeChild(MetadataParent parent,
Metadata child)
Removes a child from a parent. |
|
static
|
removeEmptyBranches(Collection<T> collection)
Removes all tree nodes without children from the collection. |
|
static void |
removeEmptyBranches(MetadataParent parent)
Removes all tree nodes without children from the parent. |
|
static void |
replaceChild(MetadataParent<MetadataValue> parent,
MetadataValue value)
Replaces an existing value amongst the parent's children. |
|
static void |
replaceChildren(MetadataParent<MetadataValue> parent,
List<MetadataValue> children)
Adds the children in a list to a parent, replacing any existing children already present. |
|
static net.sf.json.JSON |
toJson(MetadataContainer<MetadataValue> container)
Converts the container into a JSON object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static void removeChild(MetadataParent parent, Metadata child)
parent
- the parent.child
- the child to remove.public static void removeChild(Collection<? extends Metadata> list, Metadata value)
list
- the list.value
- the child to remove.public static void removeEmptyBranches(MetadataParent parent)
parent
- the parent to start with.public static <T extends Metadata> void removeEmptyBranches(Collection<T> collection)
T
- the Metadata type.collection
- the collection to remove empty trees from.public static void replaceChild(MetadataParent<MetadataValue> parent, MetadataValue value)
parent
- the parent to add/replace the child tovalue
- the value to replacepublic static void replaceChildren(MetadataParent<MetadataValue> parent, List<MetadataValue> children)
parent
- the parent to add to.children
- the children to add/replacepublic static <T extends Metadata> Collection<T> addChildValue(MetadataParent<T> parent, Collection<T> children, T value)
MetadataParent.addChild(Metadata)
T
- the type for parent, children, value and the return value.parent
- the parentchildren
- the direct list of the parents children.value
- the value to add.
public static <T extends Metadata> Collection<T> addChildValues(MetadataParent parent, Collection<T> children, Collection<T> values)
addChild(com.sonyericsson.hudson.plugins.metadata.model.Metadata)
T
- the type for parent, children, values and the return value.parent
- the parent to add the values tochildren
- the direct list of the parents children.values
- the values to add.
public static <T extends Metadata> T getChildValue(Collection<T> values, String name)
MetadataParent.getChild(String)
.
T
- the type for values, name and the return value.values
- the list of children.name
- the name to search.
public static <T extends Metadata> int getChildIndex(List<T> children, String name)
MetadataParent.indexOf(String)
}.
T
- the type for values, name and the return value.children
- the list of children.name
- the name to search.
public static net.sf.json.JSON toJson(MetadataContainer<MetadataValue> container)
MetadataValue.toJson()
because it will only convert the
children not the entire object, since a container (like
MetadataJobProperty
)
in essence doesn't have a name.
container
- the container
public static Collection<String> getChildNames(MetadataParent<MetadataValue> parent)
parent
- the parent to get the child names from.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |