Sho SHIMIZU
Committed by Sho Shimizu

Move inner classes to upper level

Rename as follows.
- ResourceId.Discrete -> DiscreteResourceId
- ResourceId.Continuous -> ContinuousResourceId
- Resource.Discrete -> DiscreteResource
- Resource.Continuous -> ContinuousResource

Change-Id: I80e59d1eec07128743bacc582a8725bd4d5489b4
...@@ -34,6 +34,7 @@ import org.onosproject.cli.AbstractShellCommand; ...@@ -34,6 +34,7 @@ import org.onosproject.cli.AbstractShellCommand;
34 import org.onosproject.net.DeviceId; 34 import org.onosproject.net.DeviceId;
35 import org.onosproject.net.PortNumber; 35 import org.onosproject.net.PortNumber;
36 import org.onosproject.net.TributarySlot; 36 import org.onosproject.net.TributarySlot;
37 +import org.onosproject.net.newresource.ContinuousResource;
37 import org.onosproject.net.newresource.Resource; 38 import org.onosproject.net.newresource.Resource;
38 import org.onosproject.net.newresource.ResourceService; 39 import org.onosproject.net.newresource.ResourceService;
39 40
...@@ -112,10 +113,10 @@ public class ResourcesCommand extends AbstractShellCommand { ...@@ -112,10 +113,10 @@ public class ResourcesCommand extends AbstractShellCommand {
112 return; 113 return;
113 } 114 }
114 115
115 - if (resource instanceof Resource.Continuous) { 116 + if (resource instanceof ContinuousResource) {
116 print("%s%s: %f", Strings.repeat(" ", level), 117 print("%s%s: %f", Strings.repeat(" ", level),
117 resource.last(), 118 resource.last(),
118 - ((Resource.Continuous) resource).value()); 119 + ((ContinuousResource) resource).value());
119 // Continuous resource is terminal node, stop here 120 // Continuous resource is terminal node, stop here
120 return; 121 return;
121 } else { 122 } else {
...@@ -144,7 +145,7 @@ public class ResourcesCommand extends AbstractShellCommand { ...@@ -144,7 +145,7 @@ public class ResourcesCommand extends AbstractShellCommand {
144 List<Resource> nonAggregatable = new ArrayList<>(); 145 List<Resource> nonAggregatable = new ArrayList<>();
145 146
146 for (Resource r : children) { 147 for (Resource r : children) {
147 - if (r instanceof Resource.Continuous) { 148 + if (r instanceof ContinuousResource) {
148 // non-aggregatable terminal node 149 // non-aggregatable terminal node
149 nonAggregatable.add(r); 150 nonAggregatable.add(r);
150 } else if (aggregatableTypes.contains(r.last().getClass())) { 151 } else if (aggregatableTypes.contains(r.last().getClass())) {
......
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.net.newresource;
17 +
18 +import com.google.common.annotations.Beta;
19 +
20 +import java.util.Objects;
21 +
22 +/**
23 + * Represents a resource path which specifies a resource which can be measured
24 + * as continuous value. Bandwidth of a link is an example of the resource.
25 + * <p>
26 + * Note: This class is exposed to the public, but intended to be used in the resource API
27 + * implementation only. It is not for resource API user.
28 + */
29 +@Beta
30 +// TODO: consider how to restrict the visibility
31 +public final class ContinuousResource extends Resource {
32 + private final double value;
33 +
34 + ContinuousResource(ResourceId id, double value) {
35 + super(id);
36 + this.value = value;
37 + }
38 +
39 + /**
40 + * The user of this methods must receive the return value as Double or double.
41 + * Otherwise, this methods throws an exception.
42 + *
43 + * @param <T> type of the return value
44 + * @return the volume of this resource
45 + */
46 + @SuppressWarnings("unchecked")
47 + @Override
48 + public <T> T volume() {
49 + return (T) Double.valueOf(value);
50 + }
51 +
52 + @Override
53 + public int hashCode() {
54 + return Objects.hash(id(), value);
55 + }
56 +
57 + @Override
58 + public boolean equals(Object obj) {
59 + if (this == obj) {
60 + return true;
61 + }
62 + if (obj == null || getClass() != obj.getClass()) {
63 + return false;
64 + }
65 + final ContinuousResource other = (ContinuousResource) obj;
66 + return Objects.equals(this.id(), other.id())
67 + && Objects.equals(this.value, other.value);
68 + }
69 +
70 + /**
71 + * Returns the value of the resource amount.
72 + *
73 + * @return the value of the resource amount
74 + */
75 + // FIXME: overlapping a purpose with volume()
76 + public double value() {
77 + return value;
78 + }
79 +}
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.net.newresource;
17 +
18 +import com.google.common.annotations.Beta;
19 +import com.google.common.collect.ImmutableList;
20 +
21 +import static com.google.common.base.Preconditions.checkNotNull;
22 +
23 +/**
24 + * ResourceId for {@link ContinuousResource}
25 + *
26 + * Note: This class is exposed to the public, but intended to be used in the resource API
27 + * implementation only. It is not for resource API user.
28 + */
29 +@Beta
30 +// TODO: consider how to restrict the visibility
31 +public final class ContinuousResourceId extends ResourceId {
32 + // for printing purpose only (used in toString() implementation)
33 + private final String name;
34 +
35 + ContinuousResourceId(ImmutableList<Object> components, String name) {
36 + super(components);
37 + this.name = checkNotNull(name);
38 + }
39 +
40 + @Override
41 + public String toString() {
42 + // due to performance consideration, the value might need to be stored in a field
43 + return ImmutableList.builder()
44 + .addAll(components.subList(0, components.size() - 1))
45 + .add(name)
46 + .build().toString();
47 + }
48 +}
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.net.newresource;
17 +
18 +import com.google.common.annotations.Beta;
19 +
20 +import java.util.Objects;
21 +
22 +/**
23 + * Represents a resource path which specifies a resource which can be measured
24 + * as a discrete unit. A VLAN ID and a MPLS label of a link are examples of the resource.
25 + * <p>
26 + * Note: This class is exposed to the public, but intended to be used in the resource API
27 + * implementation only. It is not for resource API user.
28 + * </p>
29 + */
30 +@Beta
31 +// TODO: consider how to restrict the visibility
32 +public final class DiscreteResource extends Resource {
33 + protected DiscreteResource() {
34 + super();
35 + }
36 +
37 + DiscreteResource(ResourceId id) {
38 + super(id);
39 + }
40 +
41 + /**
42 + * The user of this methods must receive the return value as the correct type.
43 + * Otherwise, this methods throws an exception.
44 + *
45 + * @param <T> type of the return value
46 + * @return the volume of this resource
47 + */
48 + @SuppressWarnings("unchecked")
49 + @Override
50 + // TODO: consider receiving Class<T> as an argument. Which approach is convenient?
51 + public <T> T volume() {
52 + return (T) last();
53 + }
54 +
55 + @Override
56 + public int hashCode() {
57 + // the value returing from volume() is excluded due to optimization
58 + return id().hashCode();
59 + }
60 +
61 + @Override
62 + public boolean equals(Object obj) {
63 + if (this == obj) {
64 + return true;
65 + }
66 + if (obj == null || getClass() != obj.getClass()) {
67 + return false;
68 + }
69 + final DiscreteResource other = (DiscreteResource) obj;
70 + // the value returing from volume() is excluded due to optimization
71 + return Objects.equals(this.id(), other.id());
72 + }
73 +}
1 +/*
2 + * Copyright 2016 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.net.newresource;
17 +
18 +import com.google.common.annotations.Beta;
19 +import com.google.common.collect.ImmutableList;
20 +
21 +/**
22 + * ResourceId for {@link DiscreteResource}.
23 + *
24 + * Note: This class is exposed to the public, but intended to be used in the resource API
25 + * implementation only. It is not for resource API user.
26 + */
27 +@Beta
28 +// TODO: consider how to restrict the visibility
29 +public final class DiscreteResourceId extends ResourceId {
30 + DiscreteResourceId(ImmutableList<Object> components) {
31 + super(components);
32 + }
33 +
34 + DiscreteResourceId() {
35 + super();
36 + }
37 +}
...@@ -21,7 +21,6 @@ import org.onosproject.net.DeviceId; ...@@ -21,7 +21,6 @@ import org.onosproject.net.DeviceId;
21 import org.onosproject.net.PortNumber; 21 import org.onosproject.net.PortNumber;
22 22
23 import java.util.List; 23 import java.util.List;
24 -import java.util.Objects;
25 import java.util.Optional; 24 import java.util.Optional;
26 25
27 import static com.google.common.base.Preconditions.checkArgument; 26 import static com.google.common.base.Preconditions.checkArgument;
...@@ -47,13 +46,13 @@ import static com.google.common.base.Preconditions.checkState; ...@@ -47,13 +46,13 @@ import static com.google.common.base.Preconditions.checkState;
47 @Beta 46 @Beta
48 public abstract class Resource { 47 public abstract class Resource {
49 48
50 - private final Discrete parent; 49 + private final DiscreteResource parent;
51 private final ResourceId id; 50 private final ResourceId id;
52 51
53 - public static final Discrete ROOT = new Discrete(); 52 + public static final DiscreteResource ROOT = new DiscreteResource();
54 53
55 public static Resource discrete(DeviceId device) { 54 public static Resource discrete(DeviceId device) {
56 - return new Discrete(ResourceId.discrete(device)); 55 + return new DiscreteResource(ResourceId.discrete(device));
57 } 56 }
58 57
59 /** 58 /**
...@@ -64,7 +63,7 @@ public abstract class Resource { ...@@ -64,7 +63,7 @@ public abstract class Resource {
64 * @return resource path instance 63 * @return resource path instance
65 */ 64 */
66 public static Resource discrete(DeviceId device, Object... components) { 65 public static Resource discrete(DeviceId device, Object... components) {
67 - return new Discrete(ResourceId.discrete(device, components)); 66 + return new DiscreteResource(ResourceId.discrete(device, components));
68 } 67 }
69 68
70 /** 69 /**
...@@ -76,7 +75,7 @@ public abstract class Resource { ...@@ -76,7 +75,7 @@ public abstract class Resource {
76 * @return resource path instance 75 * @return resource path instance
77 */ 76 */
78 public static Resource discrete(DeviceId device, PortNumber port, Object... components) { 77 public static Resource discrete(DeviceId device, PortNumber port, Object... components) {
79 - return new Discrete(ResourceId.discrete(device, port, components)); 78 + return new DiscreteResource(ResourceId.discrete(device, port, components));
80 } 79 }
81 80
82 /** 81 /**
...@@ -93,7 +92,7 @@ public abstract class Resource { ...@@ -93,7 +92,7 @@ public abstract class Resource {
93 checkArgument(components.length > 0, 92 checkArgument(components.length > 0,
94 "Length of components must be greater thant 0, but " + components.length); 93 "Length of components must be greater thant 0, but " + components.length);
95 94
96 - return new Continuous(ResourceId.continuous(device, components), value); 95 + return new ContinuousResource(ResourceId.continuous(device, components), value);
97 } 96 }
98 97
99 /** 98 /**
...@@ -108,7 +107,7 @@ public abstract class Resource { ...@@ -108,7 +107,7 @@ public abstract class Resource {
108 * @return resource path instance 107 * @return resource path instance
109 */ 108 */
110 public static Resource continuous(double value, DeviceId device, PortNumber port, Object... components) { 109 public static Resource continuous(double value, DeviceId device, PortNumber port, Object... components) {
111 - return new Continuous(ResourceId.continuous(device, port, components), value); 110 + return new ContinuousResource(ResourceId.continuous(device, port, components), value);
112 } 111 }
113 112
114 /** 113 /**
...@@ -123,12 +122,12 @@ public abstract class Resource { ...@@ -123,12 +122,12 @@ public abstract class Resource {
123 if (id.components.size() == 1) { 122 if (id.components.size() == 1) {
124 this.parent = ROOT; 123 this.parent = ROOT;
125 } else { 124 } else {
126 - this.parent = new Discrete(id.parent()); 125 + this.parent = new DiscreteResource(id.parent());
127 } 126 }
128 } 127 }
129 128
130 // for serialization 129 // for serialization
131 - private Resource() { 130 + protected Resource() {
132 this.parent = null; 131 this.parent = null;
133 this.id = ResourceId.ROOT; 132 this.id = ResourceId.ROOT;
134 } 133 }
...@@ -157,7 +156,7 @@ public abstract class Resource { ...@@ -157,7 +156,7 @@ public abstract class Resource {
157 * @return the parent resource path of this instance. 156 * @return the parent resource path of this instance.
158 * If there is no parent, empty instance will be returned. 157 * If there is no parent, empty instance will be returned.
159 */ 158 */
160 - public Optional<Discrete> parent() { 159 + public Optional<DiscreteResource> parent() {
161 return Optional.ofNullable(parent); 160 return Optional.ofNullable(parent);
162 } 161 }
163 162
...@@ -169,9 +168,9 @@ public abstract class Resource { ...@@ -169,9 +168,9 @@ public abstract class Resource {
169 * @return a child resource path 168 * @return a child resource path
170 */ 169 */
171 public Resource child(Object child) { 170 public Resource child(Object child) {
172 - checkState(this instanceof Discrete); 171 + checkState(this instanceof DiscreteResource);
173 172
174 - return new Discrete(id().child(child)); 173 + return new DiscreteResource(id().child(child));
175 } 174 }
176 175
177 /** 176 /**
...@@ -183,9 +182,9 @@ public abstract class Resource { ...@@ -183,9 +182,9 @@ public abstract class Resource {
183 * @return a child resource path 182 * @return a child resource path
184 */ 183 */
185 public Resource child(Object child, double value) { 184 public Resource child(Object child, double value) {
186 - checkState(this instanceof Discrete); 185 + checkState(this instanceof DiscreteResource);
187 186
188 - return new Continuous(id.child(child), value); 187 + return new ContinuousResource(id.child(child), value);
189 } 188 }
190 189
191 /** 190 /**
...@@ -218,114 +217,4 @@ public abstract class Resource { ...@@ -218,114 +217,4 @@ public abstract class Resource {
218 .toString(); 217 .toString();
219 } 218 }
220 219
221 - /**
222 - * Represents a resource path which specifies a resource which can be measured
223 - * as a discrete unit. A VLAN ID and a MPLS label of a link are examples of the resource.
224 - * <p>
225 - * Note: This class is exposed to the public, but intended to be used in the resource API
226 - * implementation only. It is not for resource API user.
227 - * </p>
228 - */
229 - @Beta
230 - public static final class Discrete extends Resource {
231 - private Discrete() {
232 - super();
233 - }
234 -
235 - private Discrete(ResourceId id) {
236 - super(id);
237 - }
238 -
239 - /**
240 - * The user of this methods must receive the return value as the correct type.
241 - * Otherwise, this methods throws an exception.
242 - *
243 - * @param <T> type of the return value
244 - * @return the volume of this resource
245 - */
246 - @SuppressWarnings("unchecked")
247 - @Override
248 - // TODO: consider receiving Class<T> as an argument. Which approach is convenient?
249 - public <T> T volume() {
250 - return (T) last();
251 - }
252 -
253 - @Override
254 - public int hashCode() {
255 - // the value returing from volume() is excluded due to optimization
256 - return id().hashCode();
257 - }
258 -
259 - @Override
260 - public boolean equals(Object obj) {
261 - if (this == obj) {
262 - return true;
263 - }
264 - if (obj == null || getClass() != obj.getClass()) {
265 - return false;
266 - }
267 - final Discrete other = (Discrete) obj;
268 - // the value returing from volume() is excluded due to optimization
269 - return Objects.equals(this.id(), other.id());
270 - }
271 - }
272 -
273 - /**
274 - * Represents a resource path which specifies a resource which can be measured
275 - * as continuous value. Bandwidth of a link is an example of the resource.
276 - * <p>
277 - * Note: This class is exposed to the public, but intended to be used in the resource API
278 - * implementation only. It is not for resource API user.
279 - */
280 - @Beta
281 - public static final class Continuous extends Resource {
282 - private final double value;
283 -
284 - private Continuous(ResourceId id, double value) {
285 - super(id);
286 - this.value = value;
287 - }
288 -
289 - /**
290 - * The user of this methods must receive the return value as Double or double.
291 - * Otherwise, this methods throws an exception.
292 - *
293 - * @param <T> type of the return value
294 - * @return the volume of this resource
295 - */
296 - @SuppressWarnings("unchecked")
297 - @Override
298 - public <T> T volume() {
299 - return (T) Double.valueOf(value);
300 - }
301 -
302 - @Override
303 - public int hashCode() {
304 - return Objects.hash(id(), value);
305 - }
306 -
307 - @Override
308 - public boolean equals(Object obj) {
309 - if (this == obj) {
310 - return true;
311 - }
312 - if (obj == null || getClass() != obj.getClass()) {
313 - return false;
314 - }
315 - final Continuous other = (Continuous) obj;
316 - return Objects.equals(this.id(), other.id())
317 - && Objects.equals(this.value, other.value);
318 - }
319 -
320 - /**
321 - * Returns the value of the resource amount.
322 - *
323 - * @return the value of the resource amount
324 - */
325 - // FIXME: overlapping a purpose with volume()
326 - public double value() {
327 - return value;
328 - }
329 - }
330 -
331 } 220 }
......
...@@ -33,19 +33,19 @@ import static com.google.common.base.Preconditions.checkState; ...@@ -33,19 +33,19 @@ import static com.google.common.base.Preconditions.checkState;
33 */ 33 */
34 @Beta 34 @Beta
35 public abstract class ResourceId { 35 public abstract class ResourceId {
36 - static final ResourceId ROOT = new Discrete(); 36 + static final ResourceId ROOT = new DiscreteResourceId();
37 37
38 final ImmutableList<Object> components; 38 final ImmutableList<Object> components;
39 39
40 static ResourceId discrete(DeviceId device, Object... components) { 40 static ResourceId discrete(DeviceId device, Object... components) {
41 - return new Discrete(ImmutableList.builder() 41 + return new DiscreteResourceId(ImmutableList.builder()
42 .add(device) 42 .add(device)
43 .add(components) 43 .add(components)
44 .build()); 44 .build());
45 } 45 }
46 46
47 static ResourceId discrete(DeviceId device, PortNumber port, Object... components) { 47 static ResourceId discrete(DeviceId device, PortNumber port, Object... components) {
48 - return new Discrete(ImmutableList.builder() 48 + return new DiscreteResourceId(ImmutableList.builder()
49 .add(device) 49 .add(device)
50 .add(port) 50 .add(port)
51 .add(components) 51 .add(components)
...@@ -72,17 +72,17 @@ public abstract class ResourceId { ...@@ -72,17 +72,17 @@ public abstract class ResourceId {
72 } 72 }
73 73
74 private static ResourceId continuous(ImmutableList.Builder<Object> parentComponents, Class<?> last) { 74 private static ResourceId continuous(ImmutableList.Builder<Object> parentComponents, Class<?> last) {
75 - return new Continuous(parentComponents 75 + return new ContinuousResourceId(parentComponents
76 .add(last.getCanonicalName()) 76 .add(last.getCanonicalName())
77 .build(), last.getSimpleName()); 77 .build(), last.getSimpleName());
78 } 78 }
79 79
80 - private ResourceId(ImmutableList<Object> components) { 80 + protected ResourceId(ImmutableList<Object> components) {
81 this.components = checkNotNull(components); 81 this.components = checkNotNull(components);
82 } 82 }
83 83
84 // for serializer 84 // for serializer
85 - private ResourceId() { 85 + protected ResourceId() {
86 this.components = ImmutableList.of(); 86 this.components = ImmutableList.of();
87 } 87 }
88 88
...@@ -91,27 +91,27 @@ public abstract class ResourceId { ...@@ -91,27 +91,27 @@ public abstract class ResourceId {
91 if (components.size() == 1) { 91 if (components.size() == 1) {
92 return ROOT; 92 return ROOT;
93 } else { 93 } else {
94 - return new Discrete(components.subList(0, components.size() - 1)); 94 + return new DiscreteResourceId(components.subList(0, components.size() - 1));
95 } 95 }
96 } 96 }
97 97
98 /** 98 /**
99 * Returns a resource ID of a child of this resource based on the specified object. 99 * Returns a resource ID of a child of this resource based on the specified object.
100 * If the argument is an instance of {@link Class}, this method returns an instance of 100 * If the argument is an instance of {@link Class}, this method returns an instance of
101 - * {@link Continuous}. Otherwise, it returns an instance of {@link Discrete} 101 + * {@link ContinuousResourceId}. Otherwise, it returns an instance of {@link DiscreteResourceId}
102 - * This method only work when the receiver is {@link Discrete}. Otherwise, 102 + * This method only work when the receiver is {@link DiscreteResourceId}. Otherwise,
103 * this method throws an exception. 103 * this method throws an exception.
104 * 104 *
105 * @param child the last component of the child 105 * @param child the last component of the child
106 * @return a child resource ID 106 * @return a child resource ID
107 */ 107 */
108 public ResourceId child(Object child) { 108 public ResourceId child(Object child) {
109 - checkState(this instanceof Discrete); 109 + checkState(this instanceof DiscreteResourceId);
110 110
111 if (child instanceof Class<?>) { 111 if (child instanceof Class<?>) {
112 return continuous(ImmutableList.builder().addAll(components), (Class<?>) child); 112 return continuous(ImmutableList.builder().addAll(components), (Class<?>) child);
113 } else { 113 } else {
114 - return new Discrete(ImmutableList.builder() 114 + return new DiscreteResourceId(ImmutableList.builder()
115 .addAll(components) 115 .addAll(components)
116 .add(child) 116 .add(child)
117 .build()); 117 .build());
...@@ -140,44 +140,4 @@ public abstract class ResourceId { ...@@ -140,44 +140,4 @@ public abstract class ResourceId {
140 return components.toString(); 140 return components.toString();
141 } 141 }
142 142
143 - /**
144 - * ResourceId for {@link Resource.Discrete}.
145 - *
146 - * Note: This class is exposed to the public, but intended to be used in the resource API
147 - * implementation only. It is not for resource API user.
148 - */
149 - public static final class Discrete extends ResourceId {
150 - private Discrete(ImmutableList<Object> components) {
151 - super(components);
152 - }
153 -
154 - private Discrete() {
155 - super();
156 - }
157 - }
158 -
159 - /**
160 - * ResourceId for {@link Resource.Continuous}
161 - *
162 - * Note: This class is exposed to the public, but intended to be used in the resource API
163 - * implementation only. It is not for resource API user.
164 - */
165 - public static final class Continuous extends ResourceId {
166 - // for printing purpose only (used in toString() implementation)
167 - private final String name;
168 -
169 - private Continuous(ImmutableList<Object> components, String name) {
170 - super(components);
171 - this.name = checkNotNull(name);
172 - }
173 -
174 - @Override
175 - public String toString() {
176 - // due to performance consideration, the value might need to be stored in a field
177 - return ImmutableList.builder()
178 - .addAll(components.subList(0, components.size() - 1))
179 - .add(name)
180 - .build().toString();
181 - }
182 - }
183 } 143 }
......
...@@ -172,6 +172,10 @@ import org.onosproject.net.intent.constraint.PartialFailureConstraint; ...@@ -172,6 +172,10 @@ import org.onosproject.net.intent.constraint.PartialFailureConstraint;
172 import org.onosproject.net.intent.constraint.WaypointConstraint; 172 import org.onosproject.net.intent.constraint.WaypointConstraint;
173 import org.onosproject.net.link.DefaultLinkDescription; 173 import org.onosproject.net.link.DefaultLinkDescription;
174 import org.onosproject.net.meter.MeterId; 174 import org.onosproject.net.meter.MeterId;
175 +import org.onosproject.net.newresource.ContinuousResource;
176 +import org.onosproject.net.newresource.ContinuousResourceId;
177 +import org.onosproject.net.newresource.DiscreteResource;
178 +import org.onosproject.net.newresource.DiscreteResourceId;
175 import org.onosproject.net.newresource.ResourceAllocation; 179 import org.onosproject.net.newresource.ResourceAllocation;
176 import org.onosproject.net.newresource.ResourceId; 180 import org.onosproject.net.newresource.ResourceId;
177 import org.onosproject.net.newresource.Resource; 181 import org.onosproject.net.newresource.Resource;
...@@ -434,11 +438,11 @@ public final class KryoNamespaces { ...@@ -434,11 +438,11 @@ public final class KryoNamespaces {
434 BandwidthResourceAllocation.class, 438 BandwidthResourceAllocation.class,
435 LambdaResourceAllocation.class, 439 LambdaResourceAllocation.class,
436 Resource.class, 440 Resource.class,
437 - Resource.Discrete.class, 441 + DiscreteResource.class,
438 - Resource.Continuous.class, 442 + ContinuousResource.class,
439 ResourceId.class, 443 ResourceId.class,
440 - ResourceId.Discrete.class, 444 + DiscreteResourceId.class,
441 - ResourceId.Continuous.class, 445 + ContinuousResourceId.class,
442 ResourceAllocation.class, 446 ResourceAllocation.class,
443 // Constraints 447 // Constraints
444 LambdaConstraint.class, 448 LambdaConstraint.class,
......