2 * SPDX-FileCopyrightText: The Storage-Units Authors
3 * SPDX-License-Identifier: 0BSD
5 package wtf
.metio
.storageunits
.model
;
7 import com
.google
.errorprone
.annotations
.CheckReturnValue
;
8 import org
.jetbrains
.annotations
.NotNull
;
10 import java
.io
.Serial
;
11 import java
.math
.BigInteger
;
12 import java
.util
.function
.Function
;
15 * Exabyte as specified in ISO IEC 80000-13:2008 (1 Exabyte = 1 000 000 000 000 000 000 Byte).
17 public final class Exabyte
extends StorageUnit
<Exabyte
> {
20 private static final long serialVersionUID
= 6846441733771841250L;
22 Exabyte(final @NotNull BigInteger numberOfBytes
) {
27 * @param numberOfBytes The amount of bytes the Exabyte contains.
28 * @return A new Exabyte unit with the given value.
31 public static @NotNull Exabyte
valueOf(final @NotNull BigInteger numberOfBytes
) {
32 return new Exabyte(numberOfBytes
);
36 * @param numberOfBytes The amount of bytes the Exabyte contains.
37 * @return A new Exabyte unit with the given value.
40 public static @NotNull Exabyte
valueOf(final long numberOfBytes
) {
41 return valueOf(BigInteger
.valueOf(numberOfBytes
));
45 * @param numberOfBytes The amount of bytes the Exabyte contains.
46 * @return A new Exabyte unit with the given value.
49 public static @NotNull Exabyte
valueOf(final @NotNull Long numberOfBytes
) {
50 return valueOf(numberOfBytes
.longValue());
55 public @NotNull Exabyte
add(final long bytesToAdd
) {
56 return add(BigInteger
.valueOf(bytesToAdd
));
61 public @NotNull Exabyte
add(final @NotNull BigInteger bytesToAdd
) {
62 return new Exabyte(bytes
.add(bytesToAdd
));
67 public @NotNull Exabyte
add(final @NotNull StorageUnit
<?
> storageAmount
) {
68 return add(storageAmount
.bytes
);
73 public @NotNull Exabyte
divide(final long divisor
) {
74 return divide(BigInteger
.valueOf(divisor
));
79 public @NotNull Exabyte
divide(final @NotNull BigInteger divisor
) {
80 return new Exabyte(bytes
.divide(divisor
));
85 public @NotNull Exabyte
multiply(final long factor
) {
86 return new Exabyte(bytes
.multiply(BigInteger
.valueOf(factor
)));
91 public @NotNull Exabyte
multiply(final @NotNull BigInteger factor
) {
92 return new Exabyte(bytes
.multiply(factor
));
97 public @NotNull Exabyte
subtract(final long bytesToSubtract
) {
98 return new Exabyte(bytes
.subtract(BigInteger
.valueOf(bytesToSubtract
)));
103 public @NotNull Exabyte
subtract(final @NotNull BigInteger bytesToSubtract
) {
104 return new Exabyte(bytes
.subtract(bytesToSubtract
));
109 public @NotNull Exabyte
subtract(final @NotNull StorageUnit
<?
> storageAmount
) {
110 return new Exabyte(bytes
.subtract(storageAmount
.bytes
));
115 protected @NotNull BigInteger
getNumberOfBytesPerUnit() {
116 return StorageUnit
.BYTES_IN_A_EXABYTE
;
121 protected @NotNull String
getSymbol() {
127 protected @NotNull Function
<@NotNull BigInteger
, @NotNull StorageUnit
<?
>> converter() {
128 return StorageUnits
::decimalValueOf
;