blob: cf838bf3f0baebbbea74d751135643dd57c63795 [file] [log] [blame]
Sho SHIMIZUb5e6de62015-05-04 12:13:44 -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;
Sho SHIMIZU585bed92015-05-13 11:08:45 -070019import org.onosproject.net.OchSignalType;
Sho SHIMIZUb5e6de62015-05-04 12:13:44 -070020
21import java.util.Objects;
22
23import static com.google.common.base.Preconditions.checkNotNull;
24
25/**
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070026 * Implementation of OCh (Optical Channel) signal type criterion.
Sho SHIMIZUb5e6de62015-05-04 12:13:44 -070027 */
28public class OchSignalTypeCriterion implements Criterion {
29
30 private final OchSignalType signalType;
31
32 /**
33 * Creates a criterion with the specified value.
34 *
35 * @param signalType OCh signal type
36 */
37 OchSignalTypeCriterion(OchSignalType signalType) {
38 this.signalType = checkNotNull(signalType);
39 }
40
41 @Override
42 public Type type() {
43 return Type.OCH_SIGTYPE;
44 }
45
46 /**
47 * Returns the OCh signal type to match.
48 *
49 * @return the OCh signal type to match
50 */
51 public OchSignalType signalType() {
52 return signalType;
53 }
54
55 @Override
56 public int hashCode() {
Thomas Vachuska6c8eff32015-05-27 16:11:44 -070057 return Objects.hash(type().ordinal(), signalType);
Sho SHIMIZUb5e6de62015-05-04 12:13:44 -070058 }
59
60 @Override
61 public boolean equals(Object obj) {
62 if (this == obj) {
63 return true;
64 }
65 if (!(obj instanceof OchSignalTypeCriterion)) {
66 return false;
67 }
68 final OchSignalTypeCriterion that = (OchSignalTypeCriterion) obj;
69 return Objects.equals(this.signalType, that.signalType);
70 }
71
72 @Override
73 public String toString() {
74 return MoreObjects.toStringHelper(this)
75 .add("signalType", signalType)
76 .toString();
77 }
78}