blob: c8b6690d9c01cdf4e0b55df6208fe6b667b97922 [file] [log] [blame]
Thomas Vachuska58de4162015-09-10 16:15:33 -07001/*
2 * Copyright 2015 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 */
Saurav Dasffc5bbc2015-08-18 23:30:19 -070016package org.onosproject.net.flow.criteria;
17
18import static com.google.common.base.MoreObjects.toStringHelper;
19import java.util.Objects;
20
21/**
22 * Implementation of MPLS BOS criterion (1 bit).
23 */
24public class MplsBosCriterion implements Criterion {
25 private boolean mplsBos;
26
27 MplsBosCriterion(boolean mplsBos) {
28 this.mplsBos = mplsBos;
29 }
30
31 @Override
32 public Type type() {
33 return Type.MPLS_BOS;
34 }
35
36 public boolean mplsBos() {
37 return mplsBos;
38 }
39
40 @Override
41 public String toString() {
42 return toStringHelper(type().toString())
43 .add("bos", mplsBos).toString();
44 }
45
46 @Override
47 public int hashCode() {
48 return Objects.hash(type().ordinal(), mplsBos);
49 }
50
51 @Override
52 public boolean equals(Object obj) {
53 if (this == obj) {
54 return true;
55 }
56 if (obj instanceof MplsBosCriterion) {
57 MplsBosCriterion that = (MplsBosCriterion) obj;
58 return Objects.equals(mplsBos, that.mplsBos()) &&
59 Objects.equals(this.type(), that.type());
60 }
61 return false;
62 }
63}