Thomas Vachuska | 58de416 | 2015-09-10 16:15:33 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Thomas Vachuska | 58de416 | 2015-09-10 16:15:33 -0700 | [diff] [blame] | 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 | */ |
Saurav Das | ffc5bbc | 2015-08-18 23:30:19 -0700 | [diff] [blame] | 16 | package org.onosproject.net.flow.criteria; |
| 17 | |
Saurav Das | ffc5bbc | 2015-08-18 23:30:19 -0700 | [diff] [blame] | 18 | import java.util.Objects; |
| 19 | |
| 20 | /** |
| 21 | * Implementation of MPLS BOS criterion (1 bit). |
| 22 | */ |
| 23 | public class MplsBosCriterion implements Criterion { |
| 24 | private boolean mplsBos; |
| 25 | |
| 26 | MplsBosCriterion(boolean mplsBos) { |
| 27 | this.mplsBos = mplsBos; |
| 28 | } |
| 29 | |
| 30 | @Override |
| 31 | public Type type() { |
| 32 | return Type.MPLS_BOS; |
| 33 | } |
| 34 | |
| 35 | public boolean mplsBos() { |
| 36 | return mplsBos; |
| 37 | } |
| 38 | |
| 39 | @Override |
| 40 | public String toString() { |
Jonathan Hart | c7840bd | 2016-01-21 23:26:29 -0800 | [diff] [blame] | 41 | return type().toString() + SEPARATOR + mplsBos; |
Saurav Das | ffc5bbc | 2015-08-18 23:30:19 -0700 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | @Override |
| 45 | public int hashCode() { |
| 46 | return Objects.hash(type().ordinal(), mplsBos); |
| 47 | } |
| 48 | |
| 49 | @Override |
| 50 | public boolean equals(Object obj) { |
| 51 | if (this == obj) { |
| 52 | return true; |
| 53 | } |
| 54 | if (obj instanceof MplsBosCriterion) { |
| 55 | MplsBosCriterion that = (MplsBosCriterion) obj; |
| 56 | return Objects.equals(mplsBos, that.mplsBos()) && |
| 57 | Objects.equals(this.type(), that.type()); |
| 58 | } |
| 59 | return false; |
| 60 | } |
| 61 | } |