blob: ecf605ff3de097c72e4813bd1be8d534f111f767 [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).
25 */
Marc De Leenheerd24420f2015-05-27 09:40:59 -070026@Deprecated
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -070027public final class OpticalSignalTypeCriterion implements Criterion {
28 private static final short MASK = 0xff;
29 private final short signalType; // Signal type value: 8 bits
30 private final Type type;
31
32 /**
33 * Constructor.
34 *
35 * @param signalType the optical signal type to match (8 bits unsigned
36 * integer)
37 * @param type the match type. Should be Type.OCH_SIGTYPE
38 */
39 OpticalSignalTypeCriterion(short signalType, Type type) {
40 this.signalType = (short) (signalType & MASK);
41 this.type = type;
42 }
43
44 @Override
45 public Type type() {
46 return this.type;
47 }
48
49 /**
50 * Gets the optical signal type to match.
51 *
52 * @return the optical signal type to match (8 bits unsigned integer)
53 */
54 public short signalType() {
55 return signalType;
56 }
57
58 @Override
59 public String toString() {
60 return toStringHelper(type().toString())
61 .add("signalType", signalType).toString();
62 }
63
64 @Override
65 public int hashCode() {
Thomas Vachuska6c8eff32015-05-27 16:11:44 -070066 return Objects.hash(type().ordinal(), signalType);
Sho SHIMIZUfbc80e52015-04-28 10:41:58 -070067 }
68
69 @Override
70 public boolean equals(Object obj) {
71 if (this == obj) {
72 return true;
73 }
74 if (obj instanceof OpticalSignalTypeCriterion) {
75 OpticalSignalTypeCriterion that = (OpticalSignalTypeCriterion) obj;
76 return Objects.equals(signalType, that.signalType) &&
77 Objects.equals(type, that.type);
78 }
79 return false;
80 }
81}