blob: b4739a8b48dc6037ff47e3232699e186d50a75eb [file] [log] [blame]
Thomas Vachuska58de4162015-09-10 16:15:33 -07001/*
Brian O'Connorce2a03d2017-08-03 19:21:03 -07002 * Copyright 2015-present Open Networking Foundation
Thomas Vachuska58de4162015-09-10 16:15:33 -07003 *
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
Saurav Dasffc5bbc2015-08-18 23:30:19 -070018import java.util.Objects;
19
20/**
21 * Implementation of MPLS BOS criterion (1 bit).
22 */
23public 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 Hartc7840bd2016-01-21 23:26:29 -080041 return type().toString() + SEPARATOR + mplsBos;
Saurav Dasffc5bbc2015-08-18 23:30:19 -070042 }
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}