Committed by
Gerrit Code Review
[onos-2603] - BGP link name attribute.
Change-Id: Id3f7fd4e5b1e7d9415b5cc4f7e9fcfbc8bc085f6
Showing
1 changed file
with
15 additions
and
6 deletions
... | @@ -16,7 +16,6 @@ | ... | @@ -16,7 +16,6 @@ |
16 | package org.onosproject.bgpio.types.attr; | 16 | package org.onosproject.bgpio.types.attr; |
17 | 17 | ||
18 | import java.util.Arrays; | 18 | import java.util.Arrays; |
19 | -import java.util.Objects; | ||
20 | 19 | ||
21 | import org.jboss.netty.buffer.ChannelBuffer; | 20 | import org.jboss.netty.buffer.ChannelBuffer; |
22 | import org.onosproject.bgpio.exceptions.BGPParseException; | 21 | import org.onosproject.bgpio.exceptions.BGPParseException; |
... | @@ -46,11 +45,21 @@ public class BgpLinkAttrName implements BGPValueType { | ... | @@ -46,11 +45,21 @@ public class BgpLinkAttrName implements BGPValueType { |
46 | * | 45 | * |
47 | * @param linkName link name | 46 | * @param linkName link name |
48 | */ | 47 | */ |
49 | - BgpLinkAttrName(byte[] linkName) { | 48 | + public BgpLinkAttrName(byte[] linkName) { |
50 | this.linkName = Arrays.copyOf(linkName, linkName.length); | 49 | this.linkName = Arrays.copyOf(linkName, linkName.length); |
51 | } | 50 | } |
52 | 51 | ||
53 | /** | 52 | /** |
53 | + * Returns object of this class with specified values. | ||
54 | + * | ||
55 | + * @param linkName Prefix Metric | ||
56 | + * @return object of BgpLinkAttrName | ||
57 | + */ | ||
58 | + public static BgpLinkAttrName of(byte[] linkName) { | ||
59 | + return new BgpLinkAttrName(linkName); | ||
60 | + } | ||
61 | + | ||
62 | + /** | ||
54 | * Reads the BGP link attributes Name. | 63 | * Reads the BGP link attributes Name. |
55 | * | 64 | * |
56 | * @param cb Channel buffer | 65 | * @param cb Channel buffer |
... | @@ -70,7 +79,7 @@ public class BgpLinkAttrName implements BGPValueType { | ... | @@ -70,7 +79,7 @@ public class BgpLinkAttrName implements BGPValueType { |
70 | 79 | ||
71 | linkName = new byte[lsAttrLength]; | 80 | linkName = new byte[lsAttrLength]; |
72 | cb.readBytes(linkName); | 81 | cb.readBytes(linkName); |
73 | - return new BgpLinkAttrName(linkName); | 82 | + return BgpLinkAttrName.of(linkName); |
74 | } | 83 | } |
75 | 84 | ||
76 | /** | 85 | /** |
... | @@ -78,7 +87,7 @@ public class BgpLinkAttrName implements BGPValueType { | ... | @@ -78,7 +87,7 @@ public class BgpLinkAttrName implements BGPValueType { |
78 | * | 87 | * |
79 | * @return link name | 88 | * @return link name |
80 | */ | 89 | */ |
81 | - byte[] getAttrLinkName() { | 90 | + public byte[] attrLinkName() { |
82 | return linkName; | 91 | return linkName; |
83 | } | 92 | } |
84 | 93 | ||
... | @@ -89,7 +98,7 @@ public class BgpLinkAttrName implements BGPValueType { | ... | @@ -89,7 +98,7 @@ public class BgpLinkAttrName implements BGPValueType { |
89 | 98 | ||
90 | @Override | 99 | @Override |
91 | public int hashCode() { | 100 | public int hashCode() { |
92 | - return Objects.hash(linkName); | 101 | + return Arrays.hashCode(linkName); |
93 | } | 102 | } |
94 | 103 | ||
95 | @Override | 104 | @Override |
... | @@ -100,7 +109,7 @@ public class BgpLinkAttrName implements BGPValueType { | ... | @@ -100,7 +109,7 @@ public class BgpLinkAttrName implements BGPValueType { |
100 | 109 | ||
101 | if (obj instanceof BgpLinkAttrName) { | 110 | if (obj instanceof BgpLinkAttrName) { |
102 | BgpLinkAttrName other = (BgpLinkAttrName) obj; | 111 | BgpLinkAttrName other = (BgpLinkAttrName) obj; |
103 | - return Objects.equals(linkName, other.linkName); | 112 | + return Arrays.equals(linkName, other.linkName); |
104 | } | 113 | } |
105 | return false; | 114 | return false; |
106 | } | 115 | } | ... | ... |
-
Please register or login to post a comment