Class LocalDateDoubleTimeSeriesBuilder
- java.lang.Object
-
- com.opengamma.strata.collect.timeseries.LocalDateDoubleTimeSeriesBuilder
-
public final class LocalDateDoubleTimeSeriesBuilder extends Object
Builder to create the immutableLocalDateDoubleTimeSeries.This builder allows a time-series to be created. Entries can be added to the builder in any order. If a date is duplicated it will overwrite an earlier entry.
Use
LocalDateDoubleTimeSeries.builder()to create an instance.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LocalDateDoubleTimeSeriesbuild()Build the time-series from the builder.OptionalDoubleget(LocalDate date)Gets the value associated with the specified date.LocalDateDoubleTimeSeriesBuildermerge(LocalDateDoublePoint point, DoubleBinaryOperator operator)Merges the specified date/value point into this builder.LocalDateDoubleTimeSeriesBuildermerge(LocalDate date, double value, DoubleBinaryOperator operator)Merges the specified date/value point into this builder.LocalDateDoubleTimeSeriesBuilderput(LocalDateDoublePoint point)Puts the specified date/value point into this builder.LocalDateDoubleTimeSeriesBuilderput(LocalDate date, double value)Puts the specified date/value point into this builder.LocalDateDoubleTimeSeriesBuilderputAll(LocalDateDoubleTimeSeriesBuilder other)Puts the contents of the specified builder into this builder.LocalDateDoubleTimeSeriesBuilderputAll(Collection<LocalDate> dates, double[] values)Puts all the specified dates and values into this builder.LocalDateDoubleTimeSeriesBuilderputAll(Collection<LocalDate> dates, Collection<Double> values)Puts all the specified dates and values into this builder.LocalDateDoubleTimeSeriesBuilderputAll(List<LocalDateDoublePoint> points)Puts all the specified points into this builder.LocalDateDoubleTimeSeriesBuilderputAll(Map<LocalDate,Double> map)Puts all the entries from the supplied map into this builder.LocalDateDoubleTimeSeriesBuilderputAll(Stream<LocalDateDoublePoint> points)Puts all the specified points into this builder.
-
-
-
Method Detail
-
get
public OptionalDouble get(LocalDate date)
Gets the value associated with the specified date.The result is an
OptionalDoublewhich avoids the need to handle null or exceptions. UseisPresent()to check whether the value is present. UseorElse(double)to default a missing value.- Parameters:
date- the date to get the value for- Returns:
- the value associated with the date, optional empty if the date is not present
-
put
public LocalDateDoubleTimeSeriesBuilder put(LocalDate date, double value)
Puts the specified date/value point into this builder.- Parameters:
date- the date to be addedvalue- the value associated with the date- Returns:
- this builder
-
put
public LocalDateDoubleTimeSeriesBuilder put(LocalDateDoublePoint point)
Puts the specified date/value point into this builder.- Parameters:
point- the point to be added- Returns:
- this builder
-
merge
public LocalDateDoubleTimeSeriesBuilder merge(LocalDate date, double value, DoubleBinaryOperator operator)
Merges the specified date/value point into this builder.The operator is invoked if the date already exists.
- Parameters:
date- the date to be addedvalue- the value associated with the dateoperator- the operator to use for merging- Returns:
- this builder
-
merge
public LocalDateDoubleTimeSeriesBuilder merge(LocalDateDoublePoint point, DoubleBinaryOperator operator)
Merges the specified date/value point into this builder.The operator is invoked if the date already exists.
- Parameters:
point- the point to be addedoperator- the operator to use for merging- Returns:
- this builder
-
putAll
public LocalDateDoubleTimeSeriesBuilder putAll(Collection<LocalDate> dates, Collection<Double> values)
Puts all the specified dates and values into this builder.The date and value collections must be the same size.
The date-value pairs are added one by one. If a date is duplicated it will overwrite an earlier entry.
- Parameters:
dates- the dates to be addedvalues- the values to be added- Returns:
- this builder
-
putAll
public LocalDateDoubleTimeSeriesBuilder putAll(Collection<LocalDate> dates, double[] values)
Puts all the specified dates and values into this builder.The date collection and value array must be the same size.
The date-value pairs are added one by one. If a date is duplicated it will overwrite an earlier entry.
- Parameters:
dates- the dates to be addedvalues- the values to be added- Returns:
- this builder
-
putAll
public LocalDateDoubleTimeSeriesBuilder putAll(Stream<LocalDateDoublePoint> points)
Puts all the specified points into this builder.The points are added one by one. If a date is duplicated it will overwrite an earlier entry.
- Parameters:
points- the points to be added- Returns:
- this builder
-
putAll
public LocalDateDoubleTimeSeriesBuilder putAll(List<LocalDateDoublePoint> points)
Puts all the specified points into this builder.The points are added one by one. If a date is duplicated it will overwrite an earlier entry.
- Parameters:
points- the points to be added- Returns:
- this builder
-
putAll
public LocalDateDoubleTimeSeriesBuilder putAll(LocalDateDoubleTimeSeriesBuilder other)
Puts the contents of the specified builder into this builder.The points are added one by one. If a date is duplicated it will overwrite an earlier entry.
- Parameters:
other- the other builder- Returns:
- this builder
-
putAll
public LocalDateDoubleTimeSeriesBuilder putAll(Map<LocalDate,Double> map)
Puts all the entries from the supplied map into this builder.If a date is duplicated it will overwrite an earlier entry.
- Parameters:
map- the map of points to be added- Returns:
- this builder
-
build
public LocalDateDoubleTimeSeries build()
Build the time-series from the builder.- Returns:
- a time-series containing the entries from the builder
-
-