b712675b6725a7ebc5c7ebaad8dc4f3d1d0a9f09
[onosfw.git] /
1 /*
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  */
16 package org.onosproject.net.flow.criteria;
17
18 import java.util.Objects;
19
20 import static com.google.common.base.MoreObjects.toStringHelper;
21
22 /**
23  * Implementation of optical signal type criterion (8 bits unsigned
24  * integer).
25  *
26  * @deprecated in Cardinal Release
27  */
28 @Deprecated
29 public 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() {
68         return Objects.hash(type().ordinal(), signalType);
69     }
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 }