Sho SHIMIZU

Rename NonEncodableDiscreteResources to GenericDiscreteResources

Change-Id: Ib610895b3e2251af1ae5b1cae2b9b8f378a8d920
...@@ -74,7 +74,7 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour ...@@ -74,7 +74,7 @@ public class ConsistentResourceStore extends AbstractStore<ResourceEvent, Resour
74 .register(KryoNamespaces.API) 74 .register(KryoNamespaces.API)
75 .register(UnifiedDiscreteResources.class) 75 .register(UnifiedDiscreteResources.class)
76 .register(new EncodableDiscreteResourcesSerializer(), EncodableDiscreteResources.class) 76 .register(new EncodableDiscreteResourcesSerializer(), EncodableDiscreteResources.class)
77 - .register(NonEncodableDiscreteResources.class) 77 + .register(GenericDiscreteResources.class)
78 .register(EmptyDiscreteResources.class) 78 .register(EmptyDiscreteResources.class)
79 .register(ContinuousResourceAllocation.class) 79 .register(ContinuousResourceAllocation.class)
80 .build()); 80 .build());
......
...@@ -27,7 +27,7 @@ import java.util.Objects; ...@@ -27,7 +27,7 @@ import java.util.Objects;
27 import java.util.Optional; 27 import java.util.Optional;
28 import java.util.Set; 28 import java.util.Set;
29 29
30 -final class NonEncodableDiscreteResources implements DiscreteResources { 30 +final class GenericDiscreteResources implements DiscreteResources {
31 private final Set<DiscreteResource> values; 31 private final Set<DiscreteResource> values;
32 32
33 static DiscreteResources of(Set<DiscreteResource> resources) { 33 static DiscreteResources of(Set<DiscreteResource> resources) {
...@@ -35,15 +35,15 @@ final class NonEncodableDiscreteResources implements DiscreteResources { ...@@ -35,15 +35,15 @@ final class NonEncodableDiscreteResources implements DiscreteResources {
35 return DiscreteResources.empty(); 35 return DiscreteResources.empty();
36 } 36 }
37 37
38 - return new NonEncodableDiscreteResources(resources); 38 + return new GenericDiscreteResources(resources);
39 } 39 }
40 40
41 - private NonEncodableDiscreteResources(Set<DiscreteResource> values) { 41 + private GenericDiscreteResources(Set<DiscreteResource> values) {
42 this.values = values; 42 this.values = values;
43 } 43 }
44 44
45 // for serializer 45 // for serializer
46 - private NonEncodableDiscreteResources() { 46 + private GenericDiscreteResources() {
47 this.values = null; 47 this.values = null;
48 } 48 }
49 49
...@@ -59,7 +59,7 @@ final class NonEncodableDiscreteResources implements DiscreteResources { ...@@ -59,7 +59,7 @@ final class NonEncodableDiscreteResources implements DiscreteResources {
59 59
60 @Override 60 @Override
61 public DiscreteResources difference(DiscreteResources other) { 61 public DiscreteResources difference(DiscreteResources other) {
62 - return new NonEncodableDiscreteResources(Sets.difference(this.values, other.values())); 62 + return new GenericDiscreteResources(Sets.difference(this.values, other.values()));
63 } 63 }
64 64
65 @Override 65 @Override
...@@ -77,7 +77,7 @@ final class NonEncodableDiscreteResources implements DiscreteResources { ...@@ -77,7 +77,7 @@ final class NonEncodableDiscreteResources implements DiscreteResources {
77 public DiscreteResources add(DiscreteResources other) { 77 public DiscreteResources add(DiscreteResources other) {
78 Set<DiscreteResource> newValues = new LinkedHashSet<>(this.values); 78 Set<DiscreteResource> newValues = new LinkedHashSet<>(this.values);
79 newValues.addAll(other.values()); 79 newValues.addAll(other.values());
80 - return new NonEncodableDiscreteResources(newValues); 80 + return new GenericDiscreteResources(newValues);
81 } 81 }
82 82
83 // returns a new instance, not mutate the current instance 83 // returns a new instance, not mutate the current instance
...@@ -85,7 +85,7 @@ final class NonEncodableDiscreteResources implements DiscreteResources { ...@@ -85,7 +85,7 @@ final class NonEncodableDiscreteResources implements DiscreteResources {
85 public DiscreteResources remove(List<DiscreteResource> removed) { 85 public DiscreteResources remove(List<DiscreteResource> removed) {
86 Set<DiscreteResource> newValues = new LinkedHashSet<>(this.values); 86 Set<DiscreteResource> newValues = new LinkedHashSet<>(this.values);
87 newValues.removeAll(removed); 87 newValues.removeAll(removed);
88 - return new NonEncodableDiscreteResources(newValues); 88 + return new GenericDiscreteResources(newValues);
89 } 89 }
90 90
91 @Override 91 @Override
...@@ -108,7 +108,7 @@ final class NonEncodableDiscreteResources implements DiscreteResources { ...@@ -108,7 +108,7 @@ final class NonEncodableDiscreteResources implements DiscreteResources {
108 if (obj == null || getClass() != obj.getClass()) { 108 if (obj == null || getClass() != obj.getClass()) {
109 return false; 109 return false;
110 } 110 }
111 - final NonEncodableDiscreteResources other = (NonEncodableDiscreteResources) obj; 111 + final GenericDiscreteResources other = (GenericDiscreteResources) obj;
112 return Objects.equals(this.values, other.values); 112 return Objects.equals(this.values, other.values);
113 } 113 }
114 114
......
...@@ -33,7 +33,7 @@ import java.util.stream.Stream; ...@@ -33,7 +33,7 @@ import java.util.stream.Stream;
33 * and those that can't encoded as integer. 33 * and those that can't encoded as integer.
34 */ 34 */
35 final class UnifiedDiscreteResources implements DiscreteResources { 35 final class UnifiedDiscreteResources implements DiscreteResources {
36 - private final DiscreteResources nonEncodables; 36 + private final DiscreteResources generics;
37 private final DiscreteResources encodables; 37 private final DiscreteResources encodables;
38 private static final Codecs CODECS = Codecs.getInstance(); 38 private static final Codecs CODECS = Codecs.getInstance();
39 39
...@@ -45,13 +45,13 @@ final class UnifiedDiscreteResources implements DiscreteResources { ...@@ -45,13 +45,13 @@ final class UnifiedDiscreteResources implements DiscreteResources {
45 Map<Boolean, Set<DiscreteResource>> partitioned = resources.stream() 45 Map<Boolean, Set<DiscreteResource>> partitioned = resources.stream()
46 .collect(Collectors.partitioningBy(CODECS::isEncodable, Collectors.toCollection(LinkedHashSet::new))); 46 .collect(Collectors.partitioningBy(CODECS::isEncodable, Collectors.toCollection(LinkedHashSet::new)));
47 return new UnifiedDiscreteResources( 47 return new UnifiedDiscreteResources(
48 - NonEncodableDiscreteResources.of(partitioned.get(false)), 48 + GenericDiscreteResources.of(partitioned.get(false)),
49 EncodableDiscreteResources.of(partitioned.get(true)) 49 EncodableDiscreteResources.of(partitioned.get(true))
50 ); 50 );
51 } 51 }
52 52
53 - private UnifiedDiscreteResources(DiscreteResources nonEncodables, DiscreteResources encodables) { 53 + private UnifiedDiscreteResources(DiscreteResources generics, DiscreteResources encodables) {
54 - this.nonEncodables = nonEncodables; 54 + this.generics = generics;
55 this.encodables = encodables; 55 this.encodables = encodables;
56 } 56 }
57 57
...@@ -61,7 +61,7 @@ final class UnifiedDiscreteResources implements DiscreteResources { ...@@ -61,7 +61,7 @@ final class UnifiedDiscreteResources implements DiscreteResources {
61 return encodables.lookup(id); 61 return encodables.lookup(id);
62 } 62 }
63 63
64 - return nonEncodables.lookup(id); 64 + return generics.lookup(id);
65 } 65 }
66 66
67 @Override 67 @Override
...@@ -71,14 +71,14 @@ final class UnifiedDiscreteResources implements DiscreteResources { ...@@ -71,14 +71,14 @@ final class UnifiedDiscreteResources implements DiscreteResources {
71 71
72 @Override 72 @Override
73 public boolean isEmpty() { 73 public boolean isEmpty() {
74 - return nonEncodables.isEmpty() && encodables.isEmpty(); 74 + return generics.isEmpty() && encodables.isEmpty();
75 } 75 }
76 76
77 @Override 77 @Override
78 public boolean containsAny(List<DiscreteResource> other) { 78 public boolean containsAny(List<DiscreteResource> other) {
79 Map<Boolean, List<DiscreteResource>> partitioned = other.stream() 79 Map<Boolean, List<DiscreteResource>> partitioned = other.stream()
80 .collect(Collectors.partitioningBy(CODECS::isEncodable)); 80 .collect(Collectors.partitioningBy(CODECS::isEncodable));
81 - return nonEncodables.containsAny(partitioned.get(false)) || encodables.containsAny(partitioned.get(true)); 81 + return generics.containsAny(partitioned.get(false)) || encodables.containsAny(partitioned.get(true));
82 } 82 }
83 83
84 @Override 84 @Override
...@@ -93,7 +93,7 @@ final class UnifiedDiscreteResources implements DiscreteResources { ...@@ -93,7 +93,7 @@ final class UnifiedDiscreteResources implements DiscreteResources {
93 93
94 @Override 94 @Override
95 public Set<DiscreteResource> values() { 95 public Set<DiscreteResource> values() {
96 - return Stream.concat(encodables.values().stream(), nonEncodables.values().stream()) 96 + return Stream.concat(encodables.values().stream(), generics.values().stream())
97 .collect(Collectors.toCollection(LinkedHashSet::new)); 97 .collect(Collectors.toCollection(LinkedHashSet::new));
98 } 98 }
99 } 99 }
......