2 * Copyright 2014-2015 Open Networking Laboratory
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 package org.onosproject.net.flow.instructions;
18 import com.google.common.base.MoreObjects;
19 import org.onosproject.net.OchSignal;
21 import static com.google.common.base.MoreObjects.toStringHelper;
23 import java.util.Objects;
25 public abstract class L0ModificationInstruction implements Instruction {
28 * Represents the type of traffic treatment.
30 public enum L0SubType {
32 * Lambda modification.
36 * OCh (Optical Channel) modification.
41 public abstract L0SubType subtype();
44 public final Type type() {
45 return Type.L0MODIFICATION;
49 * Represents a L0 lambda modification instruction.
51 public static final class ModLambdaInstruction extends L0ModificationInstruction {
53 private final L0SubType subtype;
54 private final short lambda;
56 ModLambdaInstruction(L0SubType subType, short lambda) {
57 this.subtype = subType;
62 public L0SubType subtype() {
66 public short lambda() {
71 public String toString() {
72 return toStringHelper(subtype().toString())
73 .add("lambda", lambda).toString();
77 public int hashCode() {
78 return Objects.hash(type(), subtype, lambda);
82 public boolean equals(Object obj) {
86 if (obj instanceof ModLambdaInstruction) {
87 ModLambdaInstruction that = (ModLambdaInstruction) obj;
88 return Objects.equals(lambda, that.lambda) &&
89 Objects.equals(subtype, that.subtype);
96 * Represents an L0 OCh (Optical Channel) modification instruction.
98 public static final class ModOchSignalInstruction extends L0ModificationInstruction {
100 private final OchSignal lambda;
102 ModOchSignalInstruction(OchSignal lambda) {
103 this.lambda = lambda;
107 public L0SubType subtype() {
108 return L0SubType.OCH;
111 public OchSignal lambda() {
116 public int hashCode() {
117 return Objects.hash(lambda);
121 public boolean equals(Object obj) {
125 if (!(obj instanceof ModOchSignalInstruction)) {
128 final ModOchSignalInstruction that = (ModOchSignalInstruction) obj;
129 return Objects.equals(this.lambda, that.lambda);
133 public String toString() {
134 return MoreObjects.toStringHelper(this)
135 .add("lambda", lambda)