[ONOS-5916] Add a mapping instruction interface with impl classes

Change-Id: I21399cd9853fe4604641af5ad57cd61f02cf354c
diff --git a/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/DefaultMappingKey.java b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/DefaultMappingKey.java
index 96feb4a..965767b 100644
--- a/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/DefaultMappingKey.java
+++ b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/DefaultMappingKey.java
@@ -15,8 +15,14 @@
  */
 package org.onosproject.mapping;
 
+import org.onosproject.mapping.address.MappingAddress;
+
 /**
  * Default mapping key implementation.
  */
 public class DefaultMappingKey implements MappingKey {
+    @Override
+    public MappingAddress address() {
+        return null;
+    }
 }
diff --git a/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/DefaultMappingValue.java b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/DefaultMappingValue.java
index 3987218..2575764 100644
--- a/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/DefaultMappingValue.java
+++ b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/DefaultMappingValue.java
@@ -15,8 +15,23 @@
  */
 package org.onosproject.mapping;
 
+import org.onosproject.mapping.address.MappingAddress;
+import org.onosproject.mapping.instructions.MappingInstruction;
+
+import java.util.List;
+
 /**
  * Default mapping value implementation.
  */
 public class DefaultMappingValue implements MappingValue {
+
+    @Override
+    public MappingAddress address() {
+        return null;
+    }
+
+    @Override
+    public List<MappingInstruction> instructions() {
+        return null;
+    }
 }
diff --git a/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingKey.java b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingKey.java
index 37c0a1a..cbce738 100644
--- a/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingKey.java
+++ b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingKey.java
@@ -15,8 +15,35 @@
  */
 package org.onosproject.mapping;
 
+import org.onosproject.mapping.address.MappingAddress;
+
 /**
- * Abstraction of key of mapping information.
+ * Abstraction of network mapping key.
  */
 public interface MappingKey {
+
+    /**
+     * Returns a mapping address.
+     *
+     * @return a mapping address
+     */
+    MappingAddress address();
+
+    interface Builder {
+
+        /**
+         * Specifies a mapping address.
+         *
+         * @param address mapping address
+         * @return a mapping key builder
+         */
+        Builder withAddress(MappingAddress address);
+
+        /**
+         * Builds an immutable mapping key.
+         *
+         * @return a mapping key
+         */
+        MappingKey build();
+    }
 }
diff --git a/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingValue.java b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingValue.java
index 5c68eef..a41d749 100644
--- a/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingValue.java
+++ b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/MappingValue.java
@@ -15,8 +15,53 @@
  */
 package org.onosproject.mapping;
 
+import org.onosproject.mapping.address.MappingAddress;
+import org.onosproject.mapping.instructions.MappingInstruction;
+
+import java.util.List;
+
 /**
  * Abstraction of value of mapping information.
  */
 public interface MappingValue {
+
+    /**
+     * Obtains a mapping address.
+     *
+     * @return a mapping address
+     */
+    MappingAddress address();
+
+    /**
+     * Obtains a collection of mapping instructions.
+     *
+     * @return a collection of mapping instructions
+     */
+    List<MappingInstruction> instructions();
+
+    interface Builder {
+
+        /**
+         * Specifies the mapping address.
+         *
+         * @param address mapping address
+         * @return a mapping value builder
+         */
+        Builder withAddress(MappingAddress address);
+
+        /**
+         * Specifies a collection of mapping instructions.
+         *
+         * @param instructions a collection of mapping instructions
+         * @return a mapping value builder
+         */
+        Builder withInstructions(List<MappingInstruction> instructions);
+
+        /**
+         * Builds an immutable mapping value.
+         *
+         * @return a mapping value
+         */
+        MappingValue build();
+    }
 }
