blob: 8ca5e6426641f1c379098ae79341361e08fdef48 [file] [log] [blame]
Yafit Hadar52d81552015-10-07 12:26:52 +03001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Yafit Hadar52d81552015-10-07 12:26:52 +03003 *
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
Yafit Hadar52d81552015-10-07 12:26:52 +030020import java.util.Objects;
21
22public abstract class L1ModificationInstruction implements Instruction {
23
Jonathan Hartc7840bd2016-01-21 23:26:29 -080024 public static final String SEPARATOR = ":";
25
Yafit Hadar52d81552015-10-07 12:26:52 +030026 /**
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() {
Jonathan Hartc7840bd2016-01-21 23:26:29 -080082 return subtype().toString() + SEPARATOR + oduSignalId;
Yafit Hadar52d81552015-10-07 12:26:52 +030083 }
84 }
85
86}