Refactor: Rename Resource#isTypeOf() to isSubTypeOf()
Change-Id: I83eed95d53ecc06cd14695cae22bd4e71646040a
diff --git a/core/api/src/main/java/org/onosproject/net/newresource/ContinuousResource.java b/core/api/src/main/java/org/onosproject/net/newresource/ContinuousResource.java
index b2e5395..e735768 100644
--- a/core/api/src/main/java/org/onosproject/net/newresource/ContinuousResource.java
+++ b/core/api/src/main/java/org/onosproject/net/newresource/ContinuousResource.java
@@ -73,12 +73,12 @@
}
@Override
- public boolean isTypeOf(Class<?> ancestorType) {
+ public boolean isSubTypeOf(Class<?> ancestor) {
String typeName = (String) id.components().get(id.components().size() - 1);
- boolean foundInLeaf = typeName.equals(ancestorType.getCanonicalName());
+ boolean foundInLeaf = typeName.equals(ancestor.getCanonicalName());
boolean foundInAncestor = id.components().subList(0, id.components().size()).stream()
.map(Object::getClass)
- .filter(x -> x.equals(ancestorType))
+ .filter(x -> x.equals(ancestor))
.findAny()
.isPresent();
return foundInAncestor || foundInLeaf;
diff --git a/core/api/src/main/java/org/onosproject/net/newresource/DiscreteResource.java b/core/api/src/main/java/org/onosproject/net/newresource/DiscreteResource.java
index c120e59..1509b8b 100644
--- a/core/api/src/main/java/org/onosproject/net/newresource/DiscreteResource.java
+++ b/core/api/src/main/java/org/onosproject/net/newresource/DiscreteResource.java
@@ -63,10 +63,10 @@
}
@Override
- public boolean isTypeOf(Class<?> ancestorType) {
+ public boolean isSubTypeOf(Class<?> ancestor) {
return id.components().stream()
.map(Object::getClass)
- .filter(x -> x.equals(ancestorType))
+ .filter(x -> x.equals(ancestor))
.findAny()
.isPresent();
}
diff --git a/core/api/src/main/java/org/onosproject/net/newresource/Resource.java b/core/api/src/main/java/org/onosproject/net/newresource/Resource.java
index 6e68404..1e3e61a 100644
--- a/core/api/src/main/java/org/onosproject/net/newresource/Resource.java
+++ b/core/api/src/main/java/org/onosproject/net/newresource/Resource.java
@@ -48,13 +48,12 @@
ResourceId id();
/**
- * Checks if the type of this instance is the specified type.
+ * Checks if the type of this instance is the sub-type of the specified type.
*
- * @param ancestorType type of resource to be checked.
+ * @param ancestor type of resource to be checked.
* @return true if this resource is under the resource whose type is the given type.
*/
- // TODO: find more proper name
- boolean isTypeOf(Class<?> ancestorType);
+ boolean isSubTypeOf(Class<?> ancestor);
/**
* Returns the volume of this resource.
diff --git a/core/api/src/test/java/org/onosproject/net/newresource/ResourceTest.java b/core/api/src/test/java/org/onosproject/net/newresource/ResourceTest.java
index 838c898..a92bbd6 100644
--- a/core/api/src/test/java/org/onosproject/net/newresource/ResourceTest.java
+++ b/core/api/src/test/java/org/onosproject/net/newresource/ResourceTest.java
@@ -90,18 +90,18 @@
}
@Test
- public void testTypeOf() {
+ public void testSubTypeOf() {
DiscreteResource discrete = Resources.discrete(D1, P1, VLAN1).resource();
- assertThat(discrete.isTypeOf(DeviceId.class), is(true));
- assertThat(discrete.isTypeOf(PortNumber.class), is(true));
- assertThat(discrete.isTypeOf(VlanId.class), is(true));
- assertThat(discrete.isTypeOf(Bandwidth.class), is(false));
+ assertThat(discrete.isSubTypeOf(DeviceId.class), is(true));
+ assertThat(discrete.isSubTypeOf(PortNumber.class), is(true));
+ assertThat(discrete.isSubTypeOf(VlanId.class), is(true));
+ assertThat(discrete.isSubTypeOf(Bandwidth.class), is(false));
ContinuousResource continuous = Resources.continuous(D1, P1, Bandwidth.class).resource(BW1.bps());
- assertThat(continuous.isTypeOf(DeviceId.class), is(true));
- assertThat(continuous.isTypeOf(PortNumber.class), is(true));
- assertThat(continuous.isTypeOf(Bandwidth.class), is(true));
- assertThat(continuous.isTypeOf(VlanId.class), is(false));
+ assertThat(continuous.isSubTypeOf(DeviceId.class), is(true));
+ assertThat(continuous.isSubTypeOf(PortNumber.class), is(true));
+ assertThat(continuous.isSubTypeOf(Bandwidth.class), is(true));
+ assertThat(continuous.isSubTypeOf(VlanId.class), is(false));
}
@Test
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/ObjectiveTracker.java b/core/net/src/main/java/org/onosproject/net/intent/impl/ObjectiveTracker.java
index 76e3ef6..5de3b32 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/ObjectiveTracker.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/ObjectiveTracker.java
@@ -302,7 +302,7 @@
private class InternalResourceListener implements ResourceListener {
@Override
public void event(ResourceEvent event) {
- if (event.subject().isTypeOf(PortNumber.class)) {
+ if (event.subject().isSubTypeOf(PortNumber.class)) {
executorService.execute(() -> {
if (delegate == null) {
return;