Sho SHIMIZU

Move the resource allocation details into ContinuousResourceAllocation

Change-Id: If5b6a86c92f27cc7acf65e6e397f72afd3a4cb41
......@@ -70,6 +70,13 @@ final class ContinuousResourceAllocation {
return allocations;
}
ContinuousResourceAllocation allocate(ContinuousResource original, ResourceAllocation value) {
return new ContinuousResourceAllocation(original, ImmutableList.<ResourceAllocation>builder()
.addAll(allocations)
.add(value)
.build());
}
ContinuousResourceAllocation release(ContinuousResource resource, ResourceConsumerId consumerId) {
List<ResourceAllocation> nonMatched = allocations.stream()
.filter(x -> !(x.consumerId().equals(consumerId) &&
......
......@@ -156,11 +156,7 @@ class TransactionalContinuousResourceStore {
return true;
}
ContinuousResourceAllocation newValue = new ContinuousResourceAllocation(original,
ImmutableList.<ResourceAllocation>builder()
.addAll(oldValue.allocations())
.add(value)
.build());
ContinuousResourceAllocation newValue = oldValue.allocate(original, value);
return consumers.replace(original.id(), oldValue, newValue);
}
......