|
1 |
| -// Copyright (c) 2020-2021 VMware, Inc. or its affiliates. All rights reserved. |
| 1 | +// Copyright (c) 2020-2022 VMware, Inc. or its affiliates. All rights reserved. |
2 | 2 | //
|
3 | 3 | // This software, the RabbitMQ Stream Java client library, is dual-licensed under the
|
4 | 4 | // Mozilla Public License 2.0 ("MPL"), and the Apache License version 2 ("ASL").
|
|
16 | 16 | import java.util.Collections;
|
17 | 17 | import java.util.HashMap;
|
18 | 18 | import java.util.Map;
|
| 19 | +import java.util.Objects; |
19 | 20 | import java.util.function.BiFunction;
|
20 | 21 | import java.util.regex.Matcher;
|
21 | 22 | import java.util.regex.Pattern;
|
22 | 23 |
|
23 | 24 | /** API to easily configure byte capacities. */
|
24 |
| -public class ByteCapacity { |
| 25 | +public class ByteCapacity implements Comparable<ByteCapacity> { |
25 | 26 |
|
26 | 27 | private static final String UNIT_MB = "mb";
|
27 | 28 | private static final int KILOBYTES_MULTIPLIER = 1000;
|
@@ -123,8 +124,30 @@ public static ByteCapacity from(String value) {
|
123 | 124 | }
|
124 | 125 | }
|
125 | 126 |
|
| 127 | + @Override |
| 128 | + public boolean equals(Object o) { |
| 129 | + if (this == o) { |
| 130 | + return true; |
| 131 | + } |
| 132 | + if (o == null || getClass() != o.getClass()) { |
| 133 | + return false; |
| 134 | + } |
| 135 | + ByteCapacity that = (ByteCapacity) o; |
| 136 | + return bytes == that.bytes; |
| 137 | + } |
| 138 | + |
| 139 | + @Override |
| 140 | + public int hashCode() { |
| 141 | + return Objects.hash(bytes); |
| 142 | + } |
| 143 | + |
126 | 144 | @Override
|
127 | 145 | public String toString() {
|
128 | 146 | return this.input;
|
129 | 147 | }
|
| 148 | + |
| 149 | + @Override |
| 150 | + public int compareTo(ByteCapacity other) { |
| 151 | + return Long.compare(this.bytes, other.bytes); |
| 152 | + } |
130 | 153 | }
|
0 commit comments