blob: 4c9fdd731367a9d4c23a49d5b784dd10d065d925 [file] [log] [blame]
Sho SHIMIZUb5e6de62015-05-04 12:13:44 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
Sho SHIMIZUb5e6de62015-05-04 12:13:44 -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 SHIMIZU585bed92015-05-13 11:08:45 -070018import org.onosproject.net.OchSignalType;
Sho SHIMIZUb5e6de62015-05-04 12:13:44 -070019
20import java.util.Objects;
21
22import static com.google.common.base.Preconditions.checkNotNull;
23
24/**
Marc De Leenheer8c2caac2015-05-28 16:37:33 -070025 * Implementation of OCh (Optical Channel) signal type criterion.
Sho SHIMIZUb5e6de62015-05-04 12:13:44 -070026 */
27public 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 Vachuska6c8eff32015-05-27 16:11:44 -070056 return Objects.hash(type().ordinal(), signalType);
Sho SHIMIZUb5e6de62015-05-04 12:13:44 -070057 }
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 Hartc7840bd2016-01-21 23:26:29 -080073 return type().toString() + SEPARATOR + signalType;
Sho SHIMIZUb5e6de62015-05-04 12:13:44 -070074 }
75}