Saurav Das | ffc5bbc | 2015-08-18 23:30:19 -0700 | [diff] [blame] | 1 | package org.onosproject.net.flow.criteria; |
| 2 | |
| 3 | import static com.google.common.base.MoreObjects.toStringHelper; |
| 4 | import java.util.Objects; |
| 5 | |
| 6 | /** |
| 7 | * Implementation of MPLS BOS criterion (1 bit). |
| 8 | */ |
| 9 | public class MplsBosCriterion implements Criterion { |
| 10 | private boolean mplsBos; |
| 11 | |
| 12 | MplsBosCriterion(boolean mplsBos) { |
| 13 | this.mplsBos = mplsBos; |
| 14 | } |
| 15 | |
| 16 | @Override |
| 17 | public Type type() { |
| 18 | return Type.MPLS_BOS; |
| 19 | } |
| 20 | |
| 21 | public boolean mplsBos() { |
| 22 | return mplsBos; |
| 23 | } |
| 24 | |
| 25 | @Override |
| 26 | public String toString() { |
| 27 | return toStringHelper(type().toString()) |
| 28 | .add("bos", mplsBos).toString(); |
| 29 | } |
| 30 | |
| 31 | @Override |
| 32 | public int hashCode() { |
| 33 | return Objects.hash(type().ordinal(), mplsBos); |
| 34 | } |
| 35 | |
| 36 | @Override |
| 37 | public boolean equals(Object obj) { |
| 38 | if (this == obj) { |
| 39 | return true; |
| 40 | } |
| 41 | if (obj instanceof MplsBosCriterion) { |
| 42 | MplsBosCriterion that = (MplsBosCriterion) obj; |
| 43 | return Objects.equals(mplsBos, that.mplsBos()) && |
| 44 | Objects.equals(this.type(), that.type()); |
| 45 | } |
| 46 | return false; |
| 47 | } |
| 48 | } |