com.kuka.common
Class ParameterSet

java.lang.Object
  extended by com.kuka.common.ParameterSet
All Implemented Interfaces:
Cloneable, Iterable<Object>

public class ParameterSet
extends Object
implements Cloneable, Iterable<Object>

Represents a set of parameters.

This element is an undocumented internal feature. It is not intended to be used by applications as it might change or be removed in future versions.

Constructor Summary
ParameterSet()
           
 
Method Summary
static ParameterSet asOne(ParameterSet[] params)
          Converts the given parameter sets into one by merging them.
 void clear()
          Clears all values in the set.
 ParameterSet clone()
           
 boolean contains(String name)
          Determines if this set contains the given parameter.
 ParameterSet copyAndPut(String name, Object value)
          Adds the specified parameter to this set.
 Iterable<Map.Entry<String,Object>> entrySet()
          Returns all entries in the set.
 String getName()
          Gets the name of this parameter set.
 boolean isEmpty()
          Checks whether this parameter set is empty.
 boolean isLocked()
          Checks if the set is locked.
 Iterator<Object> iterator()
           
 Object lock()
          Locks the set.
static
<T extends ParameterSet>
T
merge(T primary, ParameterSet... sets)
          Merges a parameter set with other sets.
 Object optionalParameter(String name, Object defaultValue)
          Gets the parameter with the specified name.
 ParameterSet put(ParameterSet other)
          Adds all parameters of the given set into this one.
 ParameterSet put(ParameterSet other, boolean override)
          Adds all parameters of the given set into this one.
 ParameterSet put(String name, Object value)
          Adds the specified parameter to this set.
 Object requiredParameter(String name)
          Gets the parameter with the specified name.
 void setName(String name)
          Sets the name of this parameter set.
 int size()
          Returns the parameter count of this set.
 String toString()
           
 void unlock(Object key)
          Unlocks the set.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ParameterSet

public ParameterSet()
Method Detail

setName

public final void setName(String name)
Sets the name of this parameter set.

Parameters:
name - The name of this set.

entrySet

public Iterable<Map.Entry<String,Object>> entrySet()
Returns all entries in the set.

Returns:
All entries in the set.

getName

public final String getName()
Gets the name of this parameter set.

Returns:
The name of this parameter set.

optionalParameter

public Object optionalParameter(String name,
                                Object defaultValue)
Gets the parameter with the specified name. Returns the given default value if no parameter was found.

Parameters:
name - The name of the parameter.
defaultValue - The default value which is returned when no parameter was found.
Returns:
The parameter value or the default value.

requiredParameter

public Object requiredParameter(String name)
Gets the parameter with the specified name. Fails if the parameter was not found.

Parameters:
name - The name of the parameter.
Returns:
The parameter with the specified name.
Throws:
IllegalArgumentException - if the name is null or if no parameter with the specified name was found in the set.

contains

public boolean contains(String name)
Determines if this set contains the given parameter.

Parameters:
name - The name of the parameter.
Returns:
True if this set contains the specified parameter.

size

public int size()
Returns the parameter count of this set.

Returns:
The parameter count of this set.

copyAndPut

public ParameterSet copyAndPut(String name,
                               Object value)
Adds the specified parameter to this set. Overrides an existing parameter with the same name.

A copy of this set is created and returned. The original set stays unchanged.

Parameters:
name - The name of the parameter.
value - The value of the parameter.
Returns:
A copy of this set with the added parameter.

put

public ParameterSet put(ParameterSet other)
Adds all parameters of the given set into this one. Already existing parameters are overridden.

Parameters:
other - The other parameter set.
Returns:
This parameter set.

put

public ParameterSet put(ParameterSet other,
                        boolean override)
Adds all parameters of the given set into this one. Already existing parameters are overridden if the override flag is set to true.

Parameters:
other - The other parameter set.
override - Override flag.
Returns:
This parameter set.

put

public ParameterSet put(String name,
                        Object value)
Adds the specified parameter to this set. Overrides an existing parameter with the same name.

Parameters:
name - The name of the parameter.
value - The value of the parameter.
Returns:
This set.

toString

public String toString()
Overrides:
toString in class Object

isEmpty

public boolean isEmpty()
Checks whether this parameter set is empty.

Returns:
True if this set is empty, false otherwise.

clear

public void clear()
Clears all values in the set.


clone

public ParameterSet clone()
Overrides:
clone in class Object

iterator

public Iterator<Object> iterator()
Specified by:
iterator in interface Iterable<Object>

lock

public Object lock()
Locks the set. Returns a key that can be used to unlock the set. Without that key, the set is read-only.

Fails if the set is already locked.

Returns:
The key that is necessary to unlock the set.
See Also:
unlock(Object)

unlock

public void unlock(Object key)
Unlocks the set. The key parameter is the value returned by the lock method. Only the correct key can unlock the set.

Fails if the set is already unlocked.

Parameters:
key - The key to unlock the set.

isLocked

public boolean isLocked()
Checks if the set is locked. All write accesses will fail if the set is locked.

Returns:
True if the set is locked, false otherwise.

asOne

public static ParameterSet asOne(ParameterSet[] params)
Converts the given parameter sets into one by merging them.

Parameters:
params - The parameters.
Returns:
A merged single parameter set.

merge

public static <T extends ParameterSet> T merge(T primary,
                                               ParameterSet... sets)
Merges a parameter set with other sets.

The order of the sets is important: Only parameters not present in the merged set will be added. No overriding occurs.

The primary set is not changed.

Type Parameters:
T - The type of the primary set.
Parameters:
primary - The primary set. May not be null. This set will not get changed. A new set is created.
sets - List of sets which will get merged into the primary set.
Returns:
The new created merged set.


Copyright © 2019. All rights reserved.