Package csw.params.core.generics
Class ParameterSetType<T extends ParameterSetType<T>>
- java.lang.Object
-
- csw.params.core.generics.ParameterSetType<T>
-
- Type Parameters:
T
- the subclass of ParameterSetType
- Direct Known Subclasses:
CurrentState
,DemandState
,Observe
,ObserveEvent
,Result
,Setup
,Struct
,SystemEvent
,Wait
public abstract class ParameterSetType<T extends ParameterSetType<T>> extends java.lang.Object
The base trait for various parameter set types (commands or events)
-
-
Constructor Summary
Constructors Constructor Description ParameterSetType()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description <P extends Parameter<?>>
Tadd(P parameter)
Adds a parameter to the parameter set<S> Parameter<S>
apply(Key<S> key)
Return the parameter associated with a Key rather than an Optionboolean
contains(Key<?> key)
Returns true if the data contains the given keyprotected abstract T
create(scala.collection.immutable.Set<Parameter<?>> data)
Method called by subclass to create a copy with the same key (or other fields) and new parameters.protected java.lang.String
dataToString()
A comma separated string representation of parameters<S> boolean
exists(Key<S> key)
Returns true if the key exists in the parameter set<S> scala.Option<Parameter<S>>
find(Parameter<S> parameter)
Find a parameter based on it's keyName and keyType<S> scala.Option<Parameter<S>>
get(Key<S> key)
Returns an Option with the parameter for the key if found, otherwise None<S> scala.Option<Parameter<S>>
get(java.lang.String keyName, KeyType<S> keyType)
Returns an Option with the parameter for the key if found, otherwise Nonescala.collection.immutable.Map<java.lang.String,java.lang.String>
getStringMap()
Returns a map based on this object where the keys and values are in string get (Could be useful for exporting in a get that other languages can read).<S> java.util.Optional<Parameter<S>>
jFind(Parameter<S> parameter)
A Java helper to find a parameter based on it's keyName and keyType<S> java.util.Optional<Parameter<S>>
jGet(Key<S> key)
Returns an Optional with the parameter for the key if found, otherwise empty<S> java.util.Optional<Parameter<S>>
jGet(java.lang.String keyName, KeyType<S> keyType)
Returns an Optional with the parameter for the key if found, otherwise emptyjava.util.Map<java.lang.String,java.lang.String>
jGetStringMap()
A Java helper that returns a map based on this object where the keys and values are in string get (Could be useful for exporting in a get that other languages can read).<P extends Parameter<?>>
TjMadd(java.util.Set<P> parametersToAdd)
java.util.Set<java.lang.String>
jMissingKeys(Key<?>... keys)
A Java helper that returns a set containing the names of any of the given keys that are missing in the datajava.util.Set<java.lang.String>
jMissingKeys(scala.collection.immutable.Seq<Key<?>> keys)
A Java helper that returns a set containing the names of any of the given keys that are missing in the datajava.util.Set<Parameter<?>>
jParamSet()
A Java helper to get parameters for this parameter set<P extends Parameter<?>>
Tmadd(P... parametersToAdd)
Adds several parameters to the parameter set<P extends Parameter<?>>
Tmadd(scala.collection.immutable.Seq<P> parametersToAdd)
Adds several parameters to the parameter set<P extends Parameter<?>>
Tmadd(scala.collection.immutable.Set<P> parametersToAdd)
Adds several parameters to the parameter setscala.collection.immutable.Set<java.lang.String>
missingKeys(scala.collection.immutable.Seq<Key<?>> keys)
Returns a set containing the names of any of the given keys that are missing in the data<S> Parameter<S>
parameter(Key<S> key)
Returns the actual parameter associated with a keyabstract scala.collection.immutable.Set<Parameter<?>>
paramSet()
Holds the parameters for this parameter set<S> T
remove(Key<S> key)
Remove a parameter from the parameter set by key<P extends Parameter<?>>
Tremove(P parameter)
Removes a parameter based on the parameterint
size()
The number of parameters in this parameter setjava.lang.String
toString()
A String representation of concrete implementation of this classjava.lang.String
typeName()
A name identifying the type of parameter set, such as "setup", "observe".
-
-
-
Method Detail
-
add
public <P extends Parameter<?>> T add(P parameter)
Adds a parameter to the parameter set- Parameters:
parameter
- the parameter to add- Returns:
- a new instance of this parameter set with the given parameter added
-
apply
public final <S> Parameter<S> apply(Key<S> key)
Return the parameter associated with a Key rather than an Option- Parameters:
key
- the Key to be used for lookup- Returns:
- the parameter associated with the Key or a NoSuchElementException if the key does not exist
-
contains
public boolean contains(Key<?> key)
Returns true if the data contains the given key- Parameters:
key
- (undocumented)- Returns:
- (undocumented)
-
create
protected abstract T create(scala.collection.immutable.Set<Parameter<?>> data)
Method called by subclass to create a copy with the same key (or other fields) and new parameters. It is protected and subclasses should also keep it as protected to avoid receiving duplicate keys.- Parameters:
data
- a new set of Parameters after addition or deletion- Returns:
- a concrete implementation of type T
-
dataToString
protected java.lang.String dataToString()
A comma separated string representation of parameters- Returns:
- (undocumented)
-
exists
public <S> boolean exists(Key<S> key)
Returns true if the key exists in the parameter set- Parameters:
key
- the key to check for- Returns:
- true if the key is found
-
find
public <S> scala.Option<Parameter<S>> find(Parameter<S> parameter)
Find a parameter based on it's keyName and keyType- Parameters:
parameter
- who's keyName and keyType is used to get values and units- Returns:
- an Option of Parameter[S] if it is found, otherwise None
-
get
public <S> scala.Option<Parameter<S>> get(Key<S> key)
Returns an Option with the parameter for the key if found, otherwise None- Parameters:
key
- the Key to be used for lookup- Returns:
- the parameter for the key, if found
-
get
public <S> scala.Option<Parameter<S>> get(java.lang.String keyName, KeyType<S> keyType)
Returns an Option with the parameter for the key if found, otherwise None- Parameters:
keyName
- the keyName for a keykeyType
- the keyType for a key- Returns:
- the parameter for the key, if found
-
getStringMap
public scala.collection.immutable.Map<java.lang.String,java.lang.String> getStringMap()
Returns a map based on this object where the keys and values are in string get (Could be useful for exporting in a get that other languages can read). Derived classes might want to add values to this map for fixed fields.- Returns:
- (undocumented)
-
jFind
public <S> java.util.Optional<Parameter<S>> jFind(Parameter<S> parameter)
A Java helper to find a parameter based on it's keyName and keyType- Parameters:
parameter
- who's keyName and keyType is used to get values and units- Returns:
- an Optional of Parameter[S] if it is found, otherwise empty
-
jGet
public <S> java.util.Optional<Parameter<S>> jGet(Key<S> key)
Returns an Optional with the parameter for the key if found, otherwise empty- Parameters:
key
- the Key to be used for lookup- Returns:
- the parameter for the key, if found
-
jGet
public <S> java.util.Optional<Parameter<S>> jGet(java.lang.String keyName, KeyType<S> keyType)
Returns an Optional with the parameter for the key if found, otherwise empty- Parameters:
keyName
- the keyName for a keykeyType
- the keyType for a key- Returns:
- the parameter for the key, if found
-
jGetStringMap
public java.util.Map<java.lang.String,java.lang.String> jGetStringMap()
A Java helper that returns a map based on this object where the keys and values are in string get (Could be useful for exporting in a get that other languages can read). Derived classes might want to add values to this map for fixed fields.- Returns:
- (undocumented)
-
jMissingKeys
public java.util.Set<java.lang.String> jMissingKeys(Key<?>... keys)
A Java helper that returns a set containing the names of any of the given keys that are missing in the data- Parameters:
keys
- one or more keys- Returns:
- (undocumented)
-
jMissingKeys
public java.util.Set<java.lang.String> jMissingKeys(scala.collection.immutable.Seq<Key<?>> keys)
A Java helper that returns a set containing the names of any of the given keys that are missing in the data- Parameters:
keys
- one or more keys- Returns:
- (undocumented)
-
jParamSet
public java.util.Set<Parameter<?>> jParamSet()
A Java helper to get parameters for this parameter set- Returns:
- (undocumented)
-
madd
public <P extends Parameter<?>> T madd(P... parametersToAdd)
Adds several parameters to the parameter set- Parameters:
parametersToAdd
- the list of parameters to add to the parameter set- Returns:
- a new instance of this parameter set with the given parameter added
-
madd
public <P extends Parameter<?>> T madd(scala.collection.immutable.Seq<P> parametersToAdd)
Adds several parameters to the parameter set- Parameters:
parametersToAdd
- the list of parameters to add to the parameter set- Returns:
- a new instance of this parameter set with the given parameter added
-
madd
public <P extends Parameter<?>> T madd(scala.collection.immutable.Set<P> parametersToAdd)
Adds several parameters to the parameter set- Parameters:
parametersToAdd
- the list of parameters to add to the parameter set- Returns:
- a new instance of this parameter set with the given parameter added
-
missingKeys
public scala.collection.immutable.Set<java.lang.String> missingKeys(scala.collection.immutable.Seq<Key<?>> keys)
Returns a set containing the names of any of the given keys that are missing in the data- Parameters:
keys
- one or more keys- Returns:
- a Set of key names
-
paramSet
public abstract scala.collection.immutable.Set<Parameter<?>> paramSet()
Holds the parameters for this parameter set- Returns:
- (undocumented)
-
parameter
public final <S> Parameter<S> parameter(Key<S> key)
Returns the actual parameter associated with a key- Parameters:
key
- the Key to be used for lookup- Returns:
- the parameter associated with the key or a NoSuchElementException if the key does not exist
-
remove
public <S> T remove(Key<S> key)
Remove a parameter from the parameter set by key- Parameters:
key
- the Key to be used for removal- Returns:
- a new T, where T is a parameter set child with the key removed or identical if the key is not present
-
remove
public <P extends Parameter<?>> T remove(P parameter)
Removes a parameter based on the parameter- Parameters:
parameter
- to be removed from the parameter set- Returns:
- a new T, where T is a parameter set child with the parameter removed or identical if the parameter is not present
-
size
public int size()
The number of parameters in this parameter set- Returns:
- the number of parameters in the parameter set
-
toString
public java.lang.String toString()
A String representation of concrete implementation of this class- Overrides:
toString
in classjava.lang.Object
- Returns:
- (undocumented)
-
typeName
public java.lang.String typeName()
A name identifying the type of parameter set, such as "setup", "observe". This is used in the JSON and toString output.- Returns:
- (undocumented)
-
-