2 * This is free and unencumbered software released into the public domain.
4 * Anyone is free to copy, modify, publish, use, compile, sell, or
5 * distribute this software, either in source code form or as a compiled
6 * binary, for any purpose, commercial or non-commercial, and by any
9 * In jurisdictions that recognize copyright laws, the author or authors
10 * of this software dedicate any and all copyright interest in the
11 * software to the public domain. We make this dedication for the benefit
12 * of the public at large and to the detriment of our heirs and
13 * successors. We intend this dedication to be an overt act of
14 * relinquishment in perpetuity of all present and future rights to this
15 * software under copyright law.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
25 * For more information, please refer to <http://unlicense.org>
27 package com
.github
.sebhoss
.units
.storage
;
29 import java
.math
.BigInteger
;
32 * Tebibyte as specified in ISO IEC 80000-13:2008 (1 Tebibyte = 1 099 511 627 776 Byte).
34 public final class Tebibyte
extends StorageUnit
<Tebibyte
> {
37 private static final long serialVersionUID
= 3614537130129620881L;
39 Tebibyte(final BigInteger bytes
) {
44 * @param numberOfBytes
45 * The amount of bytes the tebibyte contains.
46 * @return A new Tebibyte unit with the given value.
48 public static Tebibyte
valueOf(final BigInteger numberOfBytes
) {
49 return new Tebibyte(numberOfBytes
);
53 * @param numberOfBytes
54 * The amount of bytes the tebibytes contains.
55 * @return A new Tebibyte unit with the given value.
57 public static Tebibyte
valueOf(final long numberOfBytes
) {
58 return new Tebibyte(BigInteger
.valueOf(numberOfBytes
));
62 * @param numberOfBytes
63 * The amount of bytes the tebibytes contains.
64 * @return A new Tebibyte unit with the given value.
66 public static Tebibyte
valueOf(final Long numberOfBytes
) {
67 return valueOf(numberOfBytes
.longValue());
71 public Tebibyte
add(final long bytesToAdd
) {
72 return new Tebibyte(bytes
.add(BigInteger
.valueOf(bytesToAdd
)));
76 public Tebibyte
add(final StorageUnit
<?
> storageAmount
) {
77 return new Tebibyte(bytes
.add(storageAmount
.bytes
));
81 public Tebibyte
divide(final long divisor
) {
82 return new Tebibyte(bytes
.divide(BigInteger
.valueOf(divisor
)));
86 public Tebibyte
multiply(final long factor
) {
87 return new Tebibyte(bytes
.multiply(BigInteger
.valueOf(factor
)));
91 public Tebibyte
subtract(final long bytesToSubtract
) {
92 return new Tebibyte(bytes
.subtract(BigInteger
.valueOf(bytesToSubtract
)));
96 public Tebibyte
subtract(final StorageUnit
<?
> storageAmount
) {
97 return new Tebibyte(bytes
.subtract(storageAmount
.bytes
));
101 protected BigInteger
getNumberOfBytesPerUnit() {
102 return StorageUnit
.BYTES_IN_A_TEBIBYTE
;
106 protected String
getSymbol() {
107 return "TiB"; //$NON-NLS-1$