blob: 1e6e746a22cc99f366ea1201c7f3f0056288922c [file] [log] [blame]
Yafit Hadar52d81552015-10-07 12:26:52 +03001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
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.OduSignalId;
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 ID signal criterion.
26 * This criterion is based on the specification of "OFPXMT_EXP_ODU_SIGID" in
27 * Open Networking Foundation "Optical Transport Protocol Extension Version 1.0", but
28 * defined in protocol agnostic way.
29 */
30public final class OduSignalIdCriterion implements Criterion {
31
32 private final OduSignalId oduSignalId;
33
34 /**
35 * Create an instance with the specified ODU signal ID.
36 *
37 * @param oduSignalId - ODU signal ID
38 */
39 OduSignalIdCriterion(OduSignalId oduSignalId) {
40 this.oduSignalId = checkNotNull(oduSignalId);
41 }
42
43 @Override
44 public Type type() {
45 return Type.ODU_SIGID;
46 }
47
48 /**
49 * Returns the ODU Signal to match.
50 *
51 * @return the ODU signal to match
52 */
53 public OduSignalId oduSignalId() {
54 return oduSignalId;
55 }
56
57 @Override
58 public int hashCode() {
59 return Objects.hash(type(), oduSignalId);
60 }
61
62 @Override
63 public boolean equals(Object obj) {
64 if (this == obj) {
65 return true;
66 }
67 if (!(obj instanceof OduSignalIdCriterion)) {
68 return false;
69 }
70 final OduSignalIdCriterion that = (OduSignalIdCriterion) obj;
71 return Objects.equals(this.oduSignalId, that.oduSignalId);
72 }
73
74 @Override
75 public String toString() {
Jonathan Hartc7840bd2016-01-21 23:26:29 -080076 return type().toString() + SEPARATOR + oduSignalId;
Yafit Hadar52d81552015-10-07 12:26:52 +030077 }
78
79}