Committed by
Thomas Vachuska
[ONOS-4718] Implement DefaultLispMapRecord class with interface mod
Change-Id: I1544fd52adc4081614b5471f8ab263efbd6c840b
Showing
3 changed files
with
75 additions
and
17 deletions
... | @@ -20,79 +20,130 @@ import org.onosproject.lisp.msg.types.LispAfiAddress; | ... | @@ -20,79 +20,130 @@ import org.onosproject.lisp.msg.types.LispAfiAddress; |
20 | /** | 20 | /** |
21 | * Default implementation of LispMapRecord. | 21 | * Default implementation of LispMapRecord. |
22 | */ | 22 | */ |
23 | -public class DefaultLispMapRecord implements LispMapRecord { | 23 | +public final class DefaultLispMapRecord implements LispMapRecord { |
24 | - | 24 | + |
25 | - private int recordTtl; | 25 | + private final int recordTtl; |
26 | - private int locatorCount; | 26 | + private final int locatorCount; |
27 | - private byte maskLength; | 27 | + private final byte maskLength; |
28 | - private LispMapReplyAction action; | 28 | + private final LispMapReplyAction action; |
29 | - private boolean authoritative; | 29 | + private final boolean authoritative; |
30 | - private short mapVersionNumber; | 30 | + private final short mapVersionNumber; |
31 | - private LispAfiAddress eidPrefixAfi; | 31 | + private final LispAfiAddress eidPrefixAfi; |
32 | + | ||
33 | + /** | ||
34 | + * A private constructor that protects object instantiation from external. | ||
35 | + * | ||
36 | + * @param recordTtl record time-to-live value | ||
37 | + * @param locatorCount locator's count number | ||
38 | + * @param maskLength mask length | ||
39 | + * @param action lisp map reply action | ||
40 | + * @param authoritative authoritative flag | ||
41 | + * @param mapVersionNumber map version number | ||
42 | + * @param eidPrefixAfi EID prefix AFI address | ||
43 | + */ | ||
44 | + private DefaultLispMapRecord(int recordTtl, int locatorCount, byte maskLength, | ||
45 | + LispMapReplyAction action, boolean authoritative, | ||
46 | + short mapVersionNumber, LispAfiAddress eidPrefixAfi) { | ||
47 | + this.recordTtl = recordTtl; | ||
48 | + this.locatorCount = locatorCount; | ||
49 | + this.maskLength = maskLength; | ||
50 | + this.action = action; | ||
51 | + this.authoritative = authoritative; | ||
52 | + this.mapVersionNumber = mapVersionNumber; | ||
53 | + this.eidPrefixAfi = eidPrefixAfi; | ||
54 | + } | ||
32 | 55 | ||
56 | + @Override | ||
33 | public int getRecordTtl() { | 57 | public int getRecordTtl() { |
34 | return recordTtl; | 58 | return recordTtl; |
35 | } | 59 | } |
36 | 60 | ||
61 | + @Override | ||
37 | public int getLocatorCount() { | 62 | public int getLocatorCount() { |
38 | return locatorCount; | 63 | return locatorCount; |
39 | } | 64 | } |
40 | 65 | ||
66 | + @Override | ||
41 | public byte getMaskLength() { | 67 | public byte getMaskLength() { |
42 | return maskLength; | 68 | return maskLength; |
43 | } | 69 | } |
44 | 70 | ||
71 | + @Override | ||
45 | public LispMapReplyAction getAction() { | 72 | public LispMapReplyAction getAction() { |
46 | return action; | 73 | return action; |
47 | } | 74 | } |
48 | 75 | ||
76 | + @Override | ||
49 | public boolean isAuthoritative() { | 77 | public boolean isAuthoritative() { |
50 | return authoritative; | 78 | return authoritative; |
51 | } | 79 | } |
52 | 80 | ||
81 | + @Override | ||
53 | public short getMapVersionNumber() { | 82 | public short getMapVersionNumber() { |
54 | return mapVersionNumber; | 83 | return mapVersionNumber; |
55 | } | 84 | } |
56 | 85 | ||
86 | + @Override | ||
57 | public LispAfiAddress getEidPrefixAfi() { | 87 | public LispAfiAddress getEidPrefixAfi() { |
58 | return eidPrefixAfi; | 88 | return eidPrefixAfi; |
59 | } | 89 | } |
60 | 90 | ||
61 | public static final class DefaultMapRecordBuilder implements MapRecordBuilder { | 91 | public static final class DefaultMapRecordBuilder implements MapRecordBuilder { |
62 | 92 | ||
93 | + private int recordTtl; | ||
94 | + private int locatorCount; | ||
95 | + private byte maskLength; | ||
96 | + private LispMapReplyAction action; | ||
97 | + private boolean authoritative; | ||
98 | + private short mapVersionNumber; | ||
99 | + private LispAfiAddress eidPrefixAfi; | ||
100 | + | ||
63 | @Override | 101 | @Override |
64 | public MapRecordBuilder withRecordTtl(int recordTtl) { | 102 | public MapRecordBuilder withRecordTtl(int recordTtl) { |
65 | - return null; | 103 | + this.recordTtl = recordTtl; |
104 | + return this; | ||
66 | } | 105 | } |
67 | 106 | ||
68 | @Override | 107 | @Override |
69 | public MapRecordBuilder withLocatorCount(int locatorCount) { | 108 | public MapRecordBuilder withLocatorCount(int locatorCount) { |
70 | - return null; | 109 | + this.locatorCount = locatorCount; |
110 | + return this; | ||
71 | } | 111 | } |
72 | 112 | ||
73 | @Override | 113 | @Override |
74 | public MapRecordBuilder withMaskLength(byte maskLength) { | 114 | public MapRecordBuilder withMaskLength(byte maskLength) { |
75 | - return null; | 115 | + this.maskLength = maskLength; |
116 | + return this; | ||
76 | } | 117 | } |
77 | 118 | ||
78 | @Override | 119 | @Override |
79 | public MapRecordBuilder withAction(LispMapReplyAction action) { | 120 | public MapRecordBuilder withAction(LispMapReplyAction action) { |
80 | - return null; | 121 | + this.action = action; |
122 | + return this; | ||
81 | } | 123 | } |
82 | 124 | ||
83 | @Override | 125 | @Override |
84 | public MapRecordBuilder withAuthoritative(boolean authoritative) { | 126 | public MapRecordBuilder withAuthoritative(boolean authoritative) { |
85 | - return null; | 127 | + this.authoritative = authoritative; |
128 | + return this; | ||
86 | } | 129 | } |
87 | 130 | ||
88 | @Override | 131 | @Override |
89 | public MapRecordBuilder withMapVersionNumber(short mapVersionNumber) { | 132 | public MapRecordBuilder withMapVersionNumber(short mapVersionNumber) { |
90 | - return null; | 133 | + this.mapVersionNumber = mapVersionNumber; |
134 | + return this; | ||
91 | } | 135 | } |
92 | 136 | ||
93 | @Override | 137 | @Override |
94 | public MapRecordBuilder withEidPrefixAfi(LispAfiAddress prefix) { | 138 | public MapRecordBuilder withEidPrefixAfi(LispAfiAddress prefix) { |
95 | - return null; | 139 | + this.eidPrefixAfi = prefix; |
140 | + return this; | ||
141 | + } | ||
142 | + | ||
143 | + @Override | ||
144 | + public LispMapRecord build() { | ||
145 | + return new DefaultLispMapRecord(recordTtl, locatorCount, maskLength, | ||
146 | + action, authoritative, mapVersionNumber, eidPrefixAfi); | ||
96 | } | 147 | } |
97 | } | 148 | } |
98 | } | 149 | } | ... | ... |
... | @@ -20,7 +20,7 @@ import org.onosproject.lisp.msg.types.LispAfiAddress; | ... | @@ -20,7 +20,7 @@ import org.onosproject.lisp.msg.types.LispAfiAddress; |
20 | /** | 20 | /** |
21 | * LISP EID record section which is part of LISP map request message. | 21 | * LISP EID record section which is part of LISP map request message. |
22 | */ | 22 | */ |
23 | -public class LispEidRecord { | 23 | +public final class LispEidRecord { |
24 | 24 | ||
25 | private final byte maskLength; | 25 | private final byte maskLength; |
26 | private final LispAfiAddress prefix; | 26 | private final LispAfiAddress prefix; | ... | ... |
... | @@ -131,5 +131,12 @@ public interface LispMapRecord { | ... | @@ -131,5 +131,12 @@ public interface LispMapRecord { |
131 | * @return MapRecordBuilder object | 131 | * @return MapRecordBuilder object |
132 | */ | 132 | */ |
133 | MapRecordBuilder withEidPrefixAfi(LispAfiAddress prefix); | 133 | MapRecordBuilder withEidPrefixAfi(LispAfiAddress prefix); |
134 | + | ||
135 | + /** | ||
136 | + * Builds map record. | ||
137 | + * | ||
138 | + * @return map record instance | ||
139 | + */ | ||
140 | + LispMapRecord build(); | ||
134 | } | 141 | } |
135 | } | 142 | } | ... | ... |
-
Please register or login to post a comment