[ONOS-4718] Implement LISP control message classes

Change-Id: I26ab3b8da383d8967c08e14b4f11f03e0663de73
diff --git a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispMapRegister.java b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispMapRegister.java
index 1b2987e..f041d2b 100644
--- a/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispMapRegister.java
+++ b/protocols/lisp/msg/src/main/java/org/onosproject/lisp/msg/protocols/DefaultLispMapRegister.java
@@ -15,22 +15,58 @@
  */
 package org.onosproject.lisp.msg.protocols;
 
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Lists;
 import io.netty.buffer.ByteBuf;
+import org.onlab.util.ImmutableByteSequence;
 
 import java.util.List;
 
 /**
  * Default LISP map register message class.
  */
-public class DefaultLispMapRegister implements LispMapRegister {
+public final class DefaultLispMapRegister implements LispMapRegister {
+
+    private final long nonce;
+    private final short keyId;
+    private final byte[] authenticationData;
+    private final byte recordCount;
+    private final List<LispMapRecord> mapRecords;
+    private final boolean proxyMapReply;
+    private final boolean wantMapNotify;
+
+    /**
+     * A private constructor that protects object instantiation from external.
+     *
+     * @param nonce              nonce
+     * @param keyId              key identifier
+     * @param authenticationData authentication data
+     * @param recordCount        record count number
+     * @param mapRecords         a collection of map records
+     * @param proxyMapReply      proxy map reply flag
+     * @param wantMapNotify      want map notify flag
+     */
+    private DefaultLispMapRegister(long nonce, short keyId,
+                                   byte[] authenticationData, byte recordCount,
+                                   List<LispMapRecord> mapRecords,
+                                   boolean proxyMapReply, boolean wantMapNotify) {
+        this.nonce = nonce;
+        this.keyId = keyId;
+        this.authenticationData = authenticationData;
+        this.recordCount = recordCount;
+        this.mapRecords = mapRecords;
+        this.proxyMapReply = proxyMapReply;
+        this.wantMapNotify = wantMapNotify;
+    }
+
     @Override
     public LispType getType() {
-        return null;
+        return LispType.LISP_MAP_REGISTER;
     }
 
     @Override
     public void writeTo(ByteBuf byteBuf) {
-
+        // TODO: serialize LispMapRegister message
     }
 
     @Override
@@ -40,84 +76,100 @@
 
     @Override
     public boolean isProxyMapReply() {
-        return false;
+        return proxyMapReply;
     }
 
     @Override
     public boolean isWantMapNotify() {
-        return false;
+        return wantMapNotify;
     }
 
     @Override
     public byte getRecordCount() {
-        return 0;
+        return recordCount;
     }
 
     @Override
     public long getNonce() {
-        return 0;
+        return nonce;
     }
 
     @Override
     public short getKeyId() {
-        return 0;
+        return keyId;
     }
 
     @Override
     public byte[] getAuthenticationData() {
-        return new byte[0];
+        return ImmutableByteSequence.copyFrom(this.authenticationData).asArray();
     }
 
     @Override
     public List<LispMapRecord> getLispRecords() {
-        return null;
+        return ImmutableList.copyOf(mapRecords);
     }
 
     public static final class DefaultRegisterBuilder implements RegisterBuilder {
 
-        @Override
-        public LispMessage build() {
-            return null;
-        }
+        private long nonce;
+        private short keyId;
+        private byte[] authenticationData;
+        private byte recordCount;
+        private final List<LispMapRecord> mapRecords = Lists.newArrayList();
+        private boolean proxyMapReply;
+        private boolean wantMapNotify;
 
         @Override
         public LispType getType() {
-            return null;
+            return LispType.LISP_MAP_REGISTER;
         }
 
         @Override
-        public RegisterBuilder withIsProxyMapReply(boolean isProxyMapReply) {
-            return null;
+        public RegisterBuilder withIsProxyMapReply(boolean proxyMapReply) {
+            this.proxyMapReply = proxyMapReply;
+            return this;
         }
 
         @Override
-        public RegisterBuilder withIsWantMapNotify(boolean isWantMapNotify) {
-            return null;
+        public RegisterBuilder withIsWantMapNotify(boolean wantMapNotify) {
+            this.wantMapNotify = wantMapNotify;
+            return this;
         }
 
         @Override
         public RegisterBuilder withRecordCount(byte recordCount) {
-            return null;
+            this.recordCount = recordCount;
+            return this;
         }
 
         @Override
         public RegisterBuilder withNonce(long nonce) {
-            return null;
+            this.nonce = nonce;
+            return this;
         }
 
         @Override
         public RegisterBuilder withKeyId(short keyId) {
-            return null;
+            this.keyId = keyId;
+            return this;
         }
 
         @Override
         public RegisterBuilder withAuthenticationData(byte[] authenticationData) {
-            return null;
+            this.authenticationData = authenticationData;
+            return this;
         }
 
         @Override
         public RegisterBuilder addRecord(LispMapRecord record) {
-            return null;
+            this.mapRecords.add(record);
+            return this;
+        }
+
+        @Override
+        public LispMessage build() {
+            return new DefaultLispMapRegister(nonce, keyId, authenticationData,
+                    recordCount, mapRecords, proxyMapReply, wantMapNotify);
         }
     }
 }