com.sonyericsson.hudson.plugins.metadata.model
Interface MetadataParent<T extends Metadata>

Type Parameters:
T - the type to work with, either MetadataValue or MetadataDefinition.
All Known Subinterfaces:
MetadataContainer<T>
All Known Implementing Classes:
MetadataBuildAction, MetadataJobProperty, MetadataNodeProperty, TreeNodeMetadataDefinition, TreeNodeMetadataValue

public interface MetadataParent<T extends Metadata>

The Parent node of some metadata.

Author:
Robert Sandell <robert.sandell@sonyericsson.com>

Method Summary
 Collection<T> addChild(T child)
          Adds the child to the list of children.
 Collection<T> addChildren(Collection<T> children)
          Adds the children to this parent's list of children.
 T getChild(String name)
          Returns the child with the given name, or null if there is none.
 Collection<String> getChildNames()
          The child names of this parent.
 Collection<T> getChildren()
          The children of this parent.
 String getFullName()
          The full name of the element.
 String getFullName(String separator)
          The full name of the element, using the chosen separator string.
 String getFullNameFrom(MetadataParent<T> base)
          Gives the full name from the given parent.
 int indexOf(String name)
          The index of the child with the provided name.
 boolean requiresReplacement()
          If this parent type requires to be replaced or not when a replacement command is issued.
 T setChild(int index, T value)
          Sets the child on index with the provided value, replacing any object currently on that index.
 net.sf.json.JSON toJson()
          Convert this object into a JSON object.
 

Method Detail

getChild

T getChild(String name)
Returns the child with the given name, or null if there is none. comparison is case insensitive.

Parameters:
name - the name to search for.
Returns:
the child.

addChild

Collection<T> addChild(T child)
Adds the child to the list of children. If a child with the same name is already present, the children should try to be merged. The returned child is either the child itself if it is a leaf or a clone of itself with the children that failed to be merged if it contains children, null indicates a fully successful merge/add.

Parameters:
child - the child to add.
Returns:
null if the operation was successful.

addChildren

Collection<T> addChildren(Collection<T> children)
Adds the children to this parent's list of children. If a child with the same name is already present, the children should try to be merged.

Parameters:
children - the children to add.
Returns:
the children that failed to be added/merged or null if all succeeded.

getChildren

Collection<T> getChildren()
The children of this parent.

Returns:
the children.

getChildNames

Collection<String> getChildNames()
The child names of this parent.

Returns:
the child names of this parent.

getFullName

String getFullName()
The full name of the element.

Returns:
the fullName.

getFullName

String getFullName(String separator)
The full name of the element, using the chosen separator string.

Parameters:
separator - the separator string.
Returns:
the fullName.

getFullNameFrom

String getFullNameFrom(MetadataParent<T> base)
Gives the full name from the given parent.

Parameters:
base - the parent to base the tree structure from.
Returns:
a dot separated path from the base up to this item.

toJson

net.sf.json.JSON toJson()
Convert this object into a JSON object.

Returns:
the JSON version.

requiresReplacement

boolean requiresReplacement()
If this parent type requires to be replaced or not when a replacement command is issued. I.e. If this is just a holder of children then it is not necessary, but if it contains more complex structures it might want to.

Returns:
true if it needs to be replaced by fresher instances or false if it can be reused.
See Also:
MetadataValue.replacementOf( com.sonyericsson.hudson.plugins.metadata.model.values.MetadataValue)

indexOf

int indexOf(String name)
The index of the child with the provided name.

Parameters:
name - the name of the child to find.
Returns:
the index of the child or -1 if no child with that name was found.

setChild

T setChild(int index,
           T value)
Sets the child on index with the provided value, replacing any object currently on that index.

Parameters:
index - the index to set.
value - the child to set.
Returns:
the value previous at the specified index.


Copyright © 2004-2013. All Rights Reserved.