blob: 6e7d199b46bec0896074ca2320d9c9957cefa22f [file] [log] [blame]
Sangsik Yoonf0b3ad82016-08-19 18:47:59 +09001/*
2 * Copyright 2016-present 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 */
16
17package org.onosproject.incubator.net.dpi;
18
19import java.util.Objects;
20
21import static com.google.common.base.MoreObjects.toStringHelper;
22import static com.google.common.base.Preconditions.checkNotNull;
23
24/**
25 * DPI statistics with received time.
26 */
27public class DpiStatistics {
28 private final String receivedTime;
29 private final DpiStatInfo dpiStatInfo;
30
31 /**
32 * Constructor for DpiStatistics class.
33 *
34 * @param receivedTime dpiStatInfo received time
35 * @param dpiStatInfo the dpi statistics info
36 */
37 public DpiStatistics(final String receivedTime, final DpiStatInfo dpiStatInfo) {
38 checkNotNull(receivedTime, "Must specify receivedTime");
39 checkNotNull(dpiStatInfo, "Must specify DpiStatInfo");
40
41 this.receivedTime = receivedTime;
42 this.dpiStatInfo = dpiStatInfo;
43 }
44
45 /**
46 * Returns DPI statistics received time.
47 *
48 * @return receivedTime
49 */
50 public String receivedTime() {
51 return receivedTime;
52 }
53
54 /**
55 * Returns DPI statistics information.
56 *
57 * @return dpiStatInfo
58 */
59 public DpiStatInfo dpiStatInfo() {
60 return dpiStatInfo;
61 }
62
63 @Override
64 public int hashCode() {
65 return Objects.hash(receivedTime, dpiStatInfo);
66 }
67
68 @Override
69 public boolean equals(final Object obj) {
70 if (obj == null) {
71 return false;
72 }
73 if (getClass() != obj.getClass()) {
74 return false;
75 }
76 final DpiStatistics other = (DpiStatistics) obj;
77 if (!Objects.equals(this.receivedTime, other.receivedTime)) {
78 return false;
79 }
80 if (!Objects.equals(this.dpiStatInfo, other.dpiStatInfo)) {
81 return false;
82 }
83
84 return true;
85 }
86
87 @Override
88 public String toString() {
89 return toStringHelper(this)
90 .add("receivedTime", receivedTime)
91 .add("dpiStatInfo", dpiStatInfo)
92 .toString();
93 }
94}