[ONOS-3856] Implement BGP flow specication components operator value.
Change-Id: I4262aea2eb0f011d49b424ac34ad675897c07b03
diff --git a/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpFsOperatorValue.java b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpFsOperatorValue.java
new file mode 100644
index 0000000..833b36b
--- /dev/null
+++ b/protocols/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/BgpFsOperatorValue.java
@@ -0,0 +1,86 @@
+/*
+ * 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.types;
+
+import java.util.Arrays;
+import java.util.Objects;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.MoreObjects;
+
+/**
+ * BGP flow specification type operator and value implementation.
+ */
+public class BgpFsOperatorValue {
+
+ protected static final Logger log = LoggerFactory.getLogger(BgpFsOperatorValue.class);
+
+ private final byte option;
+ private final byte[] value;
+
+ /**
+ * constructor to initialize.
+ *
+ * @param option for a specific flow type
+ * @param value for a specific flow type
+ */
+ public BgpFsOperatorValue(byte option, byte[] value) {
+ this.option = option;
+ this.value = Arrays.copyOf(value, value.length);
+ }
+
+ /**
+ * Returns option of the flow type.
+ *
+ * @return option of the flow type
+ */
+ public byte option() {
+ return option;
+ }
+
+ /**
+ * Returns value of the flow type.
+ *
+ * @return value of the flow type
+ */
+ public byte[] value() {
+ return value;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(option, Arrays.hashCode(value));
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof BgpFsOperatorValue) {
+ BgpFsOperatorValue other = (BgpFsOperatorValue) obj;
+ return Objects.equals(this.option, other.option) && Arrays.equals(this.value, other.value);
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(getClass()).add("option", option).add("value", value).toString();
+ }
+}
diff --git a/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/BgpFsOperatorValueTest.java b/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/BgpFsOperatorValueTest.java
new file mode 100644
index 0000000..0dcb741
--- /dev/null
+++ b/protocols/bgp/bgpio/src/test/java/org/onosproject/bgpio/types/BgpFsOperatorValueTest.java
@@ -0,0 +1,37 @@
+/*
+ * 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.types;
+
+import org.junit.Test;
+
+import com.google.common.testing.EqualsTester;
+
+/**
+ * Test for BgpFsSourcePrefix flow specification component.
+ */
+public class BgpFsOperatorValueTest {
+ BgpFsOperatorValue tlv1 = new BgpFsOperatorValue((byte) 1, new byte[100]);
+ BgpFsOperatorValue sameAsTlv1 = new BgpFsOperatorValue((byte) 1, new byte[100]);
+ BgpFsOperatorValue tlv2 = new BgpFsOperatorValue((byte) 1, new byte[200]);
+
+ @Test
+ public void testEquality() {
+ new EqualsTester()
+ .addEqualityGroup(tlv1, sameAsTlv1)
+ .addEqualityGroup(tlv2)
+ .testEquals();
+ }
+}