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
.utils
.storage_unit
.NullsafeMath
.addNullsafe
;
10 import static de
.xn__ho_hia
.utils
.storage_unit
.NullsafeMath
.asBigInteger
;
11 import static de
.xn__ho_hia
.utils
.storage_unit
.NullsafeMath
.divideNullsafe
;
12 import static de
.xn__ho_hia
.utils
.storage_unit
.NullsafeMath
.multiplyNullsafe
;
13 import static de
.xn__ho_hia
.utils
.storage_unit
.NullsafeMath
.subtractNullsafe
;
15 import java
.math
.BigInteger
;
18 * Tebibyte as specified in ISO IEC 80000-13:2008 (1 Tebibyte = 1 099 511 627 776 Byte).
20 public final class Tebibyte
extends StorageUnit
<Tebibyte
> {
23 private static final long serialVersionUID
= 3614537130129620881L;
25 Tebibyte(final BigInteger bytes
) {
30 * @param numberOfBytes
31 * The amount of bytes the tebibyte contains.
32 * @return A new Tebibyte unit with the given value.
34 public static Tebibyte
valueOf(final BigInteger numberOfBytes
) {
35 return new Tebibyte(numberOfBytes
);
39 * @param numberOfBytes
40 * The amount of bytes the tebibytes contains.
41 * @return A new Tebibyte unit with the given value.
43 public static Tebibyte
valueOf(final long numberOfBytes
) {
44 return new Tebibyte(asBigInteger(numberOfBytes
));
48 * @param numberOfBytes
49 * The amount of bytes the tebibytes contains.
50 * @return A new Tebibyte unit with the given value.
52 public static Tebibyte
valueOf(final Long numberOfBytes
) {
53 return valueOf(numberOfBytes
.longValue());
57 public Tebibyte
add(final long bytesToAdd
) {
58 return new Tebibyte(addNullsafe(bytes
, asBigInteger(bytesToAdd
)));
62 public Tebibyte
add(final StorageUnit
<?
> storageAmount
) {
63 return new Tebibyte(addNullsafe(bytes
, storageAmount
.bytes
));
67 public Tebibyte
divide(final long divisor
) {
68 return new Tebibyte(divideNullsafe(bytes
, asBigInteger(divisor
)));
72 public Tebibyte
multiply(final long factor
) {
73 return new Tebibyte(multiplyNullsafe(bytes
, asBigInteger(factor
)));
77 public Tebibyte
subtract(final long bytesToSubtract
) {
78 return new Tebibyte(subtractNullsafe(bytes
, asBigInteger(bytesToSubtract
)));
82 public Tebibyte
subtract(final StorageUnit
<?
> storageAmount
) {
83 return new Tebibyte(subtractNullsafe(bytes
, storageAmount
.bytes
));
87 protected BigInteger
getNumberOfBytesPerUnit() {
88 return StorageUnit
.BYTES_IN_A_TEBIBYTE
;
92 protected String
getSymbol() {
93 return "TiB"; //$NON-NLS-1$