Refactor protocol buffer to split models into different packages

Change-Id: I26152ba227ebe9afd871c6e501ccca17c49e1e4e
diff --git a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/DeviceProviderServiceClientProxy.java b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/DeviceProviderServiceClientProxy.java
index 4f41835..1da5ddd 100644
--- a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/DeviceProviderServiceClientProxy.java
+++ b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/DeviceProviderServiceClientProxy.java
@@ -31,6 +31,8 @@
 import org.onosproject.grpc.net.device.DeviceService.IsReachableRequest;
 import org.onosproject.grpc.net.device.DeviceService.RoleChanged;
 import org.onosproject.grpc.net.device.DeviceService.TriggerProbe;
+import org.onosproject.grpc.net.device.models.PortDescriptionProtoOuterClass.PortDescriptionProto;
+import org.onosproject.grpc.net.device.models.PortStatisticsProtoOuterClass.PortStatisticsProto;
 import org.onosproject.incubator.protobuf.models.ProtobufUtils;
 import org.onosproject.net.DeviceId;
 import org.onosproject.net.MastershipRole;
@@ -115,7 +117,7 @@
         checkValidity();
 
         DeviceProviderServiceMsg.Builder builder = DeviceProviderServiceMsg.newBuilder();
-        List<org.onosproject.grpc.net.Port.PortDescription> portDescs =
+        List<PortDescriptionProto> portDescs =
                 portDescriptions.stream()
                     .map(ProtobufUtils::translate)
                     .collect(toList());
@@ -168,7 +170,7 @@
         checkValidity();
 
         DeviceProviderServiceMsg.Builder builder = DeviceProviderServiceMsg.newBuilder();
-        List<org.onosproject.grpc.net.Port.PortStatistics> portStats =
+        List<PortStatisticsProto> portStats =
                 portStatistics.stream()
                     .map(ProtobufUtils::translate)
                     .collect(toList());
diff --git a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderServiceClientProxy.java b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderServiceClientProxy.java
index 78f9f37..5c40c90 100644
--- a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderServiceClientProxy.java
+++ b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderServiceClientProxy.java
@@ -15,18 +15,16 @@
  */
 package org.onosproject.incubator.rpc.grpc;
 
-import static org.onosproject.incubator.protobuf.models.ProtobufUtils.asMap;
-
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-import org.onosproject.grpc.net.Link.LinkType;
+import com.google.common.annotations.Beta;
+import com.google.common.util.concurrent.ListenableFuture;
+import io.grpc.Channel;
 import org.onosproject.grpc.net.link.LinkProviderServiceRpcGrpc;
 import org.onosproject.grpc.net.link.LinkProviderServiceRpcGrpc.LinkProviderServiceRpcFutureStub;
 import org.onosproject.grpc.net.link.LinkService.LinkDetectedMsg;
 import org.onosproject.grpc.net.link.LinkService.LinkVanishedMsg;
 import org.onosproject.grpc.net.link.LinkService.Void;
+import org.onosproject.grpc.net.link.models.LinkEnumsProto.LinkTypeProto;
+import org.onosproject.grpc.net.models.ConnectPointProtoOuterClass.ConnectPointProto;
 import org.onosproject.net.ConnectPoint;
 import org.onosproject.net.DeviceId;
 import org.onosproject.net.Link.Type;
@@ -38,10 +36,11 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.annotations.Beta;
-import com.google.common.util.concurrent.ListenableFuture;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
 
-import io.grpc.Channel;
+import static org.onosproject.incubator.protobuf.models.ProtobufUtils.asMap;
 
 /**
  * Proxy object to handle LinkProviderService calls.
@@ -226,25 +225,25 @@
      * Translates ONOS object to gRPC message.
      *
      * @param type {@link org.onosproject.net.Link.Type Link.Type}
-     * @return gRPC LinkType
+     * @return gRPC LinkTypeProto
      */
