diff options
author | Ashlee Young <ashlee@wildernessvoice.com> | 2015-12-01 05:49:27 -0800 |
---|---|---|
committer | Ashlee Young <ashlee@wildernessvoice.com> | 2015-12-01 05:49:27 -0800 |
commit | e63291850fd0795c5700e25e67e5dee89ba54c5f (patch) | |
tree | 9707289536ad95bb739c9856761ad43275e07d8c /framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource | |
parent | 671823e12bc13be9a8b87a5d7de33da1bb7a44e8 (diff) |
onos commit hash c2999f30c69e50df905a9d175ef80b3f23a98514
Change-Id: I2bb8562c4942b6d6a6d60b663db2e17540477b81
Signed-off-by: Ashlee Young <ashlee@wildernessvoice.com>
Diffstat (limited to 'framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource')
2 files changed, 34 insertions, 23 deletions
diff --git a/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceAdminService.java b/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceAdminService.java index cdcd4072..28c429bd 100644 --- a/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceAdminService.java +++ b/framework/src/onos/core/api/src/main/java/org/onosproject/net/newresource/ResourceAdminService.java @@ -16,8 +16,8 @@ package org.onosproject.net.newresource; import com.google.common.annotations.Beta; +import com.google.common.collect.ImmutableList; -import java.util.Arrays; import java.util.List; /** @@ -26,50 +26,42 @@ import java.util.List; @Beta public interface ResourceAdminService { /** - * Registers resources as the children of the parent resource path. + * Registers the specified resources. * - * @param parent parent resource path under which the resource are registered - * @param children resources to be registered as the children of the parent - * @param <T> type of resources + * @param resources resources to be registered * @return true if registration is successfully done, false otherwise. Registration * succeeds when each resource is not registered or unallocated. */ - default <T> boolean registerResources(ResourcePath parent, T... children) { - return registerResources(parent, Arrays.asList(children)); + default boolean registerResources(ResourcePath... resources) { + return registerResources(ImmutableList.copyOf(resources)); } /** - * Registers resources as the children of the parent resource path. + * Registers the specified resources. * - * @param parent parent resource path under which the resource are registered - * @param children resources to be registered as the children of the parent - * @param <T> type of resources + * @param resources resources to be registered * @return true if registration is successfully done, false otherwise. Registration * succeeds when each resource is not registered or unallocated. */ - <T> boolean registerResources(ResourcePath parent, List<T> children); + boolean registerResources(List<ResourcePath> resources); /** - * Unregisters resources as the children of the parent resource path. + * Unregisters the specified resources. * - * @param parent parent resource path under which the resource are unregistered - * @param children resources to be unregistered as the children of the parent - * @param <T> type of resources + * @param resources resources to be unregistered * @return true if unregistration is successfully done, false otherwise. Unregistration * succeeds when each resource is not registered or unallocated. */ - default <T> boolean unregisterResources(ResourcePath parent, T... children) { - return unregisterResources(parent, Arrays.asList(children)); + default boolean unregisterResources(ResourcePath... resources) { + return unregisterResources(ImmutableList.copyOf(resources)); } /** - * Unregisters resources as the children of the parent resource path. + * Unregisters the specified resources. * - * @param parent parent resource path under which the resource are unregistered - * @param children resources to be unregistered as the children of the parent - * @param <T> type of resources + * @param resources resources to be unregistered * @return true if unregistration is successfully done, false otherwise. Unregistration * succeeds when each resource is not registered or unallocated. */ - <T> boolean unregisterResources(ResourcePath parent, List<T> children); + boolean unregisterResources(List<ResourcePath> resources); } 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 d87682a9..c0c4e34f 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 @@ -56,6 +56,7 @@ public abstract class ResourcePath { * 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. + * @return resource path instance */ public static ResourcePath discrete(Object... components) { if (components.length == 0) { @@ -70,6 +71,7 @@ public abstract class ResourcePath { * * @param value amount of the resource * @param components 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); @@ -141,12 +143,27 @@ public abstract class ResourcePath { return Optional.ofNullable(parent); } + /** + * Returns a child resource path of this instance with specifying the child object. + * The child resource path is discrete-type. + * + * @param child child object + * @return a child resource path + */ public ResourcePath child(Object child) { checkState(this instanceof Discrete); return new Discrete((Discrete) this, child); } + /** + * Returns a child resource path of this instance with specifying a child object and + * value. The child resource path is continuous-type. + * + * @param child child object + * @param value value + * @return a child resource path + */ public ResourcePath child(Object child, double value) { checkState(this instanceof Discrete); @@ -197,6 +214,7 @@ public abstract class ResourcePath { * implementation only. It is not for resource API user. * </p> */ + @Beta public static final class Discrete extends ResourcePath { private Discrete() { super(); @@ -218,6 +236,7 @@ public abstract class ResourcePath { * Note: This class is exposed to the public, but intended to be used in the resource API * implementation only. It is not for resource API user. */ + @Beta public static final class Continuous extends ResourcePath { // Note: value is not taken into account for equality private final double value; |