blob: b712675b6725a7ebc5c7ebaad8dc4f3d1d0a9f09 [file] [log] [blame]
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -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 java.util.Objects;
19
20import static com.google.common.base.MoreObjects.toStringHelper;
21
22/**
23 * Implementation of optical signal type criterion (8 bits unsigned
24 * integer).
Sho SHIMIZU9a2b0812015-06-30 10:02:22 -070025 *
26 * @deprecated in Cardinal Release
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -070027 */
Marc De Leenheerd24420f2015-05-27 09:40:59 -070028@Deprecated
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -070029public final class OpticalSignalTypeCriterion implements Criterion {
30 private static final short MASK = 0xff;
31 private final short signalType; // Signal type value: 8 bits
32 private final Type type;
33
34 /**
35 * Constructor.
36 *
37 * @param signalType the optical signal type to match (8 bits unsigned
38 * integer)
39 * @param type the match type. Should be Type.OCH_SIGTYPE
40 */
41 OpticalSignalTypeCriterion(short signalType, Type type) {
42 this.signalType = (short) (signalType & MASK);
43 this.type = type;
44 }
45
46 @Override
47 public Type type() {
48 return this.type;
49 }
50
51 /**
52 * Gets the optical signal type to match.
53 *
54 * @return the optical signal type to match (8 bits unsigned integer)
55 */
56 public short signalType() {
57 return signalType;
58 }
59
60 @Override
61 public String toString() {
62 return toStringHelper(type().toString())
63 .add("signalType", signalType).toString();
64 }
65
66 @Override
67 public int hashCode() {
Thomas Vachuska6c8eff32015-05-27 16:11:44 -070068 return Objects.hash(type().ordinal(), signalType);
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -070069 }
70
71 @Override
72 public boolean equals(Object obj) {
73 if (this == obj) {
74 return true;
75 }
76 if (obj instanceof OpticalSignalTypeCriterion) {
77 OpticalSignalTypeCriterion that = (OpticalSignalTypeCriterion) obj;
78 return Objects.equals(signalType, that.signalType) &&
79 Objects.equals(type, that.type);
80 }
81 return false;
82 }
83}