2 * SPDX-FileCopyrightText: The Storage-Units Authors
3 * SPDX-License-Identifier: 0BSD
5 package wtf
.metio
.storageunits
.model
;
8 import java
.math
.BigInteger
;
9 import java
.util
.function
.Function
;
10 import edu
.umd
.cs
.findbugs
.annotations
.CheckReturnValue
;
11 import org
.jetbrains
.annotations
.NotNull
;
14 * Tebibyte as specified in ISO IEC 80000-13:2008 (1 Tebibyte = 1 099 511 627 776 Byte).
16 public final class Tebibyte
extends StorageUnit
<Tebibyte
> {
19 private static final long serialVersionUID
= 3614537130129620881L;
21 Tebibyte(@NotNull final BigInteger bytes
) {
26 * @param numberOfBytes The amount of bytes the Tebibyte contains.
27 * @return A new Tebibyte unit with the given value.
31 public static Tebibyte
valueOf(@NotNull final BigInteger numberOfBytes
) {
32 return new Tebibyte(numberOfBytes
);
36 * @param numberOfBytes The amount of bytes the Tebibyte contains.
37 * @return A new Tebibyte unit with the given value.
41 public static Tebibyte
valueOf(final long numberOfBytes
) {
42 return valueOf(BigInteger
.valueOf(numberOfBytes
));
46 * @param numberOfBytes The amount of bytes the Tebibyte contains.
47 * @return A new Tebibyte unit with the given value.
51 public static Tebibyte
valueOf(@NotNull final Long numberOfBytes
) {
52 return valueOf(numberOfBytes
.longValue());
58 public Tebibyte
add(final long bytesToAdd
) {
59 return add(BigInteger
.valueOf(bytesToAdd
));
65 public Tebibyte
add(@NotNull final BigInteger bytesToAdd
) {
66 return new Tebibyte(bytes
.add(bytesToAdd
));
72 public Tebibyte
add(@NotNull final StorageUnit
<?
> storageAmount
) {
73 return add(storageAmount
.bytes
);
79 public Tebibyte
divide(final long divisor
) {
80 return divide(BigInteger
.valueOf(divisor
));
86 public Tebibyte
divide(@NotNull final BigInteger divisor
) {
87 return new Tebibyte(bytes
.divide(divisor
));
93 public Tebibyte
multiply(final long factor
) {
94 return multiply(BigInteger
.valueOf(factor
));
100 public Tebibyte
multiply(@NotNull final BigInteger factor
) {
101 return new Tebibyte(bytes
.multiply(factor
));
107 public Tebibyte
subtract(final long bytesToSubtract
) {
108 return subtract(BigInteger
.valueOf(bytesToSubtract
));
114 public Tebibyte
subtract(@NotNull final BigInteger bytesToSubtract
) {
115 return new Tebibyte(bytes
.subtract(bytesToSubtract
));
121 public Tebibyte
subtract(@NotNull final StorageUnit
<?
> storageAmount
) {
122 return subtract(storageAmount
.bytes
);
128 protected BigInteger
getNumberOfBytesPerUnit() {
129 return BYTES_IN_A_TEBIBYTE
;
135 protected String
getSymbol() {
142 protected Function
<@NotNull BigInteger
, @NotNull StorageUnit
<?
>> converter() {
143 return StorageUnits
::binaryValueOf
;