Define valueAs() to get the enclosed value and remove volume()

volume() is replaced by valueAs()

Change-Id: I3dbcbd6a0b8fcd28f0064272fe1fa6d7259e0a87
diff --git a/cli/src/main/java/org/onosproject/cli/net/ResourcesCommand.java b/cli/src/main/java/org/onosproject/cli/net/ResourcesCommand.java
index 3b8ca89..49a56c5 100644
--- a/cli/src/main/java/org/onosproject/cli/net/ResourcesCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/ResourcesCommand.java
@@ -128,7 +128,7 @@
             } else {
                 String resourceName = resource.last().getClass().getSimpleName();
 
-                String toString = String.valueOf(resource.last());
+                String toString = String.valueOf(resource.valueAs(Object.class).orElse(""));
                 if (toString.startsWith(resourceName)) {
                     print("%s%s", Strings.repeat(" ", level),
                           toString);
@@ -178,14 +178,13 @@
 
                 // aggregate into RangeSet
                 e.getValue().stream()
-                    .map(Resource::last)
                     .map(res -> {
-                            if (res instanceof VlanId) {
-                                return (long) ((VlanId) res).toShort();
-                            } else if (res instanceof MplsLabel) {
-                                return (long) ((MplsLabel) res).toInt();
-                            } else if (res instanceof TributarySlot) {
-                                return ((TributarySlot) res).index();
+                            if (res.isTypeOf(VlanId.class)) {
+                                return (long) res.valueAs(VlanId.class).get().toShort();
+                            } else if (res.isTypeOf(MplsLabel.class)) {
+                                return (long) res.valueAs(MplsLabel.class).get().toInt();
+                            } else if (res.isTypeOf(TributarySlot.class)) {
+                                return res.valueAs(TributarySlot.class).get().index();
                             }
                             // TODO support Lambda (OchSignal types)
                             return 0L;