Package org.silverpeas.core.variables
Class VariableValueSet
- java.lang.Object
-
- org.silverpeas.core.variables.VariableValueSet
-
- All Implemented Interfaces:
Iterable<VariableScheduledValue>
,Collection<VariableScheduledValue>
public class VariableValueSet extends Object implements Collection<VariableScheduledValue>
A set of variable's values. The set is related to a given variable and each value is defined for a given period in time.- Author:
- mmoquillon
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(VariableScheduledValue value)
Adds the specified variable value into this variable's values set.boolean
addAll(Collection<? extends VariableScheduledValue> values)
Adds the specified variable values into this variable's values set.VariableScheduledValue
addAndSave(VariableScheduledValue value)
Adds the specified variable value into the variable's values set and saves automatically the set.void
clear()
boolean
contains(Object o)
boolean
containsAll(Collection<?> c)
void
forEach(Consumer<? super VariableScheduledValue> action)
Optional<VariableScheduledValue>
get(String id)
Gets from this variable's value set the value with the specified identifier.Optional<VariableScheduledValue>
getCurrent()
Gets the value among the variable's value set that is valid at the current date time.Optional<VariableScheduledValue>
getNext()
Gets the value among the variable's value set that will be next scheduled.Optional<VariableScheduledValue>
getPrevious()
Gets the value among the variable's value set that was previously scheduled.boolean
isEmpty()
Is this variable's value set empty?Iterator<VariableScheduledValue>
iterator()
boolean
remove(Object o)
boolean
remove(String id)
Removes the specified variables' value from this set.boolean
removeAll(Collection<?> c)
boolean
retainAll(Collection<?> c)
int
size()
Gets the size in values of this variable's values set.Spliterator<VariableScheduledValue>
spliterator()
Stream<VariableScheduledValue>
stream()
Gets a stream on all of the values of the underlying variable.Object[]
toArray()
<T> T[]
toArray(T[] a)
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, toArray
-
-
-
-
Method Detail
-
add
public boolean add(VariableScheduledValue value)
Adds the specified variable value into this variable's values set. In order the adding to be effective you have to invokeVariable.save()
.- Specified by:
add
in interfaceCollection<VariableScheduledValue>
- Parameters:
value
- the value, defined in a given period, to add in this set.
-
remove
public boolean remove(Object o)
- Specified by:
remove
in interfaceCollection<VariableScheduledValue>
-
containsAll
public boolean containsAll(Collection<?> c)
- Specified by:
containsAll
in interfaceCollection<VariableScheduledValue>
-
addAll
public boolean addAll(Collection<? extends VariableScheduledValue> values)
Adds the specified variable values into this variable's values set. In order the adding to be effective you have to invokeVariable.save()
.- Specified by:
addAll
in interfaceCollection<VariableScheduledValue>
- Parameters:
values
- a collection of values, each of then defined in a given period, to add in this set.
-
removeAll
public boolean removeAll(Collection<?> c)
- Specified by:
removeAll
in interfaceCollection<VariableScheduledValue>
-
retainAll
public boolean retainAll(Collection<?> c)
- Specified by:
retainAll
in interfaceCollection<VariableScheduledValue>
-
clear
public void clear()
- Specified by:
clear
in interfaceCollection<VariableScheduledValue>
-
addAndSave
public VariableScheduledValue addAndSave(VariableScheduledValue value)
Adds the specified variable value into the variable's values set and saves automatically the set. This method can be invoked only with an already persisted variable otherwise aPersistenceException
will be thrown. Useful when just to add a new value to the underlying variable for a given period.- Parameters:
value
- the value, defined in a given period, to add in this set.- Returns:
- the persisted variable value.
-
stream
public Stream<VariableScheduledValue> stream()
Gets a stream on all of the values of the underlying variable.- Specified by:
stream
in interfaceCollection<VariableScheduledValue>
- Returns:
- a stream of variable values.
-
get
public Optional<VariableScheduledValue> get(String id)
Gets from this variable's value set the value with the specified identifier.- Parameters:
id
- the unique identifier of the value to get.- Returns:
- an optional value. If no such value exists among the variable's values, then an empty optional value is returned.
-
remove
public boolean remove(String id)
Removes the specified variables' value from this set. In order the removing to be effective, you have to invokeVariable.save()
.- Parameters:
id
- the unique identifier of the variable's value to remove.- Returns:
- true if the value with the specified identifier is removed, false otherwise. False is returned if no such value is defined for the underlying variable.
-
getCurrent
public Optional<VariableScheduledValue> getCurrent()
Gets the value among the variable's value set that is valid at the current date time.- Returns:
- an optional variable value. If the underlying variable has no value or none that is valid at now, then an empty optional value is returned.
-
getNext
public Optional<VariableScheduledValue> getNext()
Gets the value among the variable's value set that will be next scheduled.- Returns:
- an optional variable value. If the underlying variable has no value or none that will be scheduled in the future, then an empty optional value is returned.
-
getPrevious
public Optional<VariableScheduledValue> getPrevious()
Gets the value among the variable's value set that was previously scheduled.- Returns:
- an optional variable value. If the underlying variable has no value or none that was previously scheduled, then an empty optional value is returned.
-
size
public int size()
Gets the size in values of this variable's values set.- Specified by:
size
in interfaceCollection<VariableScheduledValue>
- Returns:
- the count of values of the underlying variable.
-
isEmpty
public boolean isEmpty()
Is this variable's value set empty?- Specified by:
isEmpty
in interfaceCollection<VariableScheduledValue>
- Returns:
- true if the underlying variable has no defined values. False otherwise.
-
contains
public boolean contains(Object o)
- Specified by:
contains
in interfaceCollection<VariableScheduledValue>
-
iterator
public Iterator<VariableScheduledValue> iterator()
- Specified by:
iterator
in interfaceCollection<VariableScheduledValue>
- Specified by:
iterator
in interfaceIterable<VariableScheduledValue>
-
toArray
public Object[] toArray()
- Specified by:
toArray
in interfaceCollection<VariableScheduledValue>
-
toArray
public <T> T[] toArray(T[] a)
- Specified by:
toArray
in interfaceCollection<VariableScheduledValue>
-
forEach
public void forEach(Consumer<? super VariableScheduledValue> action)
- Specified by:
forEach
in interfaceIterable<VariableScheduledValue>
-
spliterator
public Spliterator<VariableScheduledValue> spliterator()
- Specified by:
spliterator
in interfaceCollection<VariableScheduledValue>
- Specified by:
spliterator
in interfaceIterable<VariableScheduledValue>
-
-