blob: b640970512e820a60cbca3026ca164112da2b996 [file] [log] [blame]
Carmelo Casconeb045ddc2017-09-01 01:26:35 +02001/*
steven308017632e152018-10-20 00:51:08 +08002 * Copyright 2018-present Open Networking Foundation
Carmelo Casconeb045ddc2017-09-01 01:26:35 +02003 *
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.net.pi.runtime;
18
19import com.google.common.annotations.Beta;
20import com.google.common.base.MoreObjects;
21import com.google.common.base.Objects;
22
23/**
24 * Data of a counter cell of a protocol-independent pipeline.
25 */
steven308017632e152018-10-20 00:51:08 +080026
Carmelo Casconeb045ddc2017-09-01 01:26:35 +020027@Beta
28public final class PiCounterCellData {
29
Carmelo Casconeb045ddc2017-09-01 01:26:35 +020030 private final long packets;
31 private final long bytes;
32
33 /**
steven308017632e152018-10-20 00:51:08 +080034 * Creates a new counter cell data for the given number of packets and bytes.
Carmelo Casconeb045ddc2017-09-01 01:26:35 +020035 *
steven308017632e152018-10-20 00:51:08 +080036 * @param packets number of packets
37 * @param bytes number of bytes
Carmelo Casconeb045ddc2017-09-01 01:26:35 +020038 */
steven308017632e152018-10-20 00:51:08 +080039 public PiCounterCellData(long packets, long bytes) {
Carmelo Casconeb045ddc2017-09-01 01:26:35 +020040 this.packets = packets;
41 this.bytes = bytes;
42 }
43
44 /**
steven308017632e152018-10-20 00:51:08 +080045 * Returns the packet count value contained by this counter data.
Carmelo Casconeb045ddc2017-09-01 01:26:35 +020046 *
47 * @return number of packets
48 */
49 public long packets() {
50 return packets;
51 }
52
53 /**
steven308017632e152018-10-20 00:51:08 +080054 * Returns the byte count value contained by this counter data.
Carmelo Casconeb045ddc2017-09-01 01:26:35 +020055 *
56 * @return number of bytes
57 */
58 public long bytes() {
59 return bytes;
60 }
61
62 @Override
63 public boolean equals(Object o) {
64 if (this == o) {
65 return true;
66 }
67 if (!(o instanceof PiCounterCellData)) {
68 return false;
69 }
70 PiCounterCellData that = (PiCounterCellData) o;
71 return packets == that.packets &&
steven308017632e152018-10-20 00:51:08 +080072 bytes == that.bytes;
Carmelo Casconeb045ddc2017-09-01 01:26:35 +020073 }
74
75 @Override
76 public int hashCode() {
steven308017632e152018-10-20 00:51:08 +080077 return Objects.hashCode(packets, bytes);
Carmelo Casconeb045ddc2017-09-01 01:26:35 +020078 }
79
80 @Override
81 public String toString() {
82 return MoreObjects.toStringHelper(this)
Carmelo Casconeb045ddc2017-09-01 01:26:35 +020083 .add("packets", packets)
84 .add("bytes", bytes)
85 .toString();
86 }
87}