blob: 31080d54bd092f28b0b491b4a33cf259065243bf [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
20import com.google.common.base.MoreObjects;
21
22import java.util.Objects;
23
24/**
25 * Representation of a Bmv2 valid match parameter.
26 */
27public class Bmv2ValidMatchParam implements Bmv2MatchParam {
28
29 private final boolean flag;
30
31 /**
32 * Creates a new valid match parameter using the given boolean flag.
33 *
34 * @param flag a boolean value
35 */
36 public Bmv2ValidMatchParam(boolean flag) {
37 this.flag = flag;
38 }
39
40 @Override
41 public Type type() {
42 return Type.VALID;
43 }
44
45 /**
46 * Returns the boolean flag of this parameter.
47 *
48 * @return a boolean value
49 */
50 public boolean flag() {
51 return flag;
52 }
53
54 @Override
55 public int hashCode() {
56 return Objects.hashCode(flag);
57 }
58
59 @Override
60 public boolean equals(Object obj) {
61 if (this == obj) {
62 return true;
63 }
64 if (obj == null || getClass() != obj.getClass()) {
65 return false;
66 }
67 final Bmv2ValidMatchParam other = (Bmv2ValidMatchParam) obj;
68 return this.flag == other.flag;
69 }
70
71 @Override
72 public String toString() {
73 return MoreObjects.toStringHelper(this)
74 .add("flag", flag)
75 .toString();
76 }
77}