[ONOS-3856] Implement BGP flow spec RIB out flow specification details.

Change-Id: I9bb65a29c6182009162f1d3d1b7756fa4909240c
diff --git a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/flowspec/BgpFlowSpecDetails.java b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/flowspec/BgpFlowSpecDetails.java
new file mode 100755
index 0000000..2f2eb6f
--- /dev/null
+++ b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/flowspec/BgpFlowSpecDetails.java
@@ -0,0 +1,130 @@
+/*
+ * 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.bgpio.protocol.flowspec;
+
+import java.util.Iterator;
+import java.util.List;
+import java.util.Objects;
+import org.onosproject.bgpio.types.BgpValueType;
+import org.onosproject.bgpio.types.RouteDistinguisher;
+import com.google.common.base.MoreObjects;
+
+/**
+ * This Class stores flow specification components and action.
+ */
+public class BgpFlowSpecDetails {
+    private List<BgpValueType> flowSpecComponents;
+    BgpValueType fsActionTlv;
+    RouteDistinguisher routeDistinguisher;
+
+    /**
+     * Flow specification details object constructor with the parameter.
+     *
+     * @param flowSpecComponents flow specification components
+     */
+    public BgpFlowSpecDetails(List<BgpValueType> flowSpecComponents) {
+        this.flowSpecComponents = flowSpecComponents;
+    }
+
+    /**
+     * Returns flow specification action tlv.
+     *
+     * @return flow specification action tlv
+     */
+    public BgpValueType fsActionTlv() {
+        return this.fsActionTlv;
+    }
+
+    /**
+     * Set flow specification action tlv.
+     *
+     * @param fsActionTlv flow specification action tlv
+     */
+    public void setFsActionTlv(BgpValueType fsActionTlv) {
+        this.fsActionTlv = fsActionTlv;
+    }
+
+    /**
+     * Returns route distinguisher for the flow specification components.
+     *
+     * @return route distinguisher for the flow specification components
+     */
+    public RouteDistinguisher routeDistinguisher() {
+        return this.routeDistinguisher;
+    }
+
+    /**
+     * Set route distinguisher for flow specification component.
+     *
+     * @param routeDistinguisher route distinguisher
+     */
+    public void setRouteDistinguiher(RouteDistinguisher routeDistinguisher) {
+        this.routeDistinguisher = routeDistinguisher;
+    }
+
+    /**
+     * Returns flow specification components.
+     *
+     * @return flow specification components
+     */
+    public List<BgpValueType> flowSpecComponents() {
+        return this.flowSpecComponents;
+    }
+
+    @Override
+    public int hashCode() {
+        return Objects.hash(flowSpecComponents);
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+
+        if (obj instanceof BgpFlowSpecDetails) {
+            int countObjSubTlv = 0;
+            int countOtherSubTlv = 0;
+            boolean isCommonSubTlv = true;
+            BgpFlowSpecDetails other = (BgpFlowSpecDetails) obj;
+            Iterator<BgpValueType> objListIterator = other.flowSpecComponents.iterator();
+            countOtherSubTlv = other.flowSpecComponents.size();
+            countObjSubTlv = flowSpecComponents.size();
+            if (countObjSubTlv != countOtherSubTlv) {
+                return false;
+            } else {
+                while (objListIterator.hasNext() && isCommonSubTlv) {
+                    BgpValueType subTlv = objListIterator.next();
+                    if (flowSpecComponents.contains(subTlv) && other.flowSpecComponents.contains(subTlv)) {
+                        isCommonSubTlv = Objects.equals(flowSpecComponents.get(flowSpecComponents.indexOf(subTlv)),
+                                            other.flowSpecComponents.get(other.flowSpecComponents.indexOf(subTlv)));
+                    } else {
+                        isCommonSubTlv = false;
+                    }
+                }
+                return isCommonSubTlv;
+            }
+        }
+        return false;
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(getClass())
+                .add("flowSpecComponents", flowSpecComponents)
+                .toString();
+    }
+}
diff --git a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/flowspec/package-info.java b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/flowspec/package-info.java
new file mode 100755
index 0000000..59ff7c0
--- /dev/null
+++ b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/protocol/flowspec/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * 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.
+ */
+
+/**
+ * BGP Protocol specific flow specification component details.
+ */
+package org.onosproject.bgpio.protocol.flowspec;