Refactor: Move logic for continuous resource to another method

Change-Id: I04136c933398891bf347f14874e93825ce3f2e33
diff --git a/core/store/dist/src/main/java/org/onosproject/store/newresource/impl/ConsistentResourceStore.java b/core/store/dist/src/main/java/org/onosproject/store/newresource/impl/ConsistentResourceStore.java
index 0e873ee..4b2608c 100644
--- a/core/store/dist/src/main/java/org/onosproject/store/newresource/impl/ConsistentResourceStore.java
+++ b/core/store/dist/src/main/java/org/onosproject/store/newresource/impl/ConsistentResourceStore.java
@@ -353,29 +353,29 @@
             // check if already consumed
             return getResourceAllocations(resource.id()).isEmpty();
         } else {
-            // check if it's registered or not.
-            Versioned<Set<Resource>> v = childMap.get(resource.parent().get().id());
-            if (v == null) {
-                return false;
-            }
-
-            ContinuousResource requested = (ContinuousResource) resource;
-            ContinuousResource registered = v.value().stream()
-                    .filter(c -> c.id().equals(resource.id()))
-                    .findFirst()
-                    .map(c -> (ContinuousResource) c)
-                    .get();
-            if (registered.value() < requested.value()) {
-                // Capacity < requested, can never satisfy
-                return false;
-            }
-            // check if there's enough left
-            return isAvailable(requested);
+            return isAvailable((ContinuousResource) resource);
         }
     }
 
     // computational complexity: O(n) where n is the number of existing allocations for the resource
     private boolean isAvailable(ContinuousResource resource) {
+        // check if it's registered or not.
+        Versioned<Set<Resource>> children = childMap.get(resource.parent().get().id());
+        if (children == null) {
+            return false;
+        }
+
+        ContinuousResource registered = children.value().stream()
+                .filter(c -> c.id().equals(resource.id()))
+                .findFirst()
+                .map(c -> (ContinuousResource) c)
+                .get();
+        if (registered.value() < resource.value()) {
+            // Capacity < requested, can never satisfy
+            return false;
+        }
+
+        // check if there's enough left
         Versioned<ContinuousResourceAllocation> allocation = continuousConsumers.get(resource.id());
         if (allocation == null) {
             // no allocation (=no consumer) full registered resources available