blob: be92e135d99c5989f8f58ba43ee3f43bd91403ee [file] [log] [blame]
Sho SHIMIZU084c4ca2015-05-04 11:52:51 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Sho SHIMIZU084c4ca2015-05-04 11:52:51 -07003 *
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 */
16package org.onosproject.net.flow.criteria;
17
Sho SHIMIZU084c4ca2015-05-04 11:52:51 -070018import org.onosproject.net.OchSignal;
19
20import java.util.Objects;
21
22import 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 */
30public 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 Vachuska6c8eff32015-05-27 16:11:44 -070059 return Objects.hash(type().ordinal(), lambda);
Sho SHIMIZU084c4ca2015-05-04 11:52:51 -070060 }
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 Hartc7840bd2016-01-21 23:26:29 -080076 return type().toString() + SEPARATOR + lambda;
Sho SHIMIZU084c4ca2015-05-04 11:52:51 -070077 }
78}