blob: cb5133977e196a4a480b103e8f3be010b9412637 [file] [log] [blame]
Yafit Hadar52d81552015-10-07 12:26:52 +03001/*
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 static com.google.common.base.MoreObjects.toStringHelper;
19import static com.google.common.base.Preconditions.checkNotNull;
20
21import java.util.Objects;
22
23import org.onosproject.net.OduSignalId;
24
25/**
26 * Implementation of ODU (Optical channel Data Unit) signal ID signal criterion.
27 * This criterion is based on the specification of "OFPXMT_EXP_ODU_SIGID" in
28 * Open Networking Foundation "Optical Transport Protocol Extension Version 1.0", but
29 * defined in protocol agnostic way.
30 */
31public final class OduSignalIdCriterion implements Criterion {
32
33 private final OduSignalId oduSignalId;
34
35 /**
36 * Create an instance with the specified ODU signal ID.
37 *
38 * @param oduSignalId - ODU signal ID
39 */
40 OduSignalIdCriterion(OduSignalId oduSignalId) {
41 this.oduSignalId = checkNotNull(oduSignalId);
42 }
43
44 @Override
45 public Type type() {
46 return Type.ODU_SIGID;
47 }
48
49 /**
50 * Returns the ODU Signal to match.
51 *
52 * @return the ODU signal to match
53 */
54 public OduSignalId oduSignalId() {
55 return oduSignalId;
56 }
57
58 @Override
59 public int hashCode() {
60 return Objects.hash(type(), oduSignalId);
61 }
62
63 @Override
64 public boolean equals(Object obj) {
65 if (this == obj) {
66 return true;
67 }
68 if (!(obj instanceof OduSignalIdCriterion)) {
69 return false;
70 }
71 final OduSignalIdCriterion that = (OduSignalIdCriterion) obj;
72 return Objects.equals(this.oduSignalId, that.oduSignalId);
73 }
74
75 @Override
76 public String toString() {
77 return toStringHelper(type().toString())
78 .add("oduSignalId", oduSignalId)
79 .toString();
80 }
81
82}