blob: bc612cd29cb301ce1bed99537aa720b71295836f [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
18import com.google.common.base.MoreObjects;
19import org.onosproject.net.IndexedLambda;
20
21import java.util.Objects;
22
23import static com.google.common.base.Preconditions.checkNotNull;
24
25/**
26 * Implementation of indexed lambda criterion.
27 */
Marc De Leenheer2c305302015-12-07 21:37:44 -080028@Deprecated
Sho SHIMIZUefc2e282015-05-04 15:26:23 -070029public class IndexedLambdaCriterion implements Criterion {
30
31 private final IndexedLambda lambda;
32
33 /**
34 * Creates a criterion with the specified value.
35 *
36 * @param lambda lambda index number
37 */
38 IndexedLambdaCriterion(IndexedLambda lambda) {
39 this.lambda = checkNotNull(lambda);
40 }
41
42 @Override
43 public Type type() {
44 // TODO: consider defining a new specific type
45 // Now OCH_SIGID is used due to compatibility concerns
46 return Type.OCH_SIGID;
47 }
48
49 /**
50 * Returns the indexed lambda to match.
51 *
52 * @return the indexed lambda to match
53 */
54 public IndexedLambda lambda() {
55 return lambda;
56 }
57
58 @Override
59 public int hashCode() {
Thomas Vachuska6c8eff32015-05-27 16:11:44 -070060 return Objects.hash(type().ordinal(), lambda);
Sho SHIMIZUefc2e282015-05-04 15:26:23 -070061 }
62
63 @Override
64 public boolean equals(Object obj) {
65 if (this == obj) {
66 return true;
67 }
68 if (!(obj instanceof IndexedLambdaCriterion)) {
69 return false;
70 }
71 final IndexedLambdaCriterion that = (IndexedLambdaCriterion) obj;
72 return Objects.equals(this.lambda, that.lambda);
73 }
74
75 @Override
76 public String toString() {
77 return MoreObjects.toStringHelper(this)
78 .add("lambda", lambda)
79 .toString();
80 }
81}