blob: f9c6cb5d8c347274dbd25ae9955878f5d2ebc0ea [file] [log] [blame]
Yafit Hadar52d81552015-10-07 12:26:52 +03001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Yafit Hadar52d81552015-10-07 12:26:52 +03003 *
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
Jonathan Hartc7840bd2016-01-21 23:26:29 -080018import org.onosproject.net.OduSignalType;
Yafit Hadar52d81552015-10-07 12:26:52 +030019
20import java.util.Objects;
21
Jonathan Hartc7840bd2016-01-21 23:26:29 -080022import static com.google.common.base.Preconditions.checkNotNull;
Yafit Hadar52d81552015-10-07 12:26:52 +030023
24/**
25 * Implementation of ODU (Optical channel Data Unit) signal Type criterion.
26 * This criterion is based on the specification of "OFPXMT_EXP_ODU_SIGTYPE" in
27 * Open Networking Foundation "Optical Transport Protocol Extension Version 1.0", but
28 * defined in protocol agnostic way.
29 */
30public final class OduSignalTypeCriterion implements Criterion {
31
32 private final OduSignalType signalType;
33
34 /**
35 * Create an instance with the specified ODU signal Type.
36 *
37 * @param signalType - ODU signal Type
38 */
39 OduSignalTypeCriterion(OduSignalType signalType) {
40 this.signalType = checkNotNull(signalType);
41 }
42
43 @Override
44 public Type type() {
45 return Type.ODU_SIGTYPE;
46 }
47
48 /**
49 * Returns the ODU Signal Type to match.
50 *
51 * @return the ODU signal Type to match
52 */
53 public OduSignalType signalType() {
54 return signalType;
55 }
56
57 @Override
58 public int hashCode() {
59 return Objects.hash(type(), signalType);
60 }
61
62 @Override
63 public boolean equals(Object obj) {
64 if (this == obj) {
65 return true;
66 }
67 if (!(obj instanceof OduSignalTypeCriterion)) {
68 return false;
69 }
70 final OduSignalTypeCriterion that = (OduSignalTypeCriterion) obj;
71 return Objects.equals(this.signalType, that.signalType);
72 }
73
74 @Override
75 public String toString() {
Jonathan Hartc7840bd2016-01-21 23:26:29 -080076 return type().toString() + SEPARATOR + signalType;
Yafit Hadar52d81552015-10-07 12:26:52 +030077 }
78}