-    private LinkType translate(Type type) {
+    private LinkTypeProto translate(Type type) {
         switch (type) {
         case DIRECT:
-            return LinkType.DIRECT;
+            return LinkTypeProto.DIRECT;
         case EDGE:
-            return LinkType.EDGE;
+            return LinkTypeProto.EDGE;
         case INDIRECT:
-            return LinkType.INDIRECT;
+            return LinkTypeProto.INDIRECT;
         case OPTICAL:
-            return LinkType.OPTICAL;
+            return LinkTypeProto.OPTICAL;
         case TUNNEL:
-            return LinkType.TUNNEL;
+            return LinkTypeProto.TUNNEL;
         case VIRTUAL:
-            return LinkType.VIRTUAL;
+            return LinkTypeProto.VIRTUAL;
 
         default:
-            return LinkType.DIRECT;
+            return LinkTypeProto.DIRECT;
 
         }
     }
@@ -253,10 +252,10 @@
      * Translates ONOS object to gRPC message.
      *
      * @param cp {@link ConnectPoint}
-     * @return gRPC ConnectPoint
+     * @return gRPC ConnectPointProto
      */
-    private org.onosproject.grpc.net.Link.ConnectPoint translate(ConnectPoint cp) {
-        return org.onosproject.grpc.net.Link.ConnectPoint.newBuilder()
+    private ConnectPointProto translate(ConnectPoint cp) {
+        return ConnectPointProto.newBuilder()
                 .setDeviceId(cp.deviceId().toString())
                 .setPortNumber(cp.port().toString())
                 .build();
diff --git a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderServiceServerProxy.java b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderServiceServerProxy.java
index 69f9cfd..3ba56e4 100644
--- a/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderServiceServerProxy.java
+++ b/incubator/rpc-grpc/src/main/java/org/onosproject/incubator/rpc/grpc/LinkProviderServiceServerProxy.java
@@ -15,26 +15,24 @@
  */
 package org.onosproject.incubator.rpc.grpc;
 
-import static com.google.common.base.Preconditions.checkArgument;
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.cache.RemovalListeners.asynchronous;
-import static org.onosproject.net.DeviceId.deviceId;
-import static org.onosproject.net.LinkKey.linkKey;
-
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.TimeUnit;
-
+import com.google.common.annotations.Beta;
+import com.google.common.cache.Cache;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.RemovalNotification;
+import io.grpc.stub.StreamObserver;
 import org.apache.commons.lang3.tuple.Pair;
-import org.onosproject.grpc.net.Link.ConnectPoint.ElementIdCase;
-import org.onosproject.grpc.net.Link.LinkType;
 import org.onosproject.grpc.net.link.LinkProviderServiceRpcGrpc.LinkProviderServiceRpcImplBase;
 import org.onosproject.grpc.net.link.LinkService.LinkDetectedMsg;
 import org.onosproject.grpc.net.link.LinkService.LinkVanishedMsg;
 import org.onosproject.grpc.net.link.LinkService.Void;
+import org.onosproject.grpc.net.link.models.LinkDescriptionProtoOuterClass.LinkDescriptionProto;
+import org.onosproject.grpc.net.link.models.LinkEnumsProto.LinkTypeProto;
+import org.onosproject.grpc.net.models.ConnectPointProtoOuterClass.ConnectPointProto;
+import org.onosproject.grpc.net.models.ConnectPointProtoOuterClass.ConnectPointProto.ElementIdCase;
 import org.onosproject.incubator.protobuf.models.ProtobufUtils;
 import org.onosproject.net.ConnectPoint;
 import org.onosproject.net.DeviceId;
-import org.onosproject.net.Link;
+import org.onosproject.net.Link.Type;
 import org.onosproject.net.LinkKey;
 import org.onosproject.net.PortNumber;
 import org.onosproject.net.SparseAnnotations;
@@ -44,12 +42,14 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.cache.Cache;
-import com.google.common.cache.CacheBuilder;
-import com.google.common.cache.RemovalNotification;
-import com.google.common.annotations.Beta;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
 
-import io.grpc.stub.StreamObserver;
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.cache.RemovalListeners.asynchronous;
+import static org.onosproject.net.DeviceId.deviceId;
+import static org.onosproject.net.LinkKey.linkKey;
 
 // Only single instance will be created and bound to gRPC LinkProviderService
 /**
@@ -174,7 +174,7 @@
      * @param connectPoint gRPC message.
      * @return {@link ConnectPoint}
      */
-    private ConnectPoint translate(org.onosproject.grpc.net.Link.ConnectPoint connectPoint) {
+    private ConnectPoint translate(ConnectPointProto connectPoint) {
         checkArgument(connectPoint.getElementIdCase() == ElementIdCase.DEVICE_ID,
                       "Only DeviceId supported.");
         return new ConnectPoint(deviceId(connectPoint.getDeviceId()),
@@ -187,10 +187,10 @@
      * @param linkDescription gRPC message
      * @return {@link LinkDescription}
      */
-    private LinkDescription translate(org.onosproject.grpc.net.Link.LinkDescription linkDescription) {
+    private LinkDescription translate(LinkDescriptionProto linkDescription) {
         ConnectPoint src = translate(linkDescription.getSrc());
         ConnectPoint dst = translate(linkDescription.getDst());
-        Link.Type type = translate(linkDescription.getType());
+        Type type = translate(linkDescription.getType());
         SparseAnnotations annotations = ProtobufUtils.asAnnotations(linkDescription.getAnnotations());
         return new DefaultLinkDescription(src, dst, type, annotations);
     }
@@ -199,26 +199,26 @@
      * Translates gRPC message to corresponding ONOS object.
      *
      * @param type gRPC message enum
-     * @return {@link org.onosproject.net.Link.Type Link.Type}
+     * @return {@link Type Link.Type}
      */
-    private Link.Type translate(LinkType type) {
+    private Type translate(LinkTypeProto type) {
         switch (type) {
         case DIRECT:
-            return Link.Type.DIRECT;
+            return Type.DIRECT;
         case EDGE:
-            return Link.Type.EDGE;
+            return Type.EDGE;
         case INDIRECT:
-            return Link.Type.INDIRECT;
+            return Type.INDIRECT;
         case OPTICAL:
-            return Link.Type.INDIRECT;
+            return Type.INDIRECT;
         case TUNNEL:
-            return Link.Type.TUNNEL;
+            return Type.TUNNEL;
         case VIRTUAL:
-            return Link.Type.VIRTUAL;
+            return Type.VIRTUAL;
 
         case UNRECOGNIZED:
         default:
-            return Link.Type.DIRECT;
+            return Type.DIRECT;
         }
     }