blob: 914ed55128e918bbd57dc8a79682d041ef716d54 [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2014-present Open Networking Laboratory
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07003 *
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 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net.flow.instructions;
Marc De Leenheer49087752014-10-23 13:54:09 -070017
Sho SHIMIZUe9e12752015-05-05 14:45:40 -070018import org.onosproject.net.OchSignal;
19
Marc De Leenheer49087752014-10-23 13:54:09 -070020import java.util.Objects;
21
22public abstract class L0ModificationInstruction implements Instruction {
23
Sho SHIMIZU602edca2016-03-11 17:20:38 -080024 private static final String SEPARATOR = ":";
Jonathan Hartc7840bd2016-01-21 23:26:29 -080025
Marc De Leenheer49087752014-10-23 13:54:09 -070026 /**
27 * Represents the type of traffic treatment.
28 */
29 public enum L0SubType {
30 /**
Sho SHIMIZUe9e12752015-05-05 14:45:40 -070031 * OCh (Optical Channel) modification.
32 */
33 OCH,
Marc De Leenheer49087752014-10-23 13:54:09 -070034 }
35
36 public abstract L0SubType subtype();
37
38 @Override
Yuta HIGUCHI6a479642015-02-08 01:28:50 -080039 public final Type type() {
Marc De Leenheer49087752014-10-23 13:54:09 -070040 return Type.L0MODIFICATION;
41 }
42
43 /**
Sho SHIMIZUe9e12752015-05-05 14:45:40 -070044 * Represents an L0 OCh (Optical Channel) modification instruction.
45 */
46 public static final class ModOchSignalInstruction extends L0ModificationInstruction {
47
48 private final OchSignal lambda;
49
50 ModOchSignalInstruction(OchSignal lambda) {
51 this.lambda = lambda;
52 }
53
54 @Override
55 public L0SubType subtype() {
56 return L0SubType.OCH;
57 }
58
59 public OchSignal lambda() {
60 return lambda;
61 }
62
63 @Override
64 public int hashCode() {
HIGUCHI Yutaca9cc8e2015-10-29 23:26:51 -070065 return lambda.hashCode();
Sho SHIMIZUe9e12752015-05-05 14:45:40 -070066 }
67
68 @Override
69 public boolean equals(Object obj) {
70 if (this == obj) {
71 return true;
72 }
73 if (!(obj instanceof ModOchSignalInstruction)) {
74 return false;
75 }
76 final ModOchSignalInstruction that = (ModOchSignalInstruction) obj;
77 return Objects.equals(this.lambda, that.lambda);
78 }
79
80 @Override
81 public String toString() {
Jonathan Hartc7840bd2016-01-21 23:26:29 -080082 return subtype().toString() + SEPARATOR + lambda;
Sho SHIMIZUe9e12752015-05-05 14:45:40 -070083 }
84 }
Marc De Leenheer49087752014-10-23 13:54:09 -070085}