Sho SHIMIZU | 084c4ca | 2015-05-04 11:52:51 -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 | 084c4ca | 2015-05-04 11:52:51 -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 | 084c4ca | 2015-05-04 11:52:51 -0700 | [diff] [blame] | 18 | import org.onosproject.net.OchSignal; |
| 19 | |
| 20 | import java.util.Objects; |
| 21 | |
| 22 | import static com.google.common.base.Preconditions.checkNotNull; |
| 23 | |
| 24 | /** |
| 25 | * Implementation of OCh (Optical Channel) signal criterion. |
| 26 | * This criterion is based on the specification of "OFPXMT_EXP_OCH_SIGID" in |
| 27 | * Open Networking Foundation "Optical Transport Protocol Extension Version 1.0", but |
| 28 | * defined in protocol agnostic way. |
| 29 | */ |
| 30 | public final class OchSignalCriterion implements Criterion { |
| 31 | |
| 32 | private final OchSignal lambda; |
| 33 | |
| 34 | /** |
| 35 | * Create an instance with the specified OCh signal. |
| 36 | * |
| 37 | * @param lambda OCh signal |
| 38 | */ |
| 39 | OchSignalCriterion(OchSignal lambda) { |
| 40 | this.lambda = checkNotNull(lambda); |
| 41 | } |
| 42 | |
| 43 | @Override |
| 44 | public Type type() { |
| 45 | return Type.OCH_SIGID; |
| 46 | } |
| 47 | |
| 48 | /** |
| 49 | * Returns the OCh signal to match. |
| 50 | * |
| 51 | * @return the OCh signal to match |
| 52 | */ |
| 53 | public OchSignal lambda() { |
| 54 | return lambda; |
| 55 | } |
| 56 | |
| 57 | @Override |
| 58 | public int hashCode() { |
Thomas Vachuska | 6c8eff3 | 2015-05-27 16:11:44 -0700 | [diff] [blame] | 59 | return Objects.hash(type().ordinal(), lambda); |
Sho SHIMIZU | 084c4ca | 2015-05-04 11:52:51 -0700 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | @Override |
| 63 | public boolean equals(Object obj) { |
| 64 | if (this == obj) { |
| 65 | return true; |
| 66 | } |
| 67 | if (!(obj instanceof OchSignalCriterion)) { |
| 68 | return false; |
| 69 | } |
| 70 | final OchSignalCriterion that = (OchSignalCriterion) obj; |
| 71 | return Objects.equals(this.lambda, that.lambda); |
| 72 | } |
| 73 | |
| 74 | @Override |
| 75 | public String toString() { |
Jonathan Hart | c7840bd | 2016-01-21 23:26:29 -0800 | [diff] [blame] | 76 | return type().toString() + SEPARATOR + lambda; |
Sho SHIMIZU | 084c4ca | 2015-05-04 11:52:51 -0700 | [diff] [blame] | 77 | } |
| 78 | } |