Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 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.criteria; |
| 17 | |
| 18 | import java.util.Objects; |
| 19 | |
| 20 | import static com.google.common.base.MoreObjects.toStringHelper; |
| 21 | |
| 22 | /** |
| 23 | * Implementation of optical signal type criterion (8 bits unsigned |
| 24 | * integer). |
Sho SHIMIZU | 9a2b081 | 2015-06-30 10:02:22 -0700 | [diff] [blame] | 25 | * |
| 26 | * @deprecated in Cardinal Release |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 27 | */ |
Marc De Leenheer | d24420f | 2015-05-27 09:40:59 -0700 | [diff] [blame] | 28 | @Deprecated |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 29 | public final class OpticalSignalTypeCriterion implements Criterion { |
| 30 | private static final short MASK = 0xff; |
| 31 | private final short signalType; // Signal type value: 8 bits |
| 32 | private final Type type; |
| 33 | |
| 34 | /** |
| 35 | * Constructor. |
| 36 | * |
| 37 | * @param signalType the optical signal type to match (8 bits unsigned |
| 38 | * integer) |
| 39 | * @param type the match type. Should be Type.OCH_SIGTYPE |
| 40 | */ |
| 41 | OpticalSignalTypeCriterion(short signalType, Type type) { |
| 42 | this.signalType = (short) (signalType & MASK); |
| 43 | this.type = type; |
| 44 | } |
| 45 | |
| 46 | @Override |
| 47 | public Type type() { |
| 48 | return this.type; |
| 49 | } |
| 50 | |
| 51 | /** |
| 52 | * Gets the optical signal type to match. |
| 53 | * |
| 54 | * @return the optical signal type to match (8 bits unsigned integer) |
| 55 | */ |
| 56 | public short signalType() { |
| 57 | return signalType; |
| 58 | } |
| 59 | |
| 60 | @Override |
| 61 | public String toString() { |
| 62 | return toStringHelper(type().toString()) |
| 63 | .add("signalType", signalType).toString(); |
| 64 | } |
| 65 | |
| 66 | @Override |
| 67 | public int hashCode() { |
Thomas Vachuska | 6c8eff3 | 2015-05-27 16:11:44 -0700 | [diff] [blame] | 68 | return Objects.hash(type().ordinal(), signalType); |
Sho SHIMIZU | fbc80e5 | 2015-04-28 10:41:58 -0700 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | @Override |
| 72 | public boolean equals(Object obj) { |
| 73 | if (this == obj) { |
| 74 | return true; |
| 75 | } |
| 76 | if (obj instanceof OpticalSignalTypeCriterion) { |
| 77 | OpticalSignalTypeCriterion that = (OpticalSignalTypeCriterion) obj; |
| 78 | return Objects.equals(signalType, that.signalType) && |
| 79 | Objects.equals(type, that.type); |
| 80 | } |
| 81 | return false; |
| 82 | } |
| 83 | } |