Add default implementation for Resource/ResourceAllocation

- Instantiation of the implementations are needed in an implementation
  of ResourceService
- Device and link specific implementations are removed because the default
  implementations cover what these classes can do

Change-Id: Ia50b495e4d3bc21bf8f55f77a01f0532fae72720
diff --git a/core/api/src/main/java/org/onosproject/net/newresource/AbstractResource.java b/core/api/src/main/java/org/onosproject/net/newresource/DefaultResource.java
similarity index 80%
rename from core/api/src/main/java/org/onosproject/net/newresource/AbstractResource.java
rename to core/api/src/main/java/org/onosproject/net/newresource/DefaultResource.java
index 6da4133..5d0efe4 100644
--- a/core/api/src/main/java/org/onosproject/net/newresource/AbstractResource.java
+++ b/core/api/src/main/java/org/onosproject/net/newresource/DefaultResource.java
@@ -22,24 +22,24 @@
 import static com.google.common.base.Preconditions.checkNotNull;
 
 /**
- * Base implementation of a class representing resource which belongs to a particular subject.
+ * Default implementation of a class representing resource which belongs to a particular subject.
  *
  * @param <S> type of the subject
  * @param <T> type of the resource
  */
 @Beta
-public abstract class AbstractResource<S, T> implements Resource<S, T> {
+public class DefaultResource<S, T> implements Resource<S, T> {
 
     private final S subject;
     private final T resource;
 
     /**
-     * Constructor expected to be called by constructors of the sub-classes.
+     * Creates a resource with the specified subject and resource.
      *
      * @param subject identifier which this resource belongs to
      * @param resource resource of the subject
      */
-    protected AbstractResource(S subject, T resource) {
+    public DefaultResource(S subject, T resource) {
         this.subject = checkNotNull(subject);
         this.resource = checkNotNull(resource);
     }
@@ -64,10 +64,10 @@
         if (this == obj) {
             return true;
         }
-        if (!(obj instanceof AbstractResource)) {
+        if (!(obj instanceof DefaultResource)) {
             return false;
         }
-        final AbstractResource that = (AbstractResource) obj;
+        final DefaultResource that = (DefaultResource) obj;
         return Objects.equals(this.subject, that.subject)
                 && Objects.equals(this.resource, that.resource);
     }
diff --git a/core/api/src/main/java/org/onosproject/net/newresource/AbstractResourceAllocation.java b/core/api/src/main/java/org/onosproject/net/newresource/DefaultResourceAllocation.java
similarity index 79%
rename from core/api/src/main/java/org/onosproject/net/newresource/AbstractResourceAllocation.java
rename to core/api/src/main/java/org/onosproject/net/newresource/DefaultResourceAllocation.java
index ab0b7fe..0b496a8 100644
--- a/core/api/src/main/java/org/onosproject/net/newresource/AbstractResourceAllocation.java
+++ b/core/api/src/main/java/org/onosproject/net/newresource/DefaultResourceAllocation.java
@@ -22,26 +22,26 @@
 import static com.google.common.base.Preconditions.checkNotNull;
 
 /**
- * Base implementation of a class representing allocation of resource which belongs to a particular subject.
+ * Default implementation of a class representing allocation of resource which belongs to a particular subject.
  *
  * @param <S> type of the subject
  * @param <T> type of the resource
  */
 @Beta
-public abstract class AbstractResourceAllocation<S, T> implements ResourceAllocation<S, T> {
+public class DefaultResourceAllocation<S, T> implements ResourceAllocation<S, T> {
 
     private final S subject;
     private final T resource;
     private final ResourceConsumer consumer;
 
     /**
-     * Constructor expected to be called by constructors of the sub-classes.
+     * Creates an instance with the specified subject, resource and consumer.
      *
      * @param subject identifier which this resource belongs to
      * @param resource resource of the subject
      * @param consumer consumer ot this resource
      */
-    protected AbstractResourceAllocation(S subject, T resource, ResourceConsumer consumer) {
+    public DefaultResourceAllocation(S subject, T resource, ResourceConsumer consumer) {
         this.subject = checkNotNull(subject);
         this.resource = checkNotNull(resource);
         this.consumer = consumer;
@@ -72,10 +72,10 @@
         if (this == obj) {
             return true;
         }
-        if (!(obj instanceof AbstractResourceAllocation)) {
+        if (!(obj instanceof DefaultResourceAllocation)) {
             return false;
         }
-        final AbstractResourceAllocation that = (AbstractResourceAllocation) obj;
+        final DefaultResourceAllocation that = (DefaultResourceAllocation) obj;
         return Objects.equals(this.subject, that.subject)
                 && Objects.equals(this.resource, that.resource)
                 && Objects.equals(this.consumer, that.consumer);
diff --git a/core/api/src/main/java/org/onosproject/net/newresource/DeviceResource.java b/core/api/src/main/java/org/onosproject/net/newresource/DeviceResource.java
deleted file mode 100644
index d004c7a..0000000
--- a/core/api/src/main/java/org/onosproject/net/newresource/DeviceResource.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2015 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 org.onosproject.net.DeviceId;
-
-/**
- * Represents resource which belongs to a particular device.
- *
- * @param <T> represents the type of the resource
- */
-@Beta
-public final class DeviceResource<T> extends AbstractResource<DeviceId, T> {
-
-    /**
-     * Creates a new device resource from the specified device identifier and resource.
-     * (deviceId, resource) signifies a resource identifier which is globally unique.
-     *
-     * @param deviceId device identifier which this resource belongs to
-     * @param resource resource of the device
-     */
-    public DeviceResource(DeviceId deviceId, T resource) {
-        super(deviceId, resource);
-    }
-}
diff --git a/core/api/src/main/java/org/onosproject/net/newresource/DeviceResourceAllocation.java b/core/api/src/main/java/org/onosproject/net/newresource/DeviceResourceAllocation.java
deleted file mode 100644
index 0355bab..0000000
--- a/core/api/src/main/java/org/onosproject/net/newresource/DeviceResourceAllocation.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2015 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 org.onosproject.net.DeviceId;
-
-/**
- * Represents allocation of resource bound to device.
- *
- * @param <T> type of the resource
- */
-@Beta
-public final class DeviceResourceAllocation<T> extends AbstractResourceAllocation<DeviceId, T> {
-
-    /**
-     * Creates a new allocation of resource bound to the specified device and consumed by the specified user.
-     *
-     * @param device device identifier which this resource belongs to
-     * @param resource resource of the device
-     * @param consumer consumer of this resource
-     */
-    public DeviceResourceAllocation(DeviceId device, T resource, ResourceConsumer consumer) {
-        super(device, resource, consumer);
-    }
-}
diff --git a/core/api/src/main/java/org/onosproject/net/newresource/LinkResource.java b/core/api/src/main/java/org/onosproject/net/newresource/LinkResource.java
deleted file mode 100644
index 84becad..0000000
--- a/core/api/src/main/java/org/onosproject/net/newresource/LinkResource.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2015 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 org.onosproject.net.LinkKey;
-
-/**
- * Represents resource which belongs to a particular link.
- *
- * @param <T> represents the type of the resource
- */
-@Beta
-public final class LinkResource<T> extends AbstractResource<LinkKey, T> {
-
-    /**
-     * Creates a new link resource from the specified link identifier and resource.
-     * (linkKey, resource) signifies a resource identifier which is globally unique.
-     *
-     * @param linkKey link identifier which this resource belongs to
-     * @param resource resource of the link
-     */
-    public LinkResource(LinkKey linkKey, T resource) {
-        super(linkKey, resource);
-    }
-}
diff --git a/core/api/src/main/java/org/onosproject/net/newresource/LinkResourceAllocation.java b/core/api/src/main/java/org/onosproject/net/newresource/LinkResourceAllocation.java
deleted file mode 100644
index 62c3023..0000000
--- a/core/api/src/main/java/org/onosproject/net/newresource/LinkResourceAllocation.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright 2015 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 org.onosproject.net.LinkKey;
-
-/**
- * Represents allocation of resource bound to link.
- *
- * @param <T> type of the resource
- */
-@Beta
-public final class LinkResourceAllocation<T> extends AbstractResourceAllocation<LinkKey, T> {
-
-    /**
-     * Creates a new allocation of resource bound to the specified device and consumed by the specified user.
-     *
-     * @param link device identifier which this resource belongs to
-     * @param resource resource of the device
-     * @param consumer consumer of this resource
-     */
-    public LinkResourceAllocation(LinkKey link, T resource, ResourceConsumer consumer) {
-        super(link, resource, consumer);
-    }
-}