Sho SHIMIZU

Remove a method almost duplicated in other method

Change-Id: Idc9bd0cb53696f379fe77b7b30683eb977a597ad
...@@ -86,15 +86,6 @@ interface DiscreteResources { ...@@ -86,15 +86,6 @@ interface DiscreteResources {
86 DiscreteResources add(DiscreteResources other); 86 DiscreteResources add(DiscreteResources other);
87 87
88 /** 88 /**
89 - * Returns a difference set of this instance and the given resources.
90 - * Note: This method returns a new instance, not mutate the current intance.
91 - *
92 - * @param removed resources
93 - * @return a new DiscreteResources instance representing a difference set
94 - */
95 - DiscreteResources remove(Set<DiscreteResource> removed);
96 -
97 - /**
98 * Returns all of resources this instance holds. 89 * Returns all of resources this instance holds.
99 * 90 *
100 * @return all resources 91 * @return all resources
......
...@@ -58,11 +58,6 @@ final class EmptyDiscreteResources implements DiscreteResources { ...@@ -58,11 +58,6 @@ final class EmptyDiscreteResources implements DiscreteResources {
58 } 58 }
59 59
60 @Override 60 @Override
61 - public DiscreteResources remove(Set<DiscreteResource> removed) {
62 - return this;
63 - }
64 -
65 - @Override
66 public Set<DiscreteResource> values() { 61 public Set<DiscreteResource> values() {
67 return ImmutableSet.of(); 62 return ImmutableSet.of();
68 } 63 }
......
...@@ -108,11 +108,6 @@ final class EncodableDiscreteResources implements DiscreteResources { ...@@ -108,11 +108,6 @@ final class EncodableDiscreteResources implements DiscreteResources {
108 } 108 }
109 109
110 @Override 110 @Override
111 - public DiscreteResources remove(Set<DiscreteResource> removed) {
112 - return of(parent, Sets.difference(values(), removed));
113 - }
114 -
115 - @Override
116 public Set<DiscreteResource> values() { 111 public Set<DiscreteResource> values() {
117 return values.values().stream() 112 return values.values().stream()
118 .flatMap(x -> x.values(parent.id()).stream()) 113 .flatMap(x -> x.values(parent.id()).stream())
......
...@@ -79,12 +79,6 @@ final class GenericDiscreteResources implements DiscreteResources { ...@@ -79,12 +79,6 @@ final class GenericDiscreteResources implements DiscreteResources {
79 return new GenericDiscreteResources(newValues); 79 return new GenericDiscreteResources(newValues);
80 } 80 }
81 81
82 - // returns a new instance, not mutate the current instance
83 - @Override
84 - public DiscreteResources remove(Set<DiscreteResource> removed) {
85 - return of(Sets.difference(this.values, removed));
86 - }
87 -
88 @Override 82 @Override
89 public Set<DiscreteResource> values() { 83 public Set<DiscreteResource> values() {
90 // breaks immutability, but intentionally returns the field 84 // breaks immutability, but intentionally returns the field
......
...@@ -102,7 +102,8 @@ class TransactionalDiscreteResourceSubStore { ...@@ -102,7 +102,8 @@ class TransactionalDiscreteResourceSubStore {
102 return true; 102 return true;
103 } 103 }
104 104
105 - DiscreteResources newValues = oldValues.remove(values); 105 + DiscreteResources requested = DiscreteResources.of(values);
106 + DiscreteResources newValues = oldValues.difference(requested);
106 return childMap.replace(key, oldValues, newValues); 107 return childMap.replace(key, oldValues, newValues);
107 } 108 }
108 109
......
...@@ -88,11 +88,6 @@ final class UnifiedDiscreteResources implements DiscreteResources { ...@@ -88,11 +88,6 @@ final class UnifiedDiscreteResources implements DiscreteResources {
88 } 88 }
89 89
90 @Override 90 @Override
91 - public DiscreteResources remove(Set<DiscreteResource> removed) {
92 - return of(Sets.difference(values(), removed));
93 - }
94 -
95 - @Override
96 public Set<DiscreteResource> values() { 91 public Set<DiscreteResource> values() {
97 return Stream.concat(encodables.values().stream(), generics.values().stream()) 92 return Stream.concat(encodables.values().stream(), generics.values().stream())
98 .collect(Collectors.toCollection(LinkedHashSet::new)); 93 .collect(Collectors.toCollection(LinkedHashSet::new));
......