Carmelo Cascone | aa8b629 | 2016-04-13 14:27:06 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package org.onosproject.bmv2.api.runtime; |
| 18 | |
| 19 | |
Carmelo Cascone | 9e39e31 | 2016-06-16 14:47:09 -0700 | [diff] [blame] | 20 | import com.google.common.annotations.Beta; |
Carmelo Cascone | aa8b629 | 2016-04-13 14:27:06 -0700 | [diff] [blame] | 21 | import com.google.common.base.MoreObjects; |
| 22 | |
| 23 | import java.util.Objects; |
| 24 | |
| 25 | /** |
Carmelo Cascone | 17fc9e4 | 2016-05-31 11:29:21 -0700 | [diff] [blame] | 26 | * Representation of a BMv2 valid match parameter. |
Carmelo Cascone | aa8b629 | 2016-04-13 14:27:06 -0700 | [diff] [blame] | 27 | */ |
Carmelo Cascone | 9e39e31 | 2016-06-16 14:47:09 -0700 | [diff] [blame] | 28 | @Beta |
Carmelo Cascone | 17fc9e4 | 2016-05-31 11:29:21 -0700 | [diff] [blame] | 29 | public final class Bmv2ValidMatchParam implements Bmv2MatchParam { |
Carmelo Cascone | aa8b629 | 2016-04-13 14:27:06 -0700 | [diff] [blame] | 30 | |
| 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 | } |