2 * SPDX-FileCopyrightText: The Storage-Units Authors
3 * SPDX-License-Identifier: 0BSD
5 package wtf
.metio
.storageunits
.model
;
7 import edu
.umd
.cs
.findbugs
.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 * Exbibyte as specified in ISO IEC 80000-13:2008 (1 Exbibyte = 1 152 921 504 606 846 976 Byte).
17 public final class Exbibyte
extends StorageUnit
<Exbibyte
> {
20 private static final long serialVersionUID
= 5993490571003918471L;
22 Exbibyte(@NotNull final BigInteger bytes
) {
27 * @param numberOfBytes The amount of bytes the Exbibyte contains.
28 * @return A new Exbibyte unit with the given value.
32 public static Exbibyte
valueOf(@NotNull final BigInteger numberOfBytes
) {
33 return new Exbibyte(numberOfBytes
);
37 * @param numberOfBytes The amount of bytes the Exbibyte contains.
38 * @return A new Exbibyte unit with the given value.
42 public static Exbibyte
valueOf(final long numberOfBytes
) {
43 return valueOf(BigInteger
.valueOf(numberOfBytes
));
47 * @param numberOfBytes The amount of bytes the Exbibyte contains.
48 * @return A new Exbibyte unit with the given value.
52 public static Exbibyte
valueOf(@NotNull final Long numberOfBytes
) {
53 return valueOf(numberOfBytes
.longValue());
59 public Exbibyte
add(final long bytesToAdd
) {
60 return add(BigInteger
.valueOf(bytesToAdd
));
66 public Exbibyte
add(@NotNull final BigInteger bytesToAdd
) {
67 return new Exbibyte(bytes
.add(bytesToAdd
));
73 public Exbibyte
add(@NotNull final StorageUnit
<?
> storageAmount
) {
74 return add(storageAmount
.bytes
);
80 public Exbibyte
divide(final long divisor
) {
81 return divide(BigInteger
.valueOf(divisor
));
87 public Exbibyte
divide(@NotNull final BigInteger divisor
) {
88 return new Exbibyte(bytes
.divide(divisor
));
94 public Exbibyte
multiply(final long factor
) {
95 return new Exbibyte(bytes
.multiply(BigInteger
.valueOf(factor
)));
101 public Exbibyte
multiply(@NotNull final BigInteger factor
) {
102 return new Exbibyte(bytes
.multiply(factor
));
108 public Exbibyte
subtract(final long bytesToSubtract
) {
109 return new Exbibyte(bytes
.subtract(BigInteger
.valueOf(bytesToSubtract
)));
115 public Exbibyte
subtract(@NotNull final BigInteger bytesToSubtract
) {
116 return new Exbibyte(bytes
.subtract(bytesToSubtract
));
122 public Exbibyte
subtract(@NotNull final StorageUnit
<?
> storageAmount
) {
123 return new Exbibyte(bytes
.subtract(storageAmount
.bytes
));
129 protected BigInteger
getNumberOfBytesPerUnit() {
130 return StorageUnit
.BYTES_IN_A_EXBIBYTE
;
136 protected String
getSymbol() {
143 protected Function
<@NotNull BigInteger
, @NotNull StorageUnit
<?
>> converter() {
144 return StorageUnits
::binaryValueOf
;