
nl.tno.bim.nmd.domain.NmdFaseProfielImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of bimnmdservice Show documentation
Show all versions of bimnmdservice Show documentation
provides a REST api for retrieving nmd data from various data sources
The newest version!
package nl.tno.bim.nmd.domain;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map.Entry;
import java.util.Set;
public class NmdFaseProfielImpl implements NmdFaseProfiel {
private HashMap profielCoefficienten;
private String fase;
private NmdReferenceResources refData;
public NmdFaseProfielImpl(String fase, NmdReferenceResources referenceData) {
profielCoefficienten = new HashMap();
this.refData = referenceData;
this.setAll(0);
this.fase = fase;
}
public void setAll(double value) {
for (Entry factor : this.refData.getMilieuCategorieMapping().entrySet()) {
setProfielCoefficient(factor.getValue().getDescription(), value);
}
}
@Override
public double getProfielCoefficient(String milieuCategorie) {
return profielCoefficienten.getOrDefault(milieuCategorie, 0.0);
}
@Override
public void setProfielCoefficient(String milieuCategorie, double value) {
this.profielCoefficienten.put(milieuCategorie, value);
}
@Override
public String getFase() {
return this.fase;
}
@Override
public Set calculateFactors(double cost) {
Set results = new HashSet();
for (Entry entry : this.refData.getMilieuCategorieMapping().entrySet()) {
String description = entry.getValue().getDescription();
Double profielValue = profielCoefficienten.getOrDefault(description, Double.NaN);
if (!profielValue.isNaN()) {
results.add(
new NmdCostFactor(this.fase, description, cost * profielValue * entry.getValue().getWeight()));
}
}
return results;
}
@Override
public Double getCoefficientSum() {
return this.profielCoefficienten.values().stream()
.filter(v -> !v.isNaN())
.mapToDouble(v -> v.doubleValue())
.sum();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy