Yafit Hadar | 52d8155 | 2015-10-07 12:26:52 +0300 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | package org.onosproject.net.flow.instructions; |
| 17 | |
| 18 | import org.onosproject.net.OduSignalId; |
| 19 | |
Yafit Hadar | 52d8155 | 2015-10-07 12:26:52 +0300 | [diff] [blame] | 20 | import java.util.Objects; |
| 21 | |
| 22 | public abstract class L1ModificationInstruction implements Instruction { |
| 23 | |
Jonathan Hart | c7840bd | 2016-01-21 23:26:29 -0800 | [diff] [blame^] | 24 | public static final String SEPARATOR = ":"; |
| 25 | |
Yafit Hadar | 52d8155 | 2015-10-07 12:26:52 +0300 | [diff] [blame] | 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 Yuta | ca9cc8e | 2015-10-29 23:26:51 -0700 | [diff] [blame] | 65 | return oduSignalId.hashCode(); |
Yafit Hadar | 52d8155 | 2015-10-07 12:26:52 +0300 | [diff] [blame] | 66 | } |
| 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 Hart | c7840bd | 2016-01-21 23:26:29 -0800 | [diff] [blame^] | 82 | return subtype().toString() + SEPARATOR + oduSignalId; |
Yafit Hadar | 52d8155 | 2015-10-07 12:26:52 +0300 | [diff] [blame] | 83 | } |
| 84 | } |
| 85 | |
| 86 | } |