com.softicar.platform.common.container.schedule.coverage.ScheduleCoverageEntry Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of platform-common Show documentation
Show all versions of platform-common Show documentation
The SoftiCAR Platform is a lightweight, Java-based library to create interactive business web applications.
package com.softicar.platform.common.container.schedule.coverage;
import com.softicar.platform.common.container.map.number.INumberMap;
import com.softicar.platform.common.container.map.number.NumberMap;
import com.softicar.platform.common.math.arithmetic.IArithmetic;
public class ScheduleCoverageEntry> {
private final INumberMap columnQuantities;
private final Quantity unassignedQuantity;
public ScheduleCoverageEntry(IArithmetic arithmetic) {
this.columnQuantities = new NumberMap<>(arithmetic);
this.unassignedQuantity = arithmetic.getZero();
}
public ScheduleCoverageEntry(IArithmetic arithmetic, Quantity unassignedQuantity) {
this.columnQuantities = new NumberMap<>(arithmetic);
this.unassignedQuantity = unassignedQuantity;
}
public ScheduleCoverageEntry(IArithmetic arithmetic, Column coveringColumn, Quantity quantity) {
this(arithmetic);
this.columnQuantities.add(coveringColumn, quantity);
}
public ScheduleCoverageEntry(IArithmetic arithmetic, ScheduleCoverageEntry entry1,
ScheduleCoverageEntry entry2) {
this(arithmetic, arithmetic.plus(entry1.getUnassignedQuantity(), entry2.getUnassignedQuantity()));
this.columnQuantities.add(entry1.getColumnQuantities());
this.columnQuantities.add(entry2.getColumnQuantities());
}
public INumberMap getColumnQuantities() {
return columnQuantities;
}
public Quantity getUnassignedQuantity() {
return unassignedQuantity;
}
public Quantity getTotalQuantity() {
Quantity totalQuantity = unassignedQuantity;
IArithmetic arithmetic = columnQuantities.getArithmetic();
for (Column column: columnQuantities.keySet()) {
totalQuantity = arithmetic.plus(totalQuantity, columnQuantities.getOrZero(column));
}
return totalQuantity;
}
}