blob: 75c12d6520f89db8cd93147150b47cc603fc7270 [file] [log] [blame]
Charles Chan5adc6282018-06-19 20:56:33 -07001/*
2 * Copyright 2018-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 */
16package org.onosproject.segmentrouting;
17
18import com.google.common.base.MoreObjects;
19
20import java.util.Objects;
21
22import static com.google.common.base.MoreObjects.toStringHelper;
23
24/**
25 * Utility class used to temporarily store information about the ports on a
26 * device processed for filtering objectives.
27 */
28public final class PortFilterInfo {
29 int disabledPorts = 0, errorPorts = 0, filteredPorts = 0;
30
31 public PortFilterInfo(int disabledPorts, int errorPorts,
32 int filteredPorts) {
33 this.disabledPorts = disabledPorts;
34 this.filteredPorts = filteredPorts;
35 this.errorPorts = errorPorts;
36 }
37
38 @Override
39 public int hashCode() {
40 return Objects.hash(disabledPorts, filteredPorts, errorPorts);
41 }
42
43 @Override
44 public boolean equals(Object obj) {
45 if (this == obj) {
46 return true;
47 }
48 if ((obj == null) || (!(obj instanceof PortFilterInfo))) {
49 return false;
50 }
51 PortFilterInfo other = (PortFilterInfo) obj;
52 return ((disabledPorts == other.disabledPorts) &&
53 (filteredPorts == other.filteredPorts) &&
54 (errorPorts == other.errorPorts));
55 }
56
57 @Override
58 public String toString() {
59 MoreObjects.ToStringHelper helper = toStringHelper(this)
60 .add("disabledPorts", disabledPorts)
61 .add("errorPorts", errorPorts)
62 .add("filteredPorts", filteredPorts);
63 return helper.toString();
64 }
65}