- java.lang.Object
-
- org.arakhne.afc.util.MultiValue<T>
-
- Type Parameters:
T
- is the type of the value.
- All Implemented Interfaces:
Serializable
public class MultiValue<T> extends Object implements Serializable
Utilities class that permits to represent a collection of values and indicating if they are all the same or not.- Version:
- 17.0 2020-01-04 14:41:38
- Author:
- Stéphane GALLAND
- See Also:
- Serialized Form
- Maven Group Id:
- org.arakhne.afc.core
- Maven Artifact Id:
- util
-
-
Constructor Summary
Constructors Constructor Description MultiValue()
Create empty output parameter.MultiValue(T initialValue)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(T newValue)
Add the given value to the styored value.void
clear()
Clear this multi-value.boolean
equals(Object obj)
T
get()
Replies the value.Class<? extends T>
getValueType()
Replies the type of the value.int
hashCode()
boolean
isMultipleDifferentValues()
Replies if this MultiValue contains different values.boolean
isSet()
Replies if the value was set.void
setMultipleDifferentValues(boolean multiple)
Set if this MultiValue contains different values.String
toString()
String
toString(String multiValueLabel)
Replies a string representation of the value in this object.
-
-
-
Constructor Detail
-
MultiValue
public MultiValue(T initialValue)
Constructor.- Parameters:
initialValue
- is the initial value of the output parameter.
-
MultiValue
public MultiValue()
Create empty output parameter.
-
-
Method Detail
-
toString
@Pure public String toString(String multiValueLabel)
Replies a string representation of the value in this object. If this object is set and has multiple different values, the parametermultiValueLabel
is replied. If this object is not set or equals tonull
, the empty string is replied. Otherwise the value is replied.- Parameters:
multiValueLabel
- is the label to reply if this object is containing many different values.- Returns:
- the string representation of this object.
-
get
@Pure public T get()
Replies the value.- Returns:
- the value embedded inside this object.
-
getValueType
@Pure public Class<? extends T> getValueType()
Replies the type of the value.- Returns:
- the type or
null
if there is no value.
-
add
public void add(T newValue)
Add the given value to the styored value.- Parameters:
newValue
- the new value.
-
clear
public void clear()
Clear this multi-value.
-
isSet
@Pure public boolean isSet()
Replies if the value was set.- Returns:
true
is the value was set, otherwisefalse
-
isMultipleDifferentValues
@Pure public boolean isMultipleDifferentValues()
Replies if this MultiValue contains different values.- Returns:
true
is values are different, otherwisefalse
-
setMultipleDifferentValues
public void setMultipleDifferentValues(boolean multiple)
Set if this MultiValue contains different values.- Parameters:
multiple
- istrue
is values are different, otherwisefalse
-
-