diff --git a/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/address/MappingAddress.java b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/address/MappingAddress.java
new file mode 100644
index 0000000..c1473e9
--- /dev/null
+++ b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/address/MappingAddress.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2017-present 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.mapping.address;
+
+/**
+ * Presentation of a single mapping selection.
+ */
+public interface MappingAddress {
+
+    /**
+     * Types of address to which the mapping criterion may apply.
+     */
+    enum Type {
+
+        /** IPv4 Address. */
+        IPV4,
+
+        /** IPv6 Address. */
+        IPV6,
+
+        /** Autonomous System Number. */
+        AS,
+
+        /** Ethernet Address (MAC Address). */
+        ETH,
+
+        /** Distinguished Name. */
+        DN,
+
+        /** Extension Address. */
+        EXTENSION
+    }
+
+    /**
+     * Returns the type of mapping address.
+     *
+     * @return type of mapping address
+     */
+    Type type();
+}
diff --git a/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/address/package-info.java b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/address/package-info.java
new file mode 100644
index 0000000..8fb2106
--- /dev/null
+++ b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/address/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2017-present 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.
+ */
+
+/**
+ * Mapping address package.
+ */
+package org.onosproject.mapping.address;
\ No newline at end of file
diff --git a/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/instructions/ActionMappingInstruction.java b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/instructions/ActionMappingInstruction.java
new file mode 100644
index 0000000..8c49988
--- /dev/null
+++ b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/instructions/ActionMappingInstruction.java
@@ -0,0 +1,201 @@
+/*
+ * Copyright 2017-present 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.mapping.instructions;
+
+import java.util.Objects;
+
+/**
+ * Abstraction of an action mapping instruction.
+ */
+public abstract class ActionMappingInstruction implements MappingInstruction {
+
+    /**
+     * Represents the type of mapping action.
+     */
+    public enum ActionType {
+
+        /**
+         * Signifies that the traffic requires no action.
+         */
+        NO_ACTION,
+
+        /**
+         * Signifies that the traffic requires native forwarding.
+         */
+        NATIVE_FORWARD,
+
+        /**
+         * Signifies that the traffic requires forwarding with mapping information.
+         */
+        FORWARD,
+
+        /**
+         * Signifies that the traffic should be dropped.
+         */
+        DROP;
+    }
+
+    public abstract ActionType subtype();
+
+    @Override
+    public final Type type() {
+        return Type.ACTION;
+    }
+
+    /**
+     * Represents a No Action mapping instruction.
+     */
+    public static final class NoActionMappingInstruction
+                                            extends ActionMappingInstruction {
+
+        NoActionMappingInstruction() {
+        }
+
+        @Override
+        public ActionType subtype() {
+            return ActionType.NO_ACTION;
+        }
+
+        @Override
+        public String toString() {
+            return subtype().toString();
+        }
+
+        @Override
+        public int hashCode() {
+            return Objects.hash(type(), subtype());
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj instanceof NoActionMappingInstruction) {
+                return true;
+            }
+            return false;
+        }
+    }
+
+    /**
+     * Represents a Native Forward mapping instruction.
+     */
+    public static final class NativeForwardMappingInstruction
+                                            extends ActionMappingInstruction {
+
+        NativeForwardMappingInstruction() {
+        }
+
+        @Override
+        public ActionType subtype() {
+            return ActionType.NATIVE_FORWARD;
+        }
+
+        @Override
+        public String toString() {
+            return subtype().toString();
+        }
+
+        @Override
+        public int hashCode() {
+            return Objects.hash(type(), subtype());
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj instanceof NativeForwardMappingInstruction) {
+                return true;
+            }
+            return false;
+        }
+    }
+
+    /**
+     * Represents a Forward mapping instruction.
+     */
+    public static final class ForwardMappingInstruction
+                                            extends ActionMappingInstruction {
+
+        ForwardMappingInstruction() {
+        }
+
+        @Override
+        public ActionType subtype() {
+            return ActionType.FORWARD;
+        }
+
+        @Override
+        public String toString() {
+            return subtype().toString();
+        }
+
+        @Override
+        public int hashCode() {
+            return Objects.hash(type(), subtype());
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj instanceof ForwardMappingInstruction) {
+                return true;
+            }
+            return false;
+        }
+    }
+
+    /**
+     * Represents a Drop mapping instruction.
+     */
+    public static final class DropMappingInstruction
+                                            extends ActionMappingInstruction {
+
+        DropMappingInstruction() {
+        }
+
+        @Override
+        public ActionType subtype() {
+            return ActionType.DROP;
+        }
+
+        @Override
+        public String toString() {
+            return subtype().toString();
+        }
+
+        @Override
+        public int hashCode() {
+            return Objects.hash(type(), subtype());
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj instanceof DropMappingInstruction) {
+                return true;
+            }
+            return false;
+        }
+    }
+}
diff --git a/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/instructions/MappingInstruction.java b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/instructions/MappingInstruction.java
new file mode 100644
index 0000000..81faf05
--- /dev/null
+++ b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/instructions/MappingInstruction.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2017-present 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.mapping.instructions;
+
+/**
+ * Presentation of a single mapping instruction.
+ */
+public interface MappingInstruction {
+
+    /**
+     * Represents the type of mapping instruction.
+     */
+    enum Type {
+
+        /**
+         * Signifies that the traffic should be uni-casted with TE parameters.
+         */
+        UNICAST,
+
+        /**
+         * Signifies that the traffic should be multi-casted with TE parameters.
+         */
+        MULTICAST,
+
+        /**
+         * Signifies that the traffic should be treated with a certain action.
+         */
+        ACTION,
+
+        /**
+         * Signifies that an extension instruction will be used.
+         */
+        EXTENSION
+    }
+
+    /**
+     * Returns the type of instruction.
+     *
+     * @return type of instruction
+     */
+    Type type();
+}
diff --git a/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/instructions/MappingInstructions.java b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/instructions/MappingInstructions.java
new file mode 100644
index 0000000..0360b44
--- /dev/null
+++ b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/instructions/MappingInstructions.java
@@ -0,0 +1,184 @@
+/*
+ * Copyright 2017-present 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.mapping.instructions;
+
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.flow.instructions.ExtensionTreatment;
+
+import java.util.Objects;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.onosproject.mapping.instructions.MulticastMappingInstruction.*;
+import static org.onosproject.mapping.instructions.UnicastMappingInstruction.*;
+
+/**
+ * Factory class for creating various mapping instructions.
+ */
+public final class MappingInstructions {
+
+    private static final String SEPARATOR = ":";
+
+    /**
+     * Prevents instantiation from external.
+     */
+    private MappingInstructions() {}
+
+    /**
+     * Creates an unicast weight instruction.
+     *
+     * @param weight weight value
+     * @return an unicast mapping instruction
+     */
+    public static UnicastMappingInstruction unicastWeight(int weight) {
+        return new UnicastMappingInstruction.WeightMappingInstruction(
+                                            UnicastType.WEIGHT, weight);
+    }
+
+    /**
+     * Creates an unicast priority instruction.
+     *
+     * @param priority priority value
+     * @return an unicast mapping instruction
+     */
+    public static UnicastMappingInstruction unicastPriority(int priority) {
+        return new UnicastMappingInstruction.PriorityMappingInstruction(
+                                            UnicastType.PRIORITY, priority);
+    }
+
+    /**
+     * Creates a multicast weight instruction.
+     *
+     * @param weight weight value
+     * @return a multicast mapping instruction
+     */
+    public static MulticastMappingInstruction multicastWeight(int weight) {
+        return new MulticastMappingInstruction.WeightMappingInstruction(
+                                                MulticastType.WEIGHT, weight);
+    }
+
+    /**
+     * Creates a multicast priority instruction.
+     *
+     * @param priority priority value
+     * @return a multicast mapping instruction
+     */
+    public static MulticastMappingInstruction multicastPriority(int priority) {
+        return new MulticastMappingInstruction.PriorityMappingInstruction(
+                                                MulticastType.PRIORITY, priority);
+    }
+
+    /**
+     * Creates no action mapping instruction.
+     *
+     * @return an action mapping instruction
+     */
+    public static ActionMappingInstruction noAction() {
+        return new ActionMappingInstruction.NoActionMappingInstruction();
+    }
+
+    /**
+     * Creates native forward mapping instruction.
+     *
+     * @return an action mapping instruction
+     */
+    public static ActionMappingInstruction nativeForwardAction() {
+        return new ActionMappingInstruction.NativeForwardMappingInstruction();
+    }
+
+    /**
+     * Creates forward mapping instruction.
+     *
+     * @return an action mapping instruction
+     */
+    public static ActionMappingInstruction forwardAction() {
+        return new ActionMappingInstruction.ForwardMappingInstruction();
+    }
+
+    /**
+     * Creates drop mapping instruction.
+     *
+     * @return an action mapping instruction
+     */
+    public static ActionMappingInstruction dropAction() {
+        return new ActionMappingInstruction.DropMappingInstruction();
+    }
+
+    /**
+     * Creates an extension mapping instruction.
+     *
+     * @param extension extension mapping instruction
+     * @param deviceId device identifier
+     * @return extension mapping instruction
+     */
+    public static ExtensionMappingInstructionWrapper extension(ExtensionTreatment extension,
+                                                               DeviceId deviceId) {
+        checkNotNull(extension, "Extension instruction cannot be null");
+        checkNotNull(deviceId, "Device ID cannot be null");
+        return new ExtensionMappingInstructionWrapper(extension, deviceId);
+    }
+
+    /**
+     * Extension mapping instruction.
+     */
+    public static class ExtensionMappingInstructionWrapper implements MappingInstruction {
+
+        private final ExtensionTreatment extensionTreatment;
+        private final DeviceId deviceId;
+
+        ExtensionMappingInstructionWrapper(ExtensionTreatment extension, DeviceId deviceId) {
+            this.extensionTreatment = extension;
+            this.deviceId = deviceId;
+        }
+
+        public ExtensionTreatment extensionMappingInstruction() {
+            return extensionTreatment;
+        }
+
+        public DeviceId deviceId() {
+            return deviceId;
+        }
+
+        @Override
+        public Type type() {
+            return Type.EXTENSION;
+        }
+
+        @Override
+        public String toString() {
+            return type().toString() + SEPARATOR + deviceId + "/" + extensionTreatment;
+        }
+
+        @Override
+        public int hashCode() {
+            return Objects.hash(type().ordinal(), extensionTreatment, deviceId);
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj instanceof ExtensionMappingInstructionWrapper) {
+                ExtensionMappingInstructionWrapper that =
+                                        (ExtensionMappingInstructionWrapper) obj;
+                return Objects.equals(extensionTreatment, that.extensionTreatment)
+                        && Objects.equals(deviceId, that.deviceId);
+
+            }
+            return false;
+        }
+    }
+}
diff --git a/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/instructions/MulticastMappingInstruction.java b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/instructions/MulticastMappingInstruction.java
new file mode 100644
index 0000000..7008aa5
--- /dev/null
+++ b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/instructions/MulticastMappingInstruction.java
@@ -0,0 +1,151 @@
+/*
+ * Copyright 2017-present 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.mapping.instructions;
+
+import java.util.Objects;
+
+/**
+ * Abstraction of a multi-cast mapping traffic engineering.
+ */
+public abstract class MulticastMappingInstruction implements MappingInstruction {
+
+    private static final String SEPARATOR = ":";
+
+    /**
+     * Represents the type of Multicast traffic engineering.
+     */
+    public enum MulticastType {
+
+        /**
+         * Signifies the weight value that used in multicast traffic engineering.
+         */
+        WEIGHT,
+
+        /**
+         * Signifies the priority value that used in multicast traffic engineering.
+         */
+        PRIORITY
+    }
+
+    public abstract MulticastType subtype();
+
+    @Override
+    public final Type type() {
+        return Type.MULTICAST;
+    }
+
+    /**
+     * Represents a multicast weight configuration instruction.
+     */
+    public static final class WeightMappingInstruction extends MulticastMappingInstruction {
+
+        private final MulticastType subtype;
+        private final int weight;
+
+        WeightMappingInstruction(MulticastType subType, int weight) {
+            this.subtype = subType;
+            this.weight = weight;
+        }
+
+        @Override
+        public MulticastType subtype() {
+            return this.subtype;
+        }
+
+        /**
+         * Returns weight value of multicast TE.
+         *
+         * @return weight value of multicast TE
+         */
+        public int weight() {
+            return this.weight;
+        }
+
+        @Override
+        public String toString() {
+            return subtype().toString() + SEPARATOR + weight;
+        }
+
+        @Override
+        public int hashCode() {
+            return Objects.hash(type(), subtype, weight);
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj instanceof WeightMappingInstruction) {
+                WeightMappingInstruction that = (WeightMappingInstruction) obj;
+                return  Objects.equals(weight, that.weight) &&
+                        Objects.equals(subtype, that.subtype);
+            }
+            return false;
+        }
+    }
+
+    /**
+     * Represents a multicast priority configuration instruction.
+     */
+    public static final class PriorityMappingInstruction extends MulticastMappingInstruction {
+
+        private final MulticastType subtype;
+        private final int priority;
+
+        PriorityMappingInstruction(MulticastType subType, int priority) {
+            this.subtype = subType;
+            this.priority = priority;
+        }
+
+        @Override
+        public MulticastType subtype() {
+            return this.subtype;
+        }
+
+        /**
+         * Returns priority value of multicast TE.
+         *
+         * @return priority value of multicast TE
+         */
+        public int priority() {
+            return this.priority;
+        }
+
+        @Override
+        public String toString() {
+            return subtype().toString() + SEPARATOR + priority;
+        }
+
+        @Override
+        public int hashCode() {
+            return Objects.hash(type(), subtype, priority);
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj instanceof PriorityMappingInstruction) {
+                PriorityMappingInstruction that = (PriorityMappingInstruction) obj;
+                return  Objects.equals(priority, that.priority) &&
+                        Objects.equals(subtype, that.subtype);
+            }
+            return false;
+        }
+    }
+}
diff --git a/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/instructions/UnicastMappingInstruction.java b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/instructions/UnicastMappingInstruction.java
new file mode 100644
index 0000000..2033919
--- /dev/null
+++ b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/instructions/UnicastMappingInstruction.java
@@ -0,0 +1,151 @@
+/*
+ * Copyright 2017-present 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.mapping.instructions;
+
+import java.util.Objects;
+
+/**
+ * Abstraction of an uni-cast mapping traffic engineering.
+ */
+public abstract class UnicastMappingInstruction implements MappingInstruction {
+
+    private static final String SEPARATOR = ":";
+
+    /**
+     * Represents the type of Unicast traffic engineering.
+     */
+    public enum UnicastType {
+
+        /**
+         * Signifies the weight value that used in unicast traffic engineering.
+         */
+        WEIGHT,
+
+        /**
+         * Signifies the priority value that used in unicast traffic engineering.
+         */
+        PRIORITY
+    }
+
+    public abstract UnicastType subtype();
+
+    @Override
+    public final Type type() {
+        return Type.UNICAST;
+    }
+
+    /**
+     * Represents an unicast weight configuration instruction.
+     */
+    public static final class WeightMappingInstruction extends UnicastMappingInstruction {
+
+        private final UnicastType subtype;
+        private final int weight;
+
+        WeightMappingInstruction(UnicastType subType, int weight) {
+            this.subtype = subType;
+            this.weight = weight;
+        }
+
+        @Override
+        public UnicastType subtype() {
+            return subtype;
+        }
+
+        /**
+         * Returns weight value of unicast TE.
+         *
+         * @return weight value of unicast TE
+         */
+        public int weight() {
+            return this.weight;
+        }
+
+        @Override
+        public String toString() {
+            return subtype().toString() + SEPARATOR + weight;
+        }
+
+        @Override
+        public int hashCode() {
+            return Objects.hash(type(), subtype, weight);
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj instanceof WeightMappingInstruction) {
+                WeightMappingInstruction that = (WeightMappingInstruction) obj;
+                return  Objects.equals(weight, that.weight) &&
+                        Objects.equals(subtype, that.subtype);
+            }
+            return false;
+        }
+    }
+
+    /**
+     * Represents an unicast priority configuration instruction.
+     */
+    public static final class PriorityMappingInstruction extends UnicastMappingInstruction {
+
+        private final UnicastType subtype;
+        private final int priority;
+
+        PriorityMappingInstruction(UnicastType subType, int priority) {
+            this.subtype = subType;
+            this.priority = priority;
+        }
+
+        @Override
+        public UnicastType subtype() {
+            return this.subtype;
+        }
+
+        /**
+         * Returns priority value of unicast TE.
+         *
+         * @return priority value of unicast TE
+         */
+        public int priority() {
+            return this.priority;
+        }
+
+        @Override
+        public String toString() {
+            return subtype().toString() + SEPARATOR + priority;
+        }
+
+        @Override
+        public int hashCode() {
+            return Objects.hash(type(), subtype, priority);
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj instanceof PriorityMappingInstruction) {
+                PriorityMappingInstruction that = (PriorityMappingInstruction) obj;
+                return  Objects.equals(priority, that.priority) &&
+                        Objects.equals(subtype, that.subtype);
+            }
+            return false;
+        }
+    }
+}
diff --git a/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/instructions/package-info.java b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/instructions/package-info.java
new file mode 100644
index 0000000..2919f17
--- /dev/null
+++ b/apps/mappingmanagement/api/src/main/java/org/onosproject/mapping/instructions/package-info.java
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2017-present 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.
+ */
+/**
+ * Mapping instruction package.
+ */
+package org.onosproject.mapping.instructions;
\ No newline at end of file
diff --git a/apps/mappingmanagement/api/src/test/java/org/onosproject/mapping/instructions/MappingInstructionsTest.java b/apps/mappingmanagement/api/src/test/java/org/onosproject/mapping/instructions/MappingInstructionsTest.java
new file mode 100644
index 0000000..5bf628d
--- /dev/null
+++ b/apps/mappingmanagement/api/src/test/java/org/onosproject/mapping/instructions/MappingInstructionsTest.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2017-present 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.mapping.instructions;
+
+/**
+ * Unit tests for the MappingInstructions class.
+ */
+public class MappingInstructionsTest {
+}