com.sonyericsson.hudson.plugins.metadata.model.values
Class TreeNodeMetadataValue

java.lang.Object
  extended by com.sonyericsson.hudson.plugins.metadata.model.values.AbstractMetadataValue
      extended by com.sonyericsson.hudson.plugins.metadata.model.values.TreeNodeMetadataValue
All Implemented Interfaces:
Metadata<MetadataValue>, MetadataParent<MetadataValue>, MetadataValue, hudson.model.Describable<AbstractMetadataValue>, Serializable, Cloneable, Comparable<Object>

public class TreeNodeMetadataValue
extends AbstractMetadataValue
implements MetadataParent<MetadataValue>, Cloneable

Meta data containing other meta data values. Used to create tree structures of data.

Author:
Robert Sandell <robert.sandell@sonyericsson.com>
See Also:
Serialized Form

Nested Class Summary
static class TreeNodeMetadataValue.TreeNodeMetaDataValueDescriptor
          Descriptor for TreeNodeMetadataValues.
 
Nested classes/interfaces inherited from class com.sonyericsson.hudson.plugins.metadata.model.values.AbstractMetadataValue
AbstractMetadataValue.AbstractMetaDataValueDescriptor
 
Field Summary
 
Fields inherited from class com.sonyericsson.hudson.plugins.metadata.model.values.AbstractMetadataValue
name
 
Constructor Summary
TreeNodeMetadataValue(String name)
          Standard Constructor.
TreeNodeMetadataValue(String name, List<MetadataValue> children)
          Standard Constructor.
TreeNodeMetadataValue(String name, String description)
          Standard Constructor.
TreeNodeMetadataValue(String name, String description, List<MetadataValue> children)
          Standard Constructor.
TreeNodeMetadataValue(String name, String description, List<MetadataValue> children, boolean exposedToEnvironment)
          Standard Constructor.
 
Method Summary
 Collection<MetadataValue> addChild(MetadataValue value)
          Adds the child to the list of children.
 Collection<MetadataValue> addChildren(Collection<MetadataValue> values)
          Adds the children to this parent's list of children.
 void addEnvironmentVariables(hudson.EnvVars variables, boolean exposeAll)
          Adds the environment variables for this Metadata to the variables map.
 TreeNodeMetadataValue clone()
          Clones this MetadataValue.
 int compareTo(Object t)
           
 boolean equals(Object obj)
           
 MetadataValue 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<MetadataValue> getChildren()
          The children of this parent.
 hudson.model.Descriptor<AbstractMetadataValue> getDescriptor()
           
 List<MetadataValue> getValue()
          Get the value.
 int hashCode()
           
 int indexOf(String name)
          The index of the child with the provided name.
 void replacementOf(MetadataValue old)
          A signal sent to this object that it is the replacement of another object.
 boolean requiresReplacement()
          If this parent type requires to be replaced or not when a replacement command is issued.
 MetadataValue setChild(int index, MetadataValue value)
          Sets the child on index with the provided value, replacing any object currently on that index.
 net.sf.json.JSONObject toJson()
          Convert this object into a JSON object.
 
Methods inherited from class com.sonyericsson.hudson.plugins.metadata.model.values.AbstractMetadataValue
getDescription, getEnvironmentName, getFullName, getFullName, getFullNameFrom, getFullPath, getName, getParent, isExposedToEnvironment, isGenerated, setDescription, setExposeToEnvironment, setGenerated, setName, setParent, toAbstractJson
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sonyericsson.hudson.plugins.metadata.model.MetadataParent
getFullName, getFullName, getFullNameFrom
 

Constructor Detail

TreeNodeMetadataValue

@DataBoundConstructor
public TreeNodeMetadataValue(String name,
                                                  String description,
                                                  List<MetadataValue> children,
                                                  boolean exposedToEnvironment)
Standard Constructor.

Parameters:
name - the name.
description - the description
children - its children.
exposedToEnvironment - if this value should be exposed to the build as an environment variable.

TreeNodeMetadataValue

public TreeNodeMetadataValue(String name,
                             String description,
                             List<MetadataValue> children)
Standard Constructor.

Parameters:
name - the name
description - the description.
children - its children.

TreeNodeMetadataValue

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

Parameters:
name - the name
description - the description.

TreeNodeMetadataValue

public TreeNodeMetadataValue(String name,
                             List<MetadataValue> children)
Standard Constructor.

Parameters:
name - the name.
children - its children.

TreeNodeMetadataValue

public TreeNodeMetadataValue(String name)
Standard Constructor.

Parameters:
name - the name.
Method Detail

getValue

public List<MetadataValue> getValue()
Description copied from class: AbstractMetadataValue
Get the value.

Specified by:
getValue in interface Metadata<MetadataValue>
Overrides:
getValue in class AbstractMetadataValue
Returns:
the value.

getChild

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

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

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<MetadataValue>
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 MetadataValue setChild(int index,
                              MetadataValue 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<MetadataValue>
Parameters:
index - the index to set.
value - the child to set.
Returns:
the value previous at the specified index.

addChild

public Collection<MetadataValue> addChild(MetadataValue value)
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<MetadataValue>
Parameters:
value - the child to add.
Returns:
null if the operation was successful.

addChildren

public Collection<MetadataValue> addChildren(Collection<MetadataValue> values)
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<MetadataValue>
Parameters:
values - the children to add.
Returns:
the children that failed to be added/merged or null if all succeeded.

getChildren

public Collection<MetadataValue> getChildren()
Description copied from interface: MetadataParent
The children of this parent.

Specified by:
getChildren in interface MetadataParent<MetadataValue>
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<MetadataValue>
Returns:
the child names of this parent.

replacementOf

public void replacementOf(MetadataValue old)
Description copied from interface: MetadataValue
A signal sent to this object that it is the replacement of another object. The intention from the system is that the object should take this opportunity to try and salvage as much as possible from the old object.

Specified by:
replacementOf in interface MetadataValue
Overrides:
replacementOf in class AbstractMetadataValue
Parameters:
old - the object that it is the replacement of.

getDescriptor

public hudson.model.Descriptor<AbstractMetadataValue> getDescriptor()
Specified by:
getDescriptor in interface hudson.model.Describable<AbstractMetadataValue>

toJson

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

Specified by:
toJson in interface MetadataParent<MetadataValue>
Specified by:
toJson in interface MetadataValue
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<MetadataValue>
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)

addEnvironmentVariables

public void addEnvironmentVariables(hudson.EnvVars variables,
                                    boolean exposeAll)
Description copied from interface: MetadataValue
Adds the environment variables for this Metadata to the variables map.

Specified by:
addEnvironmentVariables in interface MetadataValue
Overrides:
addEnvironmentVariables in class AbstractMetadataValue
Parameters:
variables - the map of current environment variables.
exposeAll - whether all Metadata should be added to the map. Inherited from the parent.

clone

public TreeNodeMetadataValue clone()
                            throws CloneNotSupportedException
Description copied from interface: MetadataValue
Clones this MetadataValue.

Specified by:
clone in interface MetadataValue
Overrides:
clone in class AbstractMetadataValue
Returns:
a clone of this MetadataValue.
Throws:
CloneNotSupportedException - if it cannot be cloned.

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

compareTo

public int compareTo(Object t)
Specified by:
compareTo in interface Comparable<Object>


Copyright © 2004-2013. All Rights Reserved.