CORD-534 Added separate interfaces for Network and ServiceNetwork

Which are useful to implement OpenStack and XOS client implementation.
And removed "get" from get methods.

Change-Id: Icb477e48179a03e88003b1a38dd8f4ea83d92886
diff --git a/src/main/java/org/opencord/cordvtn/api/CordVtnAdminService.java b/src/main/java/org/opencord/cordvtn/api/CordVtnAdminService.java
index afb2a1e..db5681c 100644
--- a/src/main/java/org/opencord/cordvtn/api/CordVtnAdminService.java
+++ b/src/main/java/org/opencord/cordvtn/api/CordVtnAdminService.java
@@ -20,51 +20,53 @@
 import org.openstack4j.model.network.Subnet;
 
 /**
- * Service for administering the inventory of virtual network and service network.
+ * Service for administering the inventory of {@link Network} and
+ * {@link ServiceNetwork}.
  */
-public interface CordVtnAdminService extends CordVtnService {
+public interface CordVtnAdminService extends CordVtnService, NetworkService,
+        ServiceNetworkService {
 
     /**
-     * Creates vtn port with given service port information.
+     * Creates a service port with the given information.
      *
      * @param servicePort the new service port
      */
-    void createVtnPort(ServicePort servicePort);
+    void createServicePort(ServicePort servicePort);
 
     /**
-     * Updates vtn port with given service port information.
+     * Updates a service port with the given information.
      *
      * @param servicePort the updated service port
      */
-    void updateVtnPort(ServicePort servicePort);
+    void updateServicePort(ServicePort servicePort);
 
     /**
-     * Removes vtn port with given port id.
+     * Removes a service port with the given port id.
      *
      * @param portId port id
      */
-    void removeVtnPort(PortId portId);
+    void removeServicePort(PortId portId);
 
     /**
-     * Creates vtn network with given service network information.
+     * Creates a service network with the given information.
      *
      * @param serviceNet the new service network
      */
-    void createVtnNetwork(ServiceNetwork serviceNet);
+    void createServiceNetwork(ServiceNetwork serviceNet);
 
     /**
-     * Updates the vtn network with given service network information.
+     * Updates a service network with the given information.
      *
      * @param serviceNet the updated service network
      */
-    void updateVtnNetwork(ServiceNetwork serviceNet);
+    void updateServiceNetwork(ServiceNetwork serviceNet);
 
     /**
-     * Removes the vtn network.
+     * Removes a service network with the given network id.
      *
      * @param netId network id
      */
-    void removeVtnNetwork(NetworkId netId);
+    void removeServiceNetwork(NetworkId netId);
 
     /**
      * Creates a port.
diff --git a/src/main/java/org/opencord/cordvtn/api/CordVtnService.java b/src/main/java/org/opencord/cordvtn/api/CordVtnService.java
index 5b0849e..1a9f78f 100644
--- a/src/main/java/org/opencord/cordvtn/api/CordVtnService.java
+++ b/src/main/java/org/opencord/cordvtn/api/CordVtnService.java
@@ -16,35 +16,23 @@
 package org.opencord.cordvtn.api;
 
 import org.onosproject.event.ListenerService;
-import org.openstack4j.model.network.Network;
-import org.openstack4j.model.network.Port;
-import org.openstack4j.model.network.Subnet;
 
 import java.util.Set;
 
 /**
- * Service for interacting with the inventory of VTN network and port.
+ * Service for interacting with the inventory of {@link VtnNetwork} and
+ * {@link VtnPort}.
  */
 public interface CordVtnService
         extends ListenerService<VtnNetworkEvent, VtnNetworkListener> {
 
     /**
-     * Returns the service port with the given port id.
+     * Returns the VTN port with the given port id.
      *
      * @param portId port id
      * @return service port
      */
-    VtnPort getVtnPort(PortId portId);
-
-    /**
-     * Returns the vtn port with the given port id. It returns the VTN port with
-     * the default settings if no service port exists for the port.
-     *
-     * @param portId port id
-     * @return vtn port for the port, of the default vtn port if no service port
-     * exists for the port
-     */
-    VtnPort getVtnPortOrDefault(PortId portId);
+    VtnPort vtnPort(PortId portId);
 
     /**
      * Returns the VTN port with the given port name.
@@ -52,98 +40,27 @@
      * @param portName port name
      * @return vtn port
      */
-    VtnPort getVtnPort(String portName);
+    VtnPort vtnPort(String portName);
 
     /**
-     * Returns all service ports.
+     * Returns all VTN ports.
      *
      * @return set of service ports
      */
-    Set<VtnPort> getVtnPorts();
+    Set<VtnPort> vtnPorts();
 
     /**
-     * Returns the service network with the given network id.
+     * Returns the VTN network with the given network id.
      *
      * @param netId network id
      * @return service network
      */
-    VtnNetwork getVtnNetwork(NetworkId netId);
+    VtnNetwork vtnNetwork(NetworkId netId);
 
     /**
-     * Returns the vtn network with the given network id. It returns the VTN
-     * network with default settings if no service network exists for the network.
-     *
-     * @param netId network id
-     * @return vtn network for the network id, or the default vtn network if no
-     * service network is created for the network
-     */
-    VtnNetwork getVtnNetworkOrDefault(NetworkId netId);
-
-    /**
-     * Returns all service networks.
+     * Returns all VTN networks.
      *
      * @return set of service networks
      */
-    Set<VtnNetwork> getVtnNetworks();
-
-    /**
-     * Returns the port with the given port id.
-     *
-     * @param portId port id
-     * @return port
-     */
-    Port getPort(PortId portId);
-
-    /**
-     * Returns all ports.
-     *
-     * @return set of ports
-     */
-    Set<Port> getPorts();
-
-    /**
-     * Returns the network with the given network id.
-     *
-     * @param netId network id
-     * @return network
-     */
-    Network getNetwork(NetworkId netId);
-
-    /**
-     * Returns all networks.
-     *
-     * @return set of networks
-     */
-    Set<Network> getNetworks();
-
-    /**
-     * Returns the subnet with the given subnet id.
-     *
-     * @param subnetId subnet id
-     * @return subnet
-     */
-    Subnet getSubnet(SubnetId subnetId);
-
-    /**
-     * Returns all subnets.
-     *
-     * @return set of subnets
-     */
-    Set<Subnet> getSubnets();
-
-    /**
-     * Returns instance attached to the given port.
-     *
-     * @param portId port identifier
-     * @return instance, or null if no instance for the port
-     */
-    Instance getInstance(PortId portId);
-
-    /**
-     * Returns instances in the given network.
-     *
-     * @param netId network identifier
-     * @return set of instances, empty set if no instances in the network
-     */
-    Set<Instance> getInstances(NetworkId netId);
+    Set<VtnNetwork> vtnNetworks();
 }
diff --git a/src/main/java/org/opencord/cordvtn/api/CordVtnStore.java b/src/main/java/org/opencord/cordvtn/api/CordVtnStore.java
index bfa84f7..42b71c8 100644
--- a/src/main/java/org/opencord/cordvtn/api/CordVtnStore.java
+++ b/src/main/java/org/opencord/cordvtn/api/CordVtnStore.java
@@ -30,16 +30,16 @@
     /**
      * Creates vtn network.
      *
-     * @param serviceNet the new vtn network
+     * @param vtnNet vtn network
      */
-    void createVtnNetwork(VtnNetwork serviceNet);
+    void createVtnNetwork(VtnNetwork vtnNet);
 
     /**
      * Updates the vtn network.
      *
-     * @param serviceNet the updated vtn network
+     * @param vtnNet vtn network
      */
-    void updateVtnNetwork(VtnNetwork serviceNet);
+    void updateVtnNetwork(VtnNetwork vtnNet);
 
     /**
      * Returns the vtn network with the given network id.
@@ -47,17 +47,17 @@
      * @param netId network id
      * @return vtn network
      */
-    VtnNetwork getVtnNetwork(NetworkId netId);
+    VtnNetwork vtnNetwork(NetworkId netId);
 
     /**
      * Returns all vtn networks.
      *
      * @return set of vtn networks
      */
-    Set<VtnNetwork> getVtnNetworks();
+    Set<VtnNetwork> vtnNetworks();
 
     /**
-     * Removes the vtn network.
+     * Removes the vtn network with the given network id.
      *
      * @param netId network id
      */
@@ -66,16 +66,16 @@
     /**
      * Creates vtn port.
      *
-     * @param servicePort the new vtn port
+     * @param vtnPort the new vtn port
      */
-    void createVtnPort(VtnPort servicePort);
+    void createVtnPort(VtnPort vtnPort);
 
     /**
      * Updates the vtn port.
      *
-     * @param servicePort vtn port
+     * @param vtnPort vtn port
      */
-    void updateVtnPort(VtnPort servicePort);
+    void updateVtnPort(VtnPort vtnPort);
 
     /**
      * Returns the vtn port with the given port id.
@@ -83,14 +83,14 @@
      * @param portId port id
      * @return vtn port
      */
-    VtnPort getVtnPort(PortId portId);
+    VtnPort vtnPort(PortId portId);
 
     /**
      * Returns all vtn ports.
      *
      * @return set of vtn ports
      */
-    Set<VtnPort> getVtnPorts();
+    Set<VtnPort> vtnPorts();
 
     /**
      * Removes vtn port.
@@ -119,14 +119,14 @@
      * @param netId network id
      * @return network
      */
-    Network getNetwork(NetworkId netId);
+    Network network(NetworkId netId);
 
     /**
      * Returns all networks.
      *
      * @return set of networks
      */
-    Set<Network> getNetworks();
+    Set<Network> networks();
 
     /**
      * Removes the network with the given network id.
@@ -155,14 +155,14 @@
      * @param portId port id
      * @return port
      */
-    Port getPort(PortId portId);
+    Port port(PortId portId);
 
     /**
      * Returns all ports.
      *
      * @return set of ports
      */
-    Set<Port> getPorts();
+    Set<Port> ports();
 
     /**
      * Removes the port with the given port id.
@@ -191,14 +191,14 @@
      * @param subnetId subnet id
      * @return subnet
      */
-    Subnet getSubnet(SubnetId subnetId);
+    Subnet subnet(SubnetId subnetId);
 
     /**
      * Returns all subnets.
      *
      * @return set of subnets
      */
-    Set<Subnet> getSubnets();
+    Set<Subnet> subnets();
 
     /**
      * Removes the subnet with the given subnet id.
diff --git a/src/main/java/org/opencord/cordvtn/api/NetworkService.java b/src/main/java/org/opencord/cordvtn/api/NetworkService.java
new file mode 100644
index 0000000..aa178e5
--- /dev/null
+++ b/src/main/java/org/opencord/cordvtn/api/NetworkService.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2016-present 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.opencord.cordvtn.api;
+
+import org.openstack4j.model.network.Network;
+import org.openstack4j.model.network.Port;
+import org.openstack4j.model.network.Subnet;
+
+import java.util.Set;
+
+/**
+ * Service for interacting with the inventory of {@link Network}, {@link Port},
+ * and {@link Subnet}.
+ */
+public interface NetworkService {
+
+    /**
+     * Returns the network with the supplied network ID.
+     *
+     * @param netId network id
+     * @return network
+     */
+    Network network(NetworkId netId);
+
+    /**
+     * Returns all networks registered in the service.
+     *
+     * @return set of networks
+     */
+    Set<Network> networks();
+
+    /**
+     * Returns the port with the supplied port ID.
+     *
+     * @param portId port id
+     * @return port
+     */
+    Port port(PortId portId);
+
+    /**
+     * Returns all ports registered in the service.
+     *
+     * @return set of ports
+     */
+    Set<Port> ports();
+
+    /**
+     * Returns the subnet with the supplied subnet ID.
+     *
+     * @param subnetId subnet id
+     * @return subnet
+     */
+    Subnet subnet(SubnetId subnetId);
+
+    /**
+     * Returns all subnets registered in the service.
+     *
+     * @return set of subnets
+     */
+    Set<Subnet> subnets();
+}
diff --git a/src/main/java/org/opencord/cordvtn/api/ServiceNetwork.java b/src/main/java/org/opencord/cordvtn/api/ServiceNetwork.java
index 6da6833..90de69c 100644
--- a/src/main/java/org/opencord/cordvtn/api/ServiceNetwork.java
+++ b/src/main/java/org/opencord/cordvtn/api/ServiceNetwork.java
@@ -24,7 +24,8 @@
 import static com.google.common.base.Preconditions.checkNotNull;
 
 /**
- * Representation of a service network.
+ * Representation of a service network which holds service specific information,
+ * like service type or dependency, in addition to the common network.
  */
 public class ServiceNetwork {
 
diff --git a/src/main/java/org/opencord/cordvtn/api/ServiceNetworkService.java b/src/main/java/org/opencord/cordvtn/api/ServiceNetworkService.java
new file mode 100644
index 0000000..1b387b7
--- /dev/null
+++ b/src/main/java/org/opencord/cordvtn/api/ServiceNetworkService.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2016-present 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.opencord.cordvtn.api;
+
+import java.util.Set;
+
+/**
+ * Service for interacting with the inventory of {@link ServiceNetwork} and
+ * {@link ServicePort}.
+ */
+public interface ServiceNetworkService {
+
+    /**
+     * Returns the service network with the supplied network ID.
+     *
+     * @param netId network id
+     * @return service network
+     */
+    ServiceNetwork serviceNetwork(NetworkId netId);
+
+    /**
+     * Returns all service networks registered in the service.
+     *
+     * @return set of service networks
+     */
+    Set<ServiceNetwork> serviceNetworks();
+
+    /**
+     * Returns the service port with the supplied port ID.
+     *
+     * @param portId port id
+     * @return service port
+     */
+    ServicePort servicePort(PortId portId);
+
+    /**
+     * Returns all service ports registered in the service.
+     *
+     * @return set of service ports
+     */
+    Set<ServicePort> servicePorts();
+}
diff --git a/src/main/java/org/opencord/cordvtn/api/ServicePort.java b/src/main/java/org/opencord/cordvtn/api/ServicePort.java
index 3ed18ee..a6e048b 100644
--- a/src/main/java/org/opencord/cordvtn/api/ServicePort.java
+++ b/src/main/java/org/opencord/cordvtn/api/ServicePort.java
@@ -26,7 +26,8 @@
 import static com.google.common.base.Preconditions.checkNotNull;
 
 /**
- * Representation of a service port.
+ * Representation of a service port which holds service specific port information,
+ * like vlan tag or additional addresses, to the common network port.
  */
 public class ServicePort {
 
diff --git a/src/main/java/org/opencord/cordvtn/api/VtnNetwork.java b/src/main/java/org/opencord/cordvtn/api/VtnNetwork.java
index 644a939..55fb595 100644
--- a/src/main/java/org/opencord/cordvtn/api/VtnNetwork.java
+++ b/src/main/java/org/opencord/cordvtn/api/VtnNetwork.java
@@ -32,8 +32,11 @@
 import static org.opencord.cordvtn.api.ServiceNetwork.ServiceNetworkType.PRIVATE;
 
 /**
- * Representation of the network containing all network information consumed by
- * VTN service.
+ * Representation of a network holding the basic virtual network and additional
+ * service network specific information.
+ * All the services making use of {@link CordVtnService} are intended to interface
+ * with this VtnNetwork, and not allowed to directly access {@link Network} or
+ * {@link ServiceNetwork}.
  */
 public final class VtnNetwork extends ServiceNetwork {
 
diff --git a/src/main/java/org/opencord/cordvtn/api/VtnPort.java b/src/main/java/org/opencord/cordvtn/api/VtnPort.java
index a7d8385..af1bd99 100644
--- a/src/main/java/org/opencord/cordvtn/api/VtnPort.java
+++ b/src/main/java/org/opencord/cordvtn/api/VtnPort.java
@@ -30,7 +30,11 @@
 import static com.google.common.base.Preconditions.checkNotNull;
 
 /**
- * Representation of the port containing all port information consumed by VTN service.
+ * Representation of a port holding the basic virtual port and additional service
+ * port specific information.
+ * All the services making use of {@link CordVtnService} are intended to interface
+ * with this VtnPort, and not allowed to directly access {@link Port} or
+ * {@link ServicePort}.
  */
 public final class VtnPort extends ServicePort {