blob: 9312b56fb86dd51ebd3c4af6c72ed2f14424d1aa [file] [log] [blame]
Carmelo Casconeaa8b6292016-04-13 14:27:06 -07001/*
2 * Copyright 2016-present 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 */
16
17package org.onosproject.bmv2.api.runtime;
18
19
Carmelo Cascone9e39e312016-06-16 14:47:09 -070020import com.google.common.annotations.Beta;
Carmelo Casconeaa8b6292016-04-13 14:27:06 -070021import com.google.common.base.MoreObjects;
22
23import java.util.Objects;
24
25/**
Carmelo Cascone17fc9e42016-05-31 11:29:21 -070026 * Representation of a BMv2 valid match parameter.
Carmelo Casconeaa8b6292016-04-13 14:27:06 -070027 */
Carmelo Cascone9e39e312016-06-16 14:47:09 -070028@Beta
Carmelo Cascone17fc9e42016-05-31 11:29:21 -070029public final class Bmv2ValidMatchParam implements Bmv2MatchParam {
Carmelo Casconeaa8b6292016-04-13 14:27:06 -070030
31 private final boolean flag;
32
33 /**
34 * Creates a new valid match parameter using the given boolean flag.
35 *
36 * @param flag a boolean value
37 */
38 public Bmv2ValidMatchParam(boolean flag) {
39 this.flag = flag;
40 }
41
42 @Override
43 public Type type() {
44 return Type.VALID;
45 }
46
47 /**
48 * Returns the boolean flag of this parameter.
49 *
50 * @return a boolean value
51 */
52 public boolean flag() {
53 return flag;
54 }
55
56 @Override
57 public int hashCode() {
58 return Objects.hashCode(flag);
59 }
60
61 @Override
62 public boolean equals(Object obj) {
63 if (this == obj) {
64 return true;
65 }
66 if (obj == null || getClass() != obj.getClass()) {
67 return false;
68 }
69 final Bmv2ValidMatchParam other = (Bmv2ValidMatchParam) obj;
70 return this.flag == other.flag;
71 }
72
73 @Override
74 public String toString() {
75 return MoreObjects.toStringHelper(this)
76 .add("flag", flag)
77 .toString();
78 }
79}