c6847d1c8bd621b18796ec49de2b2697dfe5fdd4
[onosfw.git] /
1 /*
2  * Copyright 2014-2015 Open Networking Laboratory
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.onosproject.net.flow.instructions;
17
18 import org.onosproject.net.OduSignalId;
19
20 import static com.google.common.base.MoreObjects.toStringHelper;
21
22 import java.util.Objects;
23
24 public abstract class L1ModificationInstruction implements Instruction {
25
26     /**
27      * Represents the type of traffic treatment.
28      */
29     public enum L1SubType {
30         /**
31          * ODU (Optical channel Data Unit) Signal Id modification.
32          */
33         ODU_SIGID
34     }
35
36     public abstract L1SubType subtype();
37
38     @Override
39     public final Type type() {
40         return Type.L1MODIFICATION;
41     }
42
43     /**
44      * Represents an L1 ODU (Optical channel Data Unit) Signal Id modification instruction.
45      */
46     public static final class ModOduSignalIdInstruction extends L1ModificationInstruction {
47
48         private final OduSignalId oduSignalId;
49
50         ModOduSignalIdInstruction(OduSignalId oduSignalId) {
51             this.oduSignalId = oduSignalId;
52         }
53
54         @Override
55         public L1SubType subtype() {
56             return L1SubType.ODU_SIGID;
57         }
58
59         public OduSignalId oduSignalId() {
60             return oduSignalId;
61         }
62
63         @Override
64         public int hashCode() {
65             return Objects.hash(oduSignalId);
66         }
67
68         @Override
69         public boolean equals(Object obj) {
70             if (this == obj) {
71                 return true;
72             }
73             if (!(obj instanceof ModOduSignalIdInstruction)) {
74                 return false;
75             }
76             final ModOduSignalIdInstruction that = (ModOduSignalIdInstruction) obj;
77             return Objects.equals(this.oduSignalId, that.oduSignalId);
78         }
79
80         @Override
81         public String toString() {
82             return toStringHelper(this)
83                     .add("oduSignalId", oduSignalId)
84                     .toString();
85         }
86     }
87
88 }