Move inner classes to upper level

Rename as follows.
- ResourceId.Discrete -> DiscreteResourceId
- ResourceId.Continuous -> ContinuousResourceId
- Resource.Discrete -> DiscreteResource
- Resource.Continuous -> ContinuousResource

Change-Id: I80e59d1eec07128743bacc582a8725bd4d5489b4
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
new file mode 100644
index 0000000..b0573dc
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/newresource/ContinuousResource.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.net.newresource;
+
+import com.google.common.annotations.Beta;
+
+import java.util.Objects;
+
+/**
+ * Represents a resource path which specifies a resource which can be measured
+ * as continuous value. Bandwidth of a link is an example of the resource.
+ * <p>
+ * 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
+// TODO: consider how to restrict the visibility
+public final class ContinuousResource extends Resource {
+    private final double value;
+
+    ContinuousResource(ResourceId id, double value) {
+        super(id);
+        this.value = value;
+    }
+
+    /**
+     * The user of this methods must receive the return value as Double or double.
+     * Otherwise, this methods throws an exception.
+     *
+     * @param <T> type of the return value
+     * @return the volume of this resource
+     */
+    @SuppressWarnings("unchecked")
+    @Override
+    public <T> T volume() {
+        return (T) Double.valueOf(value);
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(id(), value);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null || getClass() != obj.getClass()) {
+            return false;
+        }
+        final ContinuousResource other = (ContinuousResource) obj;
+        return Objects.equals(this.id(), other.id())
+                && Objects.equals(this.value, other.value);
+    }
+
+    /**
+     * Returns the value of the resource amount.
+     *
+     * @return the value of the resource amount
+     */
+    // FIXME: overlapping a purpose with volume()
+    public double value() {
+        return value;
+    }
+}
diff --git a/core/api/src/main/java/org/onosproject/net/newresource/ContinuousResourceId.java b/core/api/src/main/java/org/onosproject/net/newresource/ContinuousResourceId.java
new file mode 100644
index 0000000..cd25a92
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/newresource/ContinuousResourceId.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.net.newresource;
+
+import com.google.common.annotations.Beta;
+import com.google.common.collect.ImmutableList;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * ResourceId for {@link ContinuousResource}
+ *
+ * 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
+// TODO: consider how to restrict the visibility
+public final class ContinuousResourceId extends ResourceId {
+    // for printing purpose only (used in toString() implementation)
+    private final String name;
+
+    ContinuousResourceId(ImmutableList<Object> components, String name) {
+        super(components);
+        this.name = checkNotNull(name);
+    }
+
+    @Override
+    public String toString() {
+        // due to performance consideration, the value might need to be stored in a field
+        return ImmutableList.builder()
+                .addAll(components.subList(0, components.size() - 1))
+                .add(name)
+                .build().toString();
+    }
+}
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
new file mode 100644
index 0000000..9efbbd1
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/newresource/DiscreteResource.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.net.newresource;
+
+import com.google.common.annotations.Beta;
+
+import java.util.Objects;
+
+/**
+ * Represents a resource path which specifies a resource which can be measured
+ * as a discrete unit. A VLAN ID and a MPLS label of a link are examples of the resource.
+ * <p>
+ * 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.
+ * </p>
+ */
+@Beta
+// TODO: consider how to restrict the visibility
+public final class DiscreteResource extends Resource {
+    protected DiscreteResource() {
+        super();
+    }
+
+    DiscreteResource(ResourceId id) {
+        super(id);
+    }
+
+    /**
+     * The user of this methods must receive the return value as the correct type.
+     * Otherwise, this methods throws an exception.
+     *
+     * @param <T> type of the return value
+     * @return the volume of this resource
+     */
+    @SuppressWarnings("unchecked")
+    @Override
+    // TODO: consider receiving Class<T> as an argument. Which approach is convenient?
+    public <T> T volume() {
+        return (T) last();
+    }
+
+    @Override
+    public int hashCode() {
+        // the value returing from volume() is excluded due to optimization
+        return id().hashCode();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null || getClass() != obj.getClass()) {
+            return false;
+        }
+        final DiscreteResource other = (DiscreteResource) obj;
+        // the value returing from volume() is excluded due to optimization
+        return Objects.equals(this.id(), other.id());
+    }
+}
diff --git a/core/api/src/main/java/org/onosproject/net/newresource/DiscreteResourceId.java b/core/api/src/main/java/org/onosproject/net/newresource/DiscreteResourceId.java
new file mode 100644
index 0000000..cf9d334
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/newresource/DiscreteResourceId.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2016 Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.net.newresource;
+
+import com.google.common.annotations.Beta;
+import com.google.common.collect.ImmutableList;
+
+/**
+ * ResourceId for {@link DiscreteResource}.
+ *
+ * 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
+// TODO: consider how to restrict the visibility
+public final class DiscreteResourceId extends ResourceId {
+    DiscreteResourceId(ImmutableList<Object> components) {
+        super(components);
+    }
+
+    DiscreteResourceId() {
+        super();
+    }
+}
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 1b05d94..1dadcc2 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
@@ -21,7 +21,6 @@
 import org.onosproject.net.PortNumber;
 
 import java.util.List;
-import java.util.Objects;
 import java.util.Optional;
 
 import static com.google.common.base.Preconditions.checkArgument;
@@ -47,13 +46,13 @@
 @Beta
 public abstract class Resource {
 
-    private final Discrete parent;
+    private final DiscreteResource parent;
     private final ResourceId id;
 
-    public static final Discrete ROOT = new Discrete();
+    public static final DiscreteResource ROOT = new DiscreteResource();
 
     public static Resource discrete(DeviceId device) {
-        return new Discrete(ResourceId.discrete(device));
+        return new DiscreteResource(ResourceId.discrete(device));
     }
 
     /**
@@ -64,7 +63,7 @@
      * @return resource path instance
      */
     public static Resource discrete(DeviceId device, Object... components) {
-        return new Discrete(ResourceId.discrete(device, components));
+        return new DiscreteResource(ResourceId.discrete(device, components));
     }
 
     /**
@@ -76,7 +75,7 @@
      * @return resource path instance
      */
     public static Resource discrete(DeviceId device, PortNumber port, Object... components) {
-        return new Discrete(ResourceId.discrete(device, port, components));
+        return new DiscreteResource(ResourceId.discrete(device, port, components));
     }
 
     /**
@@ -93,7 +92,7 @@
         checkArgument(components.length > 0,
                 "Length of components must be greater thant 0, but " + components.length);
 
-        return new Continuous(ResourceId.continuous(device, components), value);
+        return new ContinuousResource(ResourceId.continuous(device, components), value);
     }
 
     /**
@@ -108,7 +107,7 @@
      * @return resource path instance
      */
     public static Resource continuous(double value, DeviceId device, PortNumber port, Object... components) {
-        return new Continuous(ResourceId.continuous(device, port, components), value);
+        return new ContinuousResource(ResourceId.continuous(device, port, components), value);
     }
 
     /**
@@ -123,12 +122,12 @@
         if (id.components.size() == 1) {
             this.parent = ROOT;
         } else {
-            this.parent = new Discrete(id.parent());
+            this.parent = new DiscreteResource(id.parent());
         }
     }
 
     // for serialization
-    private Resource() {
+    protected Resource() {
         this.parent = null;
         this.id = ResourceId.ROOT;
     }
@@ -157,7 +156,7 @@
      * @return the parent resource path of this instance.
      * If there is no parent, empty instance will be returned.
      */
