blob: b72dd7bce2cacba9f93302aed1c61744d34d0e7f [file] [log] [blame]
Yafit Hadar52d81552015-10-07 12:26:52 +03001/*
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 */
16package org.onosproject.net.flow.instructions;
17
18import org.onosproject.net.OduSignalId;
19
20import static com.google.common.base.MoreObjects.toStringHelper;
21
22import java.util.Objects;
23
24public 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() {
HIGUCHI Yutaca9cc8e2015-10-29 23:26:51 -070065 return oduSignalId.hashCode();
Yafit Hadar52d81552015-10-07 12:26:52 +030066 }
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}