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