[ONOS-7683] Add FlowInfo and StatsInfo impls with unit tests
Change-Id: I86327507c528a9b7eea60af858ccfb1fb4b2f8ce
diff --git a/apps/openstacktelemetry/api/src/main/java/org/onosproject/openstacktelemetry/api/FlowInfo.java b/apps/openstacktelemetry/api/src/main/java/org/onosproject/openstacktelemetry/api/FlowInfo.java
new file mode 100644
index 0000000..502d692
--- /dev/null
+++ b/apps/openstacktelemetry/api/src/main/java/org/onosproject/openstacktelemetry/api/FlowInfo.java
@@ -0,0 +1,248 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * 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.openstacktelemetry.api;
+
+import org.onlab.packet.IpPrefix;
+import org.onlab.packet.MacAddress;
+import org.onlab.packet.VlanId;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.PortNumber;
+
+/**
+ * Flow info interface.
+ */
+public interface FlowInfo {
+
+ /**
+ * Obtains flow type.
+ *
+ * @return flow type
+ */
+ byte flowType();
+
+ /**
+ * Obtains device identifier.
+ *
+ * @return device identifier
+ */
+ DeviceId deviceId();
+
+ /**
+ * Obtains input interface identifier.
+ *
+ * @return input interface identifier
+ */
+ int inputInterfaceId();
+
+ /**
+ * Obtains output interface identifier.
+ *
+ * @return output interface identifier
+ */
+ int outputInterfaceId();
+
+ /**
+ * Obtains VLAN identifier.
+ *
+ * @return VLAN identifier
+ */
+ VlanId vlanId();
+
+ /**
+ * Obtains VxLAN identifier.
+ *
+ * @return VxLAN identifier
+ */
+ short vxlanId();
+
+ /**
+ * Obtains source IP address.
+ *
+ * @return source IP address
+ */
+ IpPrefix srcIp();
+
+ /**
+ * Obtains destination IP address.
+ *
+ * @return destination IP address
+ */
+ IpPrefix dstIp();
+
+ /**
+ * Obtains source port.
+ *
+ * @return source port
+ */
+ PortNumber srcPort();
+
+ /**
+ * Obtains destination port.
+ *
+ * @return destination port
+ */
+ PortNumber dstPort();
+
+ /**
+ * Obtains protocol type.
+ *
+ * @return protocol type
+ */
+ byte protocol();
+
+ /**
+ * Obtains source MAC address.
+ *
+ * @return source MAC address
+ */
+ MacAddress srcMac();
+
+ /**
+ * Obtains destination MAC address.
+ *
+ * @return destination MAC address
+ */
+ MacAddress dstMac();
+
+ /**
+ * Obtains flow level stats information.
+ *
+ * @return flow level stats information
+ */
+ StatsInfo statsInfo();
+
+ interface Builder {
+
+ /**
+ * Sets flow type.
+ *
+ * @param flowType flow type
+ * @return builder instance
+ */
+ Builder withFlowType(byte flowType);
+
+ /**
+ * Sets device identifier.
+ *
+ * @param deviceId device identifier
+ * @return builder instance
+ */
+ Builder withDeviceId(DeviceId deviceId);
+
+ /**
+ * Sets input interface identifier.
+ *
+ * @param inputInterfaceId input interface identifier
+ * @return builder instance
+ */
+ Builder withInputInterfaceId(int inputInterfaceId);
+
+ /**
+ * Sets output interface identifier.
+ *
+ * @param outputInterfaceId output interface identifier
+ * @return builder instance
+ */
+ Builder withOutputInterfaceId(int outputInterfaceId);
+
+ /**
+ * Sets VLAN identifier.
+ *
+ * @param vlanId VLAN identifier
+ * @return builder instance
+ */
+ Builder withVlanId(VlanId vlanId);
+
+ /**
+ * Sets VxLAN identifier.
+ *
+ * @param vxlanId VxLAN identifier
+ * @return builder instance
+ */
+ Builder withVxlanId(short vxlanId);
+
+ /**
+ * Sets source IP address.
+ *
+ * @param srcIp source IP address
+ * @return builder instance
+ */
+ Builder withSrcIp(IpPrefix srcIp);
+
+ /**
+ * Sets destination IP address.
+ *
+ * @param dstIp destination IP address
+ * @return builder instance
+ */
+ Builder withDstIp(IpPrefix dstIp);
+
+ /**
+ * Sets source port number.
+ *
+ * @param srcPort source port number
+ * @return builder instance
+ */
+ Builder withSrcPort(PortNumber srcPort);
+
+ /**
+ * Sets destination port number.
+ *
+ * @param dstPort destination port number
+ * @return builder instance
+ */
+ Builder withDstPort(PortNumber dstPort);
+
+ /**
+ * Sets protocol type.
+ *
+ * @param protocol protocol type
+ * @return builder instance
+ */
+ Builder withProtocol(byte protocol);
+
+ /**
+ * Sets source MAC address.
+ *
+ * @param srcMac source MAC address
+ * @return builder instance
+ */
+ Builder withSrcMac(MacAddress srcMac);
+
+ /**
+ * Sets destination MAC address.
+ *
+ * @param dstMac destination MAC address
+ * @return builder instance
+ */
+ Builder withDstMac(MacAddress dstMac);
+
+ /**
+ * Sets flow level stats info.
+ *
+ * @param statsInfo flow level stats info
+ * @return builder instance
+ */
+ Builder withStatsInfo(StatsInfo statsInfo);
+
+ /**
+ * Creates a FlowInfo instance.
+ *
+ * @return FlowInfo instance
+ */
+ FlowInfo build();
+ }
+}
diff --git a/apps/openstacktelemetry/api/src/main/java/org/onosproject/openstacktelemetry/api/StatsInfo.java b/apps/openstacktelemetry/api/src/main/java/org/onosproject/openstacktelemetry/api/StatsInfo.java
new file mode 100644
index 0000000..a256527
--- /dev/null
+++ b/apps/openstacktelemetry/api/src/main/java/org/onosproject/openstacktelemetry/api/StatsInfo.java
@@ -0,0 +1,167 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * 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.openstacktelemetry.api;
+
+/**
+ * Stats info interface.
+ */
+public interface StatsInfo {
+
+ /**
+ * Obtains startup time.
+ *
+ * @return startup time
+ */
+ long startupTime();
+
+ /**
+ * Obtains first packet arrival time.
+ *
+ * @return first packet arrival time
+ */
+ long fstPktArrTime();
+
+ /**
+ * Obtains last packet offset.
+ *
+ * @return last packet offset
+ */
+ int lstPktOffset();
+
+ /**
+ * Obtains previous accumulated bytes.
+ *
+ * @return previous accumulated bytes
+ */
+ long prevAccBytes();
+
+ /**
+ * Obtains previous accumulated packets.
+ *
+ * @return previous accumulated packets
+ */
+ int prevAccPkts();
+
+ /**
+ * Obtains current accumulated bytes.
+ *
+ * @return current accumulated bytes
+ */
+ long currAccBytes();
+
+ /**
+ * Obtains current accumulated packets.
+ *
+ * @return current accumulated packets
+ */
+ int currAccPkts();
+
+ /**
+ * Obtains error packets stats.
+ *
+ * @return error packets stats
+ */
+ short errorPkts();
+
+ /**
+ * Obtains dropped packets stats.
+ *
+ * @return dropped packets stats
+ */
+ short dropPkts();
+
+ interface Builder {
+
+ /**
+ * Sets startup time.
+ *
+ * @param startupTime startup time
+ * @return builder instance
+ */
+ Builder withStartupTime(long startupTime);
+
+ /**
+ * Sets first packet arrival time.
+ *
+ * @param fstPktArrTime first packet arrival time
+ * @return builder instance
+ */
+ Builder withFstPktArrTime(long fstPktArrTime);
+
+ /**
+ * Sets last packet offset.
+ *
+ * @param lstPktOffset last packet offset
+ * @return builder instance
+ */
+ Builder withLstPktOffset(int lstPktOffset);
+
+ /**
+ * Sets previous accumulated bytes.
+ *
+ * @param prevAccBytes previous accumulated bytes
+ * @return builder instance
+ */
+ Builder withPrevAccBytes(long prevAccBytes);
+
+ /**
+ * Sets previous accumulated packets.
+ *
+ * @param prevAccPkts previous accumulated packets
+ * @return builder instance
+ */
+ Builder withPrevAccPkts(int prevAccPkts);
+
+ /**
+ * Sets current accumulated bytes.
+ *
+ * @param currAccBytes current accumulated bytes
+ * @return builder instance
+ */
+ Builder withCurrAccBytes(long currAccBytes);
+
+ /**
+ * Sets currently accumulated packets.
+ *
+ * @param currAccPkts current accumulated packets
+ * @return builder instance
+ */
+ Builder withCurrAccPkts(int currAccPkts);
+
+ /**
+ * Sets error packets stats.
+ *
+ * @param errorPkts error packets stats
+ * @return builder instance
+ */
+ Builder withErrorPkts(short errorPkts);
+
+ /**
+ * Sets dropped packets stats.
+ *
+ * @param dropPkts dropped packets stats
+ * @return builder instance
+ */
+ Builder withDropPkts(short dropPkts);
+
+ /**
+ * Creates flow level stats info instance.
+ *
+ * @return stats info instance
+ */
+ StatsInfo build();
+ }
+}