com.sonyericsson.hudson.plugins.metadata.model.definitions
Class TreeNodeMetadataDefinition

java.lang.Object
  extended by com.sonyericsson.hudson.plugins.metadata.model.definitions.AbstractMetadataDefinition
      extended by com.sonyericsson.hudson.plugins.metadata.model.definitions.TreeNodeMetadataDefinition
All Implemented Interfaces:
MetadataDefinition, Metadata<MetadataDefinition>, MetadataParent<MetadataDefinition>, hudson.model.Describable<AbstractMetadataDefinition>, Serializable

public class TreeNodeMetadataDefinition
extends AbstractMetadataDefinition
implements MetadataParent<MetadataDefinition>

A metadata definition containing other metadata definitions as children.

Author:
Tomas Westling <thomas.westling@sonyericsson.com>
See Also:
Serialized Form

Nested Class Summary
static class TreeNodeMetadataDefinition.TreeNodeMetaDataDefinitionDescriptor
          The Descriptor.
 
Nested classes/interfaces inherited from class com.sonyericsson.hudson.plugins.metadata.model.definitions.AbstractMetadataDefinition
AbstractMetadataDefinition.AbstractMetaDataDefinitionDescriptor
 
Constructor Summary
TreeNodeMetadataDefinition(String name)
          Standard constructor.
TreeNodeMetadataDefinition(String name, List<MetadataDefinition> children)
          Standard constructor.
TreeNodeMetadataDefinition(String name, String description)
          Standard Constructor.
TreeNodeMetadataDefinition(String name, String description, List<MetadataDefinition> children)
          Standard constructor.
 
Method Summary
 Collection<MetadataDefinition> addChild(MetadataDefinition definition)
          Adds the child to the list of children.
 Collection<MetadataDefinition> addChildren(Collection<MetadataDefinition> definitions)
          Adds the children to this parent's list of children.
 AbstractMetadataValue createValue(Object o)
          Creates an AbstractMetadataValue from this definition.
 MetadataDefinition 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<MetadataDefinition> getChildren()
          Getter for the children of this tree node, used by stapler to create the entire tree.
 Object getDefaultValue()
          Returns default metadata values for this definition.
 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.
 MetadataDefinition setChild(int index, MetadataDefinition 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.
 
Methods inherited from class com.sonyericsson.hudson.plugins.metadata.model.definitions.AbstractMetadataDefinition
getAll, getDescription, getDescriptor, getFullName, getFullName, getFullNameFrom, getFullPath, getName, getParent, getType, getValue, isExposedToEnvironment, setExposeToEnvironment, setParent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sonyericsson.hudson.plugins.metadata.model.MetadataParent
getFullName, getFullName, getFullNameFrom
 

Constructor Detail

TreeNodeMetadataDefinition

@DataBoundConstructor
public TreeNodeMetadataDefinition(String name,
                                                       String description,
                                                       List<MetadataDefinition> children)
Standard constructor.

Parameters:
name - the name.
description - the description.
children - the children of this node.

TreeNodeMetadataDefinition

public TreeNodeMetadataDefinition(String name)
Standard constructor.

Parameters:
name - the name.

TreeNodeMetadataDefinition

public TreeNodeMetadataDefinition(String name,
                                  String description)
Standard Constructor.

Parameters:
name - the name
description - the description.

TreeNodeMetadataDefinition

public TreeNodeMetadataDefinition(String name,
                                  List<MetadataDefinition> children)
Standard constructor.

Parameters:
name - the name.
children - the children of this node.
Method Detail

getChild

public MetadataDefinition getChild(String name)
Description copied from interface: MetadataParent
Returns the child with the given name, or null if there is none. comparison is case insensitive.

Specified by:
getChild in interface MetadataParent<MetadataDefinition>
Parameters:
name - the name to search for.
Returns:
the child.

indexOf

public int indexOf(String name)
Description copied from interface: MetadataParent
The index of the child with the provided name.

Specified by:
indexOf in interface MetadataParent<MetadataDefinition>
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

public MetadataDefinition setChild(int index,
                                   MetadataDefinition value)
Description copied from interface: MetadataParent
Sets the child on index with the provided value, replacing any object currently on that index.

Specified by:
setChild in interface MetadataParent<MetadataDefinition>
Parameters:
index - the index to set.
value - the child to set.
Returns:
the value previous at the specified index.

addChild

public Collection<MetadataDefinition> addChild(MetadataDefinition definition)
Description copied from interface: MetadataParent
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.

Specified by:
addChild in interface MetadataParent<MetadataDefinition>
Parameters:
definition - the child to add.
Returns:
null if the operation was successful.

addChildren

public Collection<MetadataDefinition> addChildren(Collection<MetadataDefinition> definitions)
Description copied from interface: MetadataParent
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.

Specified by:
addChildren in interface MetadataParent<MetadataDefinition>
Parameters:
definitions - the children to add.
Returns:
the children that failed to be added/merged or null if all succeeded.

getChildren

public Collection<MetadataDefinition> getChildren()
Getter for the children of this tree node, used by stapler to create the entire tree.

Specified by:
getChildren in interface MetadataParent<MetadataDefinition>
Returns:
the children.

getChildNames

public Collection<String> getChildNames()
Description copied from interface: MetadataParent
The child names of this parent.

Specified by:
getChildNames in interface MetadataParent<MetadataDefinition>
Returns:
the child names of this parent.

createValue

public AbstractMetadataValue createValue(Object o)
Description copied from class: AbstractMetadataDefinition
Creates an AbstractMetadataValue from this definition. Uses the input parameter Object to create the AbstractMetadataValue.

Specified by:
createValue in interface MetadataDefinition
Specified by:
createValue in class AbstractMetadataDefinition
Parameters:
o - the value to use as input for creating the AbstractMetadataValue.
Returns:
the AbstractMetadataValue.

toJson

public net.sf.json.JSON toJson()
Description copied from interface: MetadataParent
Convert this object into a JSON object.

Specified by:
toJson in interface MetadataParent<MetadataDefinition>
Returns:
the JSON version.

requiresReplacement

public boolean requiresReplacement()
Description copied from interface: MetadataParent
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.

Specified by:
requiresReplacement in interface MetadataParent<MetadataDefinition>
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)

getDefaultValue

public Object getDefaultValue()
Description copied from class: AbstractMetadataDefinition
Returns default metadata values for this definition.

Overrides:
getDefaultValue in class AbstractMetadataDefinition
Returns:
default metadata values or null if no defaults are available


Copyright © 2004-2013. All Rights Reserved.