blob: 17ea2d051795f8eeab772eea9c82724c3eaed63b [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.
HIGUCHI Yuta603e8d92015-12-11 09:57:30 -080027 *
28 * @deprecated in Emu (ONOS 1.4).
Sho SHIMIZUefc2e282015-05-04 15:26:23 -070029 */
Marc De Leenheer2c305302015-12-07 21:37:44 -080030@Deprecated
Sho SHIMIZUefc2e282015-05-04 15:26:23 -070031public class IndexedLambdaCriterion implements Criterion {
32
33 private final IndexedLambda lambda;
34
35 /**
36 * Creates a criterion with the specified value.
37 *
38 * @param lambda lambda index number
39 */
40 IndexedLambdaCriterion(IndexedLambda lambda) {
41 this.lambda = checkNotNull(lambda);
42 }
43
44 @Override
45 public Type type() {
46 // TODO: consider defining a new specific type
47 // Now OCH_SIGID is used due to compatibility concerns
48 return Type.OCH_SIGID;
49 }
50
51 /**
52 * Returns the indexed lambda to match.
53 *
54 * @return the indexed lambda to match
55 */
56 public IndexedLambda lambda() {
57 return lambda;
58 }
59
60 @Override
61 public int hashCode() {
Thomas Vachuska6c8eff32015-05-27 16:11:44 -070062 return Objects.hash(type().ordinal(), lambda);
Sho SHIMIZUefc2e282015-05-04 15:26:23 -070063 }
64
65 @Override
66 public boolean equals(Object obj) {
67 if (this == obj) {
68 return true;
69 }
70 if (!(obj instanceof IndexedLambdaCriterion)) {
71 return false;
72 }
73 final IndexedLambdaCriterion that = (IndexedLambdaCriterion) obj;
74 return Objects.equals(this.lambda, that.lambda);
75 }
76
77 @Override
78 public String toString() {
79 return MoreObjects.toStringHelper(this)
80 .add("lambda", lambda)
81 .toString();
82 }
83}