-    public Optional<Discrete> parent() {
+    public Optional<DiscreteResource> parent() {
         return Optional.ofNullable(parent);
     }
 
@@ -169,9 +168,9 @@
      * @return a child resource path
      */
     public Resource child(Object child) {
-        checkState(this instanceof Discrete);
+        checkState(this instanceof DiscreteResource);
 
-        return new Discrete(id().child(child));
+        return new DiscreteResource(id().child(child));
     }
 
     /**
@@ -183,9 +182,9 @@
      * @return a child resource path
      */
     public Resource child(Object child, double value) {
-        checkState(this instanceof Discrete);
+        checkState(this instanceof DiscreteResource);
 
-        return new Continuous(id.child(child), value);
+        return new ContinuousResource(id.child(child), value);
     }
 
     /**
@@ -218,114 +217,4 @@
                 .toString();
     }
 
-    /**
-     * Represents a resource path which specifies a resource which can be measured
-     * as a discrete unit. A VLAN ID and a MPLS label of a link are examples of the resource.
-     * <p>
-     * 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.
-     * </p>
-     */
-    @Beta
-    public static final class Discrete extends Resource {
-        private Discrete() {
-            super();
-        }
-
-        private Discrete(ResourceId id) {
-            super(id);
-        }
-
-        /**
-         * The user of this methods must receive the return value as the correct type.
-         * Otherwise, this methods throws an exception.
-         *
-         * @param <T> type of the return value
-         * @return the volume of this resource
-         */
-        @SuppressWarnings("unchecked")
-        @Override
-        // TODO: consider receiving Class<T> as an argument. Which approach is convenient?
-        public <T> T volume() {
-            return (T) last();
-        }
-
-        @Override
-        public int hashCode() {
-            // the value returing from volume() is excluded due to optimization
-            return id().hashCode();
-        }
-
-        @Override
-        public boolean equals(Object obj) {
-            if (this == obj) {
-                return true;
-            }
-            if (obj == null || getClass() != obj.getClass()) {
-                return false;
-            }
-            final Discrete other = (Discrete) obj;
-            // the value returing from volume() is excluded due to optimization
-            return Objects.equals(this.id(), other.id());
-        }
-    }
-
-    /**
-     * Represents a resource path which specifies a resource which can be measured
-     * as continuous value. Bandwidth of a link is an example of the resource.
-     * <p>
-     * 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 Resource {
-        private final double value;
-
-        private Continuous(ResourceId id, double value) {
-            super(id);
-            this.value = value;
-        }
-
-        /**
-         * The user of this methods must receive the return value as Double or double.
-         * Otherwise, this methods throws an exception.
-         *
-         * @param <T> type of the return value
-         * @return the volume of this resource
-         */
-        @SuppressWarnings("unchecked")
-        @Override
-        public <T> T volume() {
-            return (T) Double.valueOf(value);
-        }
-
-        @Override
-        public int hashCode() {
-            return Objects.hash(id(), value);
-        }
-
-        @Override
-        public boolean equals(Object obj) {
-            if (this == obj) {
-                return true;
-            }
-            if (obj == null || getClass() != obj.getClass()) {
-                return false;
-            }
-            final Continuous other = (Continuous) obj;
-            return Objects.equals(this.id(), other.id())
-                    && Objects.equals(this.value, other.value);
-        }
-
-        /**
-         * Returns the value of the resource amount.
-         *
-         * @return the value of the resource amount
-         */
-        // FIXME: overlapping a purpose with volume()
-        public double value() {
-            return value;
-        }
-    }
-
 }
diff --git a/core/api/src/main/java/org/onosproject/net/newresource/ResourceId.java b/core/api/src/main/java/org/onosproject/net/newresource/ResourceId.java
index 1be737e..93c4472 100644
--- a/core/api/src/main/java/org/onosproject/net/newresource/ResourceId.java
+++ b/core/api/src/main/java/org/onosproject/net/newresource/ResourceId.java
@@ -33,19 +33,19 @@
  */
 @Beta
 public abstract class ResourceId {
-    static final ResourceId ROOT = new Discrete();
+    static final ResourceId ROOT = new DiscreteResourceId();
 
     final ImmutableList<Object> components;
 
     static ResourceId discrete(DeviceId device, Object... components) {
-        return new Discrete(ImmutableList.builder()
+        return new DiscreteResourceId(ImmutableList.builder()
                 .add(device)
                 .add(components)
                 .build());
     }
 
     static ResourceId discrete(DeviceId device, PortNumber port, Object... components) {
-        return new Discrete(ImmutableList.builder()
+        return new DiscreteResourceId(ImmutableList.builder()
                 .add(device)
                 .add(port)
                 .add(components)
@@ -72,17 +72,17 @@
     }
 
     private static ResourceId continuous(ImmutableList.Builder<Object> parentComponents, Class<?> last) {
-        return new Continuous(parentComponents
+        return new ContinuousResourceId(parentComponents
                 .add(last.getCanonicalName())
                 .build(), last.getSimpleName());
     }
 
-    private ResourceId(ImmutableList<Object> components) {
+    protected ResourceId(ImmutableList<Object> components) {
         this.components = checkNotNull(components);
     }
 
     // for serializer
-    private ResourceId() {
+    protected ResourceId() {
         this.components = ImmutableList.of();
     }
 
@@ -91,27 +91,27 @@
         if (components.size() == 1) {
             return ROOT;
         } else {
-            return new Discrete(components.subList(0, components.size() - 1));
+            return new DiscreteResourceId(components.subList(0, components.size() - 1));
         }
     }
 
     /**
      * Returns a resource ID of a child of this resource based on the specified object.
      * If the argument is an instance of {@link Class}, this method returns an instance of
-     * {@link Continuous}. Otherwise, it returns an instance of {@link Discrete}
-     * This method only work when the receiver is {@link Discrete}. Otherwise,
+     * {@link ContinuousResourceId}. Otherwise, it returns an instance of {@link DiscreteResourceId}
+     * This method only work when the receiver is {@link DiscreteResourceId}. Otherwise,
      * this method throws an exception.
      *
      * @param child the last component of the child
      * @return a child resource ID
      */
     public ResourceId child(Object child) {
-        checkState(this instanceof Discrete);
+        checkState(this instanceof DiscreteResourceId);
 
         if (child instanceof Class<?>) {
             return continuous(ImmutableList.builder().addAll(components), (Class<?>) child);
         } else {
-            return new Discrete(ImmutableList.builder()
+            return new DiscreteResourceId(ImmutableList.builder()
                     .addAll(components)
                     .add(child)
                     .build());
@@ -140,44 +140,4 @@
         return components.toString();
     }
 
-    /**
-     * ResourceId for {@link Resource.Discrete}.
-     *
-     * 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.
-     */
-    public static final class Discrete extends ResourceId {
-        private Discrete(ImmutableList<Object> components) {
-            super(components);
-        }
-
-        private Discrete() {
-            super();
-        }
-    }
-
-    /**
-     * ResourceId for {@link Resource.Continuous}
-     *
-     * 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.
-     */
-    public static final class Continuous extends ResourceId {
-        // for printing purpose only (used in toString() implementation)
-        private final String name;
-
-        private Continuous(ImmutableList<Object> components, String name) {
-            super(components);
-            this.name = checkNotNull(name);
-        }
-
-        @Override
-        public String toString() {
-            // due to performance consideration, the value might need to be stored in a field
-            return ImmutableList.builder()
-                    .addAll(components.subList(0, components.size() - 1))
-                    .add(name)
-                    .build().toString();
-        }
-    }
 }