Sho SHIMIZU | b5e6de6 | 2015-05-04 12:13:44 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Sho SHIMIZU | b5e6de6 | 2015-05-04 12:13:44 -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 | */ |
| 16 | package org.onosproject.net.flow.criteria; |
| 17 | |
Sho SHIMIZU | 585bed9 | 2015-05-13 11:08:45 -0700 | [diff] [blame] | 18 | import org.onosproject.net.OchSignalType; |
Sho SHIMIZU | b5e6de6 | 2015-05-04 12:13:44 -0700 | [diff] [blame] | 19 | |
| 20 | import java.util.Objects; |
| 21 | |
| 22 | import static com.google.common.base.Preconditions.checkNotNull; |
| 23 | |
| 24 | /** |
Marc De Leenheer | 8c2caac | 2015-05-28 16:37:33 -0700 | [diff] [blame] | 25 | * Implementation of OCh (Optical Channel) signal type criterion. |
Sho SHIMIZU | b5e6de6 | 2015-05-04 12:13:44 -0700 | [diff] [blame] | 26 | */ |
| 27 | public class OchSignalTypeCriterion implements Criterion { |
| 28 | |
| 29 | private final OchSignalType signalType; |
| 30 | |
| 31 | /** |
| 32 | * Creates a criterion with the specified value. |
| 33 | * |
| 34 | * @param signalType OCh signal type |
| 35 | */ |
| 36 | OchSignalTypeCriterion(OchSignalType signalType) { |
| 37 | this.signalType = checkNotNull(signalType); |
| 38 | } |
| 39 | |
| 40 | @Override |
| 41 | public Type type() { |
| 42 | return Type.OCH_SIGTYPE; |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * Returns the OCh signal type to match. |
| 47 | * |
| 48 | * @return the OCh signal type to match |
| 49 | */ |
| 50 | public OchSignalType signalType() { |
| 51 | return signalType; |
| 52 | } |
| 53 | |
| 54 | @Override |
| 55 | public int hashCode() { |
Thomas Vachuska | 6c8eff3 | 2015-05-27 16:11:44 -0700 | [diff] [blame] | 56 | return Objects.hash(type().ordinal(), signalType); |
Sho SHIMIZU | b5e6de6 | 2015-05-04 12:13:44 -0700 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | @Override |
| 60 | public boolean equals(Object obj) { |
| 61 | if (this == obj) { |
| 62 | return true; |
| 63 | } |
| 64 | if (!(obj instanceof OchSignalTypeCriterion)) { |
| 65 | return false; |
| 66 | } |
| 67 | final OchSignalTypeCriterion that = (OchSignalTypeCriterion) obj; |
| 68 | return Objects.equals(this.signalType, that.signalType); |
| 69 | } |
| 70 | |
| 71 | @Override |
| 72 | public String toString() { |
Jonathan Hart | c7840bd | 2016-01-21 23:26:29 -0800 | [diff] [blame] | 73 | return type().toString() + SEPARATOR + signalType; |
Sho SHIMIZU | b5e6de6 | 2015-05-04 12:13:44 -0700 | [diff] [blame] | 74 | } |
| 75 | } |