Sangsik Yoon | f0b3ad8 | 2016-08-19 18:47:59 +0900 | [diff] [blame] | 1 | /* |
Thomas Vachuska | 52f2cd1 | 2018-11-08 21:20:04 -0800 | [diff] [blame] | 2 | * Copyright 2018-present Open Networking Foundation |
Sangsik Yoon | f0b3ad8 | 2016-08-19 18:47:59 +0900 | [diff] [blame] | 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 | |
| 17 | package org.onosproject.incubator.net.dpi; |
| 18 | |
| 19 | import java.util.Objects; |
| 20 | |
| 21 | import static com.google.common.base.MoreObjects.toStringHelper; |
| 22 | import static com.google.common.base.Preconditions.checkNotNull; |
| 23 | |
| 24 | /** |
| 25 | * DPI statistics with received time. |
| 26 | */ |
| 27 | public 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 | } |