[onos-2603] - BGP link name attribute.
Change-Id: Id3f7fd4e5b1e7d9415b5cc4f7e9fcfbc8bc085f6
diff --git a/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrName.java b/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrName.java
index 50591ec..e44ba7e 100755
--- a/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrName.java
+++ b/bgp/bgpio/src/main/java/org/onosproject/bgpio/types/attr/BgpLinkAttrName.java
@@ -16,7 +16,6 @@
package org.onosproject.bgpio.types.attr;
import java.util.Arrays;
-import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.bgpio.exceptions.BGPParseException;
@@ -46,11 +45,21 @@
*
* @param linkName link name
*/
- BgpLinkAttrName(byte[] linkName) {
+ public BgpLinkAttrName(byte[] linkName) {
this.linkName = Arrays.copyOf(linkName, linkName.length);
}
/**
+ * Returns object of this class with specified values.
+ *
+ * @param linkName Prefix Metric
+ * @return object of BgpLinkAttrName
+ */
+ public static BgpLinkAttrName of(byte[] linkName) {
+ return new BgpLinkAttrName(linkName);
+ }
+
+ /**
* Reads the BGP link attributes Name.
*
* @param cb Channel buffer
@@ -70,7 +79,7 @@
linkName = new byte[lsAttrLength];
cb.readBytes(linkName);
- return new BgpLinkAttrName(linkName);
+ return BgpLinkAttrName.of(linkName);
}
/**
@@ -78,7 +87,7 @@
*
* @return link name
*/
- byte[] getAttrLinkName() {
+ public byte[] attrLinkName() {
return linkName;
}
@@ -89,7 +98,7 @@
@Override
public int hashCode() {
- return Objects.hash(linkName);
+ return Arrays.hashCode(linkName);
}
@Override
@@ -100,7 +109,7 @@
if (obj instanceof BgpLinkAttrName) {
BgpLinkAttrName other = (BgpLinkAttrName) obj;
- return Objects.equals(linkName, other.linkName);
+ return Arrays.equals(linkName, other.linkName);
}
return false;
}