code links added to readme

This commit is contained in:
Michał Michaluk
2018-02-18 22:28:24 +01:00
parent df64659038
commit 8e9e3a1ca9
17 changed files with 111 additions and 71 deletions

View File

@@ -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;
}
}

View File

@@ -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;
}
}