diff options
author | Ashlee Young <ashlee@wildernessvoice.com> | 2015-12-06 07:15:03 -0800 |
---|---|---|
committer | Ashlee Young <ashlee@wildernessvoice.com> | 2015-12-08 10:55:21 -0800 |
commit | 76dc892491948adae5e5e62cf94448967e8d865b (patch) | |
tree | 7a33ef05cc583946db21edad627060f280a53549 /framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourcePath.java | |
parent | d333c63fdec8b064184b0a26f8d777f267577fde (diff) |
Fixes bad POM file with ONOS commit 8c68536972f63069c263635c9d9f4f31d7f3e9a2
Change-Id: I7adb5a2d3738d53dbc41db7577768b0e7ced5450
Signed-off-by: Ashlee Young <ashlee@wildernessvoice.com>
Diffstat (limited to 'framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourcePath.java')
-rw-r--r-- | framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourcePath.java | 74 |
1 files changed, 60 insertions, 14 deletions
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourcePath.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourcePath.java index c0c4e34f..72f8ac01 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourcePath.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourcePath.java @@ -18,6 +18,8 @@ package org.onosproject.net.newresource; import com.google.common.annotations.Beta; import com.google.common.base.MoreObjects; import com.google.common.collect.ImmutableList; +import org.onosproject.net.DeviceId; +import org.onosproject.net.PortNumber; import java.util.LinkedList; import java.util.List; @@ -41,8 +43,8 @@ import static com.google.common.base.Preconditions.checkState; * A double value is associated with a continuous type value. * * Users of this class must keep the semantics of resources regarding the hierarchical structure. - * For example, resource path, Link:1/VLAN ID:100, is valid, but resource path, VLAN ID:100/Link:1 - * is not valid because a link is not a sub-component of a VLAN ID. + * For example, resource path, Device:1/Port:1/VLAN ID:100, is valid, but resource path, + * VLAN ID:100/Device:1/Port:1 is not valid because a link is not a sub-component of a VLAN ID. */ @Beta public abstract class ResourcePath { @@ -52,29 +54,73 @@ public abstract class ResourcePath { public static final Discrete ROOT = new Discrete(); + public static ResourcePath discrete(DeviceId device) { + return new Discrete(ImmutableList.of(device)); + } + /** * Creates an resource path which represents a discrete-type resource from the specified components. * - * @param components components of the path. The order represents hierarchical structure of the resource. + * @param device device ID which is the first component of the path + * @param components following components of the path. The order represents hierarchical structure of the resource. * @return resource path instance */ - public static ResourcePath discrete(Object... components) { - if (components.length == 0) { - return ROOT; - } else { - return new Discrete(ImmutableList.copyOf(components)); - } + public static ResourcePath discrete(DeviceId device, Object... components) { + return new Discrete(ImmutableList.builder() + .add(device) + .add(components) + .build()); + } + + /** + * Creates an resource path which represents a discrete-type resource from the specified components. + * + * @param device device ID which is the first component of the path + * @param port port number which is the second component of the path + * @param components following components of the path. The order represents hierarchical structure of the resource. + * @return resource path instance + */ + public static ResourcePath discrete(DeviceId device, PortNumber port, Object... components) { + return new Discrete(ImmutableList.builder() + .add(device) + .add(port) + .add(components) + .build()); } /** * Creates an resource path which represents a continuous-type resource from the specified components. * * @param value amount of the resource - * @param components components of the path. The order represents hierarchical structure of the resource. + * @param device device ID which is the first component of the path + * @param components following components of the path. The order represents hierarchical structure of the resource. + * @return resource path instance + */ + public static ResourcePath continuous(double value, DeviceId device, Object... components) { + checkArgument(components.length > 0, + "Length of components must be greater thant 0, but " + components.length); + + return new Continuous(ImmutableList.builder() + .add(device) + .add(components) + .build(), value); + } + + /** + * Creates an resource path which represents a continuous-type resource from the specified components. + * + * @param value amount of the resource + * @param device device ID which is the first component of the path. + * @param port port number which is the second component of the path. + * @param components following components of the path. The order represents hierarchical structure of the resource. * @return resource path instance */ - public static ResourcePath continuous(double value, Object... components) { - return new Continuous(ImmutableList.copyOf(components), value); + public static ResourcePath continuous(double value, DeviceId device, PortNumber port, Object... components) { + return new Continuous(ImmutableList.builder() + .add(device) + .add(port) + .add(components) + .build(), value); } /** @@ -82,7 +128,7 @@ public abstract class ResourcePath { * * @param components components of the path. The order represents hierarchical structure of the resource. */ - ResourcePath(List<Object> components) { + protected ResourcePath(List<Object> components) { checkNotNull(components); checkArgument(!components.isEmpty()); @@ -101,7 +147,7 @@ public abstract class ResourcePath { * @param parent the parent of this resource * @param last a child of the parent */ - ResourcePath(Discrete parent, Object last) { + protected ResourcePath(Discrete parent, Object last) { checkNotNull(parent); checkNotNull(last); |