Package net.vleo.timel.time
Class Sample<V>
- java.lang.Object
-
- net.vleo.timel.time.Sample<V>
-
public final class Sample<V> extends Object
An immutable object representing a constant value over a given time interval.- Author:
- Andrea Leofreddi
-
-
Constructor Summary
Constructors Constructor Description Sample()
-
Method Summary
Modifier and Type Method Description Sample<V>
copyWithInterval(Interval newInterval)
Clone the current Sample into a new one with the same value but different interval.<T> Sample<T>
copyWithValue(T newValue)
Clone the current Sample into a new one with the same interval but different value.static <T> Sample<T>
of(Interval interval, T value)
Static factory method to instance a new Sample.String
toString()
-
-
-
Method Detail
-
of
public static <T> Sample<T> of(Interval interval, T value)
Static factory method to instance a new Sample.- Type Parameters:
T
- Value Java type- Parameters:
interval
- Sample intervalvalue
- Sample value- Returns:
- The new sample object
-
copyWithInterval
public Sample<V> copyWithInterval(Interval newInterval)
Clone the current Sample into a new one with the same value but different interval.- Parameters:
newInterval
- The interval of the new sample- Returns:
- The new sample
-
copyWithValue
public <T> Sample<T> copyWithValue(T newValue)
Clone the current Sample into a new one with the same interval but different value.- Type Parameters:
T
- Target value Java type- Parameters:
newValue
- The value of the new sample- Returns:
- The new sample
-
-