Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2014-present Open Networking Laboratory |
Thomas Vachuska | 4f1a60c | 2014-10-28 13:39:07 -0700 | [diff] [blame] | 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 | */ |
Brian O'Connor | abafb50 | 2014-12-02 22:26:20 -0800 | [diff] [blame] | 16 | package org.onosproject.net.flow.instructions; |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 17 | |
Sho SHIMIZU | e9e1275 | 2015-05-05 14:45:40 -0700 | [diff] [blame] | 18 | import org.onosproject.net.OchSignal; |
| 19 | |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 20 | import java.util.Objects; |
| 21 | |
| 22 | public abstract class L0ModificationInstruction implements Instruction { |
| 23 | |
Sho SHIMIZU | 602edca | 2016-03-11 17:20:38 -0800 | [diff] [blame] | 24 | private static final String SEPARATOR = ":"; |
Jonathan Hart | c7840bd | 2016-01-21 23:26:29 -0800 | [diff] [blame] | 25 | |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 26 | /** |
| 27 | * Represents the type of traffic treatment. |
| 28 | */ |
| 29 | public enum L0SubType { |
| 30 | /** |
Sho SHIMIZU | e9e1275 | 2015-05-05 14:45:40 -0700 | [diff] [blame] | 31 | * OCh (Optical Channel) modification. |
| 32 | */ |
| 33 | OCH, |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | public abstract L0SubType subtype(); |
| 37 | |
| 38 | @Override |
Yuta HIGUCHI | 6a47964 | 2015-02-08 01:28:50 -0800 | [diff] [blame] | 39 | public final Type type() { |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 40 | return Type.L0MODIFICATION; |
| 41 | } |
| 42 | |
| 43 | /** |
Sho SHIMIZU | e9e1275 | 2015-05-05 14:45:40 -0700 | [diff] [blame] | 44 | * 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 Yuta | ca9cc8e | 2015-10-29 23:26:51 -0700 | [diff] [blame] | 65 | return lambda.hashCode(); |
Sho SHIMIZU | e9e1275 | 2015-05-05 14:45:40 -0700 | [diff] [blame] | 66 | } |
| 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 Hart | c7840bd | 2016-01-21 23:26:29 -0800 | [diff] [blame] | 82 | return subtype().toString() + SEPARATOR + lambda; |
Sho SHIMIZU | e9e1275 | 2015-05-05 14:45:40 -0700 | [diff] [blame] | 83 | } |
| 84 | } |
Marc De Leenheer | 4908775 | 2014-10-23 13:54:09 -0700 | [diff] [blame] | 85 | } |