ItEr39S16CUConfiguracionMaquinasItEr35S09: Extracting and moving methods to DayAssignment
This commit is contained in:
parent
f70c31c40f
commit
f0433f5b05
3 changed files with 14 additions and 10 deletions
|
|
@ -26,8 +26,10 @@ import java.util.Collection;
|
|||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
|
|
@ -91,6 +93,15 @@ public abstract class DayAssignment extends BaseEntity {
|
|||
return result;
|
||||
}
|
||||
|
||||
public static Set<Resource> getAllResources(
|
||||
Collection<? extends DayAssignment> assignments) {
|
||||
Set<Resource> result = new HashSet<Resource>();
|
||||
for (DayAssignment dayAssignment : assignments) {
|
||||
result.add(dayAssignment.getResource());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Min(0)
|
||||
private int hours;
|
||||
|
||||
|
|
|
|||
|
|
@ -220,11 +220,8 @@ public class GenericResourceAllocation extends
|
|||
|
||||
@Override
|
||||
public List<Resource> getAssociatedResources() {
|
||||
Set<Resource> resources = new HashSet<Resource>();
|
||||
for (DayAssignment dayAssignment : getAssignments()) {
|
||||
resources.add(dayAssignment.getResource());
|
||||
}
|
||||
return new ArrayList<Resource>(resources);
|
||||
return new ArrayList<Resource>(DayAssignment
|
||||
.getAllResources(getAssignments()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -532,11 +532,7 @@ public abstract class ResourceAllocation<T extends DayAssignment> extends
|
|||
}
|
||||
|
||||
public int getAssignedHours() {
|
||||
int total = 0;
|
||||
for (DayAssignment dayAssignment : getAssignments()) {
|
||||
total += dayAssignment.getHours();
|
||||
}
|
||||
return total;
|
||||
return DayAssignment.sum(getAssignments());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue