2 * This file is part of storage-units. It is subject to the license terms in the LICENSE file found in the top-level
3 * directory of this distribution and at http://creativecommons.org/publicdomain/zero/1.0/. No part of storage-units,
4 * including this file, may be copied, modified, propagated, or distributed except according to the terms contained
7 package de
.xn__ho_hia
.utils
.storage_unit
;
9 import static de
.xn__ho_hia
.quality
.null_analysis
.Nullsafe
.addNullsafe
;
10 import static de
.xn__ho_hia
.quality
.null_analysis
.Nullsafe
.asBigInteger
;
11 import static de
.xn__ho_hia
.quality
.null_analysis
.Nullsafe
.divideNullsafe
;
12 import static de
.xn__ho_hia
.quality
.null_analysis
.Nullsafe
.multiplyNullsafe
;
13 import static de
.xn__ho_hia
.quality
.null_analysis
.Nullsafe
.subtractNullsafe
;
15 import java
.math
.BigInteger
;
16 import java
.util
.function
.Function
;
18 import org
.eclipse
.jdt
.annotation
.NonNull
;
21 * Tebibyte as specified in ISO IEC 80000-13:2008 (1 Tebibyte = 1 099 511 627 776 Byte).
23 public final class Tebibyte
extends StorageUnit
<Tebibyte
> {
26 private static final long serialVersionUID
= 3614537130129620881L;
28 Tebibyte(@NonNull final BigInteger bytes
) {
33 * @param numberOfBytes
34 * The amount of bytes the Tebibyte contains.
35 * @return A new Tebibyte unit with the given value.
38 public static Tebibyte
valueOf(@NonNull final BigInteger numberOfBytes
) {
39 return new Tebibyte(numberOfBytes
);
43 * @param numberOfBytes
44 * The amount of bytes the Tebibyte contains.
45 * @return A new Tebibyte unit with the given value.
48 public static Tebibyte
valueOf(final long numberOfBytes
) {
49 return new Tebibyte(asBigInteger(numberOfBytes
));
53 * @param numberOfBytes
54 * The amount of bytes the Tebibyte contains.
55 * @return A new Tebibyte unit with the given value.
58 public static Tebibyte
valueOf(@NonNull final Long numberOfBytes
) {
59 return valueOf(numberOfBytes
.longValue());
63 public Tebibyte
add(final long bytesToAdd
) {
64 return new Tebibyte(addNullsafe(bytes
, asBigInteger(bytesToAdd
)));
68 public Tebibyte
add(final StorageUnit
<?
> storageAmount
) {
69 return new Tebibyte(addNullsafe(bytes
, storageAmount
.bytes
));
73 public Tebibyte
divide(final long divisor
) {
74 return new Tebibyte(divideNullsafe(bytes
, asBigInteger(divisor
)));
78 public Tebibyte
multiply(final long factor
) {
79 return new Tebibyte(multiplyNullsafe(bytes
, asBigInteger(factor
)));
83 public Tebibyte
subtract(final long bytesToSubtract
) {
84 return new Tebibyte(subtractNullsafe(bytes
, asBigInteger(bytesToSubtract
)));
88 public Tebibyte
subtract(final StorageUnit
<?
> storageAmount
) {
89 return new Tebibyte(subtractNullsafe(bytes
, storageAmount
.bytes
));
93 protected BigInteger
getNumberOfBytesPerUnit() {
94 return StorageUnit
.BYTES_IN_A_TEBIBYTE
;
98 protected String
getSymbol() {
99 return "TiB"; //$NON-NLS-1$
103 protected Function
<@NonNull BigInteger
, @NonNull StorageUnit
<?
>> converter() {
104 return StorageUnits
::binaryValueOf
;