blob: 86cec25787bf5e2d0d4128ce85980d9092c108fc [file] [log] [blame]
Georgios Katsikas83600982017-05-28 20:41:45 +02001/*
2 * Copyright 2017-present Open Networking Foundation
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 */
Georgios Katsikas2ebd8a02018-06-27 18:32:50 +020016package org.onosproject.drivers.server.devices.nic;
Georgios Katsikas83600982017-05-28 20:41:45 +020017
18import org.onlab.packet.VlanId;
19
20import java.util.Objects;
21
22import static com.google.common.base.Preconditions.checkNotNull;
23
24/**
25 * A VLAN Rx filter value.
26 */
27public class VlanRxFilterValue extends RxFilterValue {
28
29 private VlanId vlanId;
30
31 public VlanRxFilterValue() {
32 super();
Georgios Katsikas2ebd8a02018-06-27 18:32:50 +020033 this.vlanId = VlanId.NONE;
Georgios Katsikas83600982017-05-28 20:41:45 +020034 }
35
36 public VlanRxFilterValue(VlanId vlanId) {
37 super();
Georgios Katsikas2ebd8a02018-06-27 18:32:50 +020038 setValue(vlanId);
Georgios Katsikas83600982017-05-28 20:41:45 +020039 }
40
41 public VlanRxFilterValue(VlanRxFilterValue other) {
42 super();
Georgios Katsikas2ebd8a02018-06-27 18:32:50 +020043 setValue(other.value());
Georgios Katsikas83600982017-05-28 20:41:45 +020044 }
45
46 /**
47 * Returns the value of this Rx filter.
48 *
49 * @return VLAN ID value
50 */
51 public VlanId value() {
52 return this.vlanId;
53 }
54
55 /**
56 * Sets the value of this Rx filter.
57 *
58 * @param vlanId VLAN ID value
59 */
60 public void setValue(VlanId vlanId) {
61 checkNotNull(vlanId, "VLAN ID of Rx filter is NULL");
62
63 this.vlanId = vlanId;
64 }
65
66 @Override
67 public int hashCode() {
68 return Objects.hash(this.vlanId);
69 }
70
71 @Override
72 public boolean equals(Object obj) {
73 if (this == obj) {
74 return true;
75 }
76
77 if ((obj == null) || (!(obj instanceof VlanRxFilterValue))) {
78 return false;
79 }
80
81 VlanRxFilterValue other = (VlanRxFilterValue) obj;
82
83 return this.value().equals(other.value());
84 }
85
86 @Override
87 public String toString() {
88 return this.value().toString();
89 }
90
91}