Sho SHIMIZU

Remove a method almost duplicated in other method

Change-Id: Idc9bd0cb53696f379fe77b7b30683eb977a597ad
......@@ -86,15 +86,6 @@ interface DiscreteResources {
DiscreteResources add(DiscreteResources other);
/**
* Returns a difference set of this instance and the given resources.
* Note: This method returns a new instance, not mutate the current intance.
*
* @param removed resources
* @return a new DiscreteResources instance representing a difference set
*/
DiscreteResources remove(Set<DiscreteResource> removed);
/**
* Returns all of resources this instance holds.
*
* @return all resources
......
......@@ -58,11 +58,6 @@ final class EmptyDiscreteResources implements DiscreteResources {
}
@Override
public DiscreteResources remove(Set<DiscreteResource> removed) {
return this;
}
@Override
public Set<DiscreteResource> values() {
return ImmutableSet.of();
}
......
......@@ -108,11 +108,6 @@ final class EncodableDiscreteResources implements DiscreteResources {
}
@Override
public DiscreteResources remove(Set<DiscreteResource> removed) {
return of(parent, Sets.difference(values(), removed));
}
@Override
public Set<DiscreteResource> values() {
return values.values().stream()
.flatMap(x -> x.values(parent.id()).stream())
......
......@@ -79,12 +79,6 @@ final class GenericDiscreteResources implements DiscreteResources {
return new GenericDiscreteResources(newValues);
}
// returns a new instance, not mutate the current instance
@Override
public DiscreteResources remove(Set<DiscreteResource> removed) {
return of(Sets.difference(this.values, removed));
}
@Override
public Set<DiscreteResource> values() {
// breaks immutability, but intentionally returns the field
......
......@@ -102,7 +102,8 @@ class TransactionalDiscreteResourceSubStore {
return true;
}
DiscreteResources newValues = oldValues.remove(values);
DiscreteResources requested = DiscreteResources.of(values);
DiscreteResources newValues = oldValues.difference(requested);
return childMap.replace(key, oldValues, newValues);
}
......
......@@ -88,11 +88,6 @@ final class UnifiedDiscreteResources implements DiscreteResources {
}
@Override
public DiscreteResources remove(Set<DiscreteResource> removed) {
return of(Sets.difference(values(), removed));
}
@Override
public Set<DiscreteResource> values() {
return Stream.concat(encodables.values().stream(), generics.values().stream())
.collect(Collectors.toCollection(LinkedHashSet::new));
......