blob: 3311544c51bbc593c924044017e5fef8d5fb1a0f [file] [log] [blame]
Sho SHIMIZUefc2e282015-05-04 15:26:23 -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
Sho SHIMIZUefc2e282015-05-04 15:26:23 -070018import org.onosproject.net.IndexedLambda;
19
20import java.util.Objects;
21
22import static com.google.common.base.Preconditions.checkNotNull;
23
24/**
25 * Implementation of indexed lambda criterion.
HIGUCHI Yuta603e8d92015-12-11 09:57:30 -080026 *
27 * @deprecated in Emu (ONOS 1.4).
Sho SHIMIZUefc2e282015-05-04 15:26:23 -070028 */
Marc De Leenheer2c305302015-12-07 21:37:44 -080029@Deprecated
Sho SHIMIZUefc2e282015-05-04 15:26:23 -070030public class IndexedLambdaCriterion implements Criterion {
31
32 private final IndexedLambda lambda;
33
34 /**
35 * Creates a criterion with the specified value.
36 *
37 * @param lambda lambda index number
38 */
39 IndexedLambdaCriterion(IndexedLambda lambda) {
40 this.lambda = checkNotNull(lambda);
41 }
42
43 @Override
44 public Type type() {
45 // TODO: consider defining a new specific type
46 // Now OCH_SIGID is used due to compatibility concerns
47 return Type.OCH_SIGID;
48 }
49
50 /**
51 * Returns the indexed lambda to match.
52 *
53 * @return the indexed lambda to match
54 */
55 public IndexedLambda lambda() {
56 return lambda;
57 }
58
59 @Override
60 public int hashCode() {
Thomas Vachuska6c8eff32015-05-27 16:11:44 -070061 return Objects.hash(type().ordinal(), lambda);
Sho SHIMIZUefc2e282015-05-04 15:26:23 -070062 }
63
64 @Override
65 public boolean equals(Object obj) {
66 if (this == obj) {
67 return true;
68 }
69 if (!(obj instanceof IndexedLambdaCriterion)) {
70 return false;
71 }
72 final IndexedLambdaCriterion that = (IndexedLambdaCriterion) obj;
73 return Objects.equals(this.lambda, that.lambda);
74 }
75
76 @Override
77 public String toString() {
Jonathan Hartc7840bd2016-01-21 23:26:29 -080078 return type().toString() + SEPARATOR + lambda;
Sho SHIMIZUefc2e282015-05-04 15:26:23 -070079 }
80}