code links added to readme
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
package pl.com.bottega.factory.demand.forecasting;
|
||||
|
||||
import lombok.Value;
|
||||
import lombok.AllArgsConstructor;
|
||||
import pl.com.bottega.factory.demand.forecasting.DailyDemand.Result;
|
||||
|
||||
import java.time.LocalDate;
|
||||
@@ -11,12 +11,12 @@ import java.util.Optional;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Value
|
||||
@AllArgsConstructor
|
||||
public class AdjustDemand {
|
||||
String refNo;
|
||||
Map<LocalDate, Adjustment> adjustments;
|
||||
private final String refNo;
|
||||
private final Map<LocalDate, Adjustment> adjustments;
|
||||
|
||||
public List<Result> forEachStartingFrom(LocalDate date, BiFunction<LocalDate, Adjustment, Result> f) {
|
||||
List<Result> forEachStartingFrom(LocalDate date, BiFunction<LocalDate, Adjustment, Result> f) {
|
||||
return adjustments.entrySet().stream()
|
||||
.filter(e -> !e.getKey().isBefore(date))
|
||||
.map(e -> f.apply(e.getKey(), e.getValue()))
|
||||
@@ -24,6 +24,11 @@ public class AdjustDemand {
|
||||
}
|
||||
|
||||
public Optional<LocalDate> latestAdjustment() {
|
||||
return adjustments.keySet().stream().max(Comparator.naturalOrder());
|
||||
return adjustments.keySet().stream()
|
||||
.max(Comparator.naturalOrder());
|
||||
}
|
||||
|
||||
public String getRefNo() {
|
||||
return refNo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,33 +1,30 @@
|
||||
package pl.com.bottega.factory.demand.forecasting;
|
||||
|
||||
import lombok.Value;
|
||||
import lombok.AllArgsConstructor;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.SortedMap;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Value
|
||||
@AllArgsConstructor
|
||||
public class Document {
|
||||
|
||||
Instant created;
|
||||
String refNo;
|
||||
SortedMap<LocalDate, Demand> demands;
|
||||
private final Instant created;
|
||||
private final String refNo;
|
||||
private final SortedMap<LocalDate, Demand> demands;
|
||||
|
||||
public Document(Instant created, String refNo, SortedMap<LocalDate, Demand> demands) {
|
||||
this.created = created;
|
||||
this.refNo = refNo;
|
||||
this.demands = Collections.unmodifiableSortedMap(demands);
|
||||
}
|
||||
|
||||
public List<DailyDemand.Result> forEachStartingFrom(LocalDate date, BiFunction<LocalDate, Demand, DailyDemand.Result> f) {
|
||||
List<DailyDemand.Result> forEachStartingFrom(LocalDate date, BiFunction<LocalDate, Demand, DailyDemand.Result> f) {
|
||||
return demands.entrySet().stream()
|
||||
.filter(e -> !e.getKey().isBefore(date))
|
||||
.map(e -> f.apply(e.getKey(), e.getValue()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public String getRefNo() {
|
||||
return refNo;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user