Check preconditions when registering/unregistering resources
Change-Id: Ibe7897fcdef791fb83eb6521c5e48e795612f8f5
diff --git a/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceManager.java b/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceManager.java
index abce072..b8c31a4 100644
--- a/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceManager.java
+++ b/core/net/src/main/java/org/onosproject/net/newresource/impl/ResourceManager.java
@@ -35,6 +35,7 @@
import java.util.Optional;
import java.util.stream.Collectors;
+import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
/**
@@ -127,12 +128,20 @@
@Override
public <T> boolean registerResources(ResourcePath parent, List<T> children) {
+ checkNotNull(parent);
+ checkNotNull(children);
+ checkArgument(!children.isEmpty());
+
List<ResourcePath> resources = Lists.transform(children, x -> ResourcePath.child(parent, x));
return store.register(parent, resources);
}
@Override
public <T> boolean unregisterResources(ResourcePath parent, List<T> children) {
+ checkNotNull(parent);
+ checkNotNull(children);
+ checkArgument(!children.isEmpty());
+
List<ResourcePath> resources = Lists.transform(children, x -> ResourcePath.child(parent, x));
return store.unregister(parent, resources);
}