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
.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 * Yobibyte as specified in ISO IEC 80000-13:2008 (1 Yobibyte = 1 208 925 819 614 629 174 706 176 Byte).
23 public final class Yobibyte
extends StorageUnit
<Yobibyte
> {
26 private static final long serialVersionUID
= -5606322878020884194L;
28 Yobibyte(@NonNull final BigInteger bytes
) {
33 * @param numberOfBytes
34 * The amount of bytes the Yobibyte contains.
35 * @return A new Yobibyte unit with the given value.
38 public static Yobibyte
valueOf(@NonNull final BigInteger numberOfBytes
) {
39 return new Yobibyte(numberOfBytes
);
43 * @param numberOfBytes
44 * The amount of bytes the Yobibyte contains.
45 * @return A new Yobibyte unit with the given value.
48 public static Yobibyte
valueOf(final long numberOfBytes
) {
49 return new Yobibyte(asBigInteger(numberOfBytes
));
53 * @param numberOfBytes
54 * The amount of bytes the Yobibyte contains.
55 * @return A new Yobibyte unit with the given value.
58 public static Yobibyte
valueOf(@NonNull final Long numberOfBytes
) {
59 return valueOf(numberOfBytes
.longValue());
63 public Yobibyte
add(final long bytesToAdd
) {
64 return new Yobibyte(addNullsafe(bytes
, asBigInteger(bytesToAdd
)));
68 public Yobibyte
add(final StorageUnit
<?
> storageAmount
) {
69 return new Yobibyte(addNullsafe(bytes
, storageAmount
.bytes
));
73 public Yobibyte
divide(final long divisor
) {
74 return new Yobibyte(divideNullsafe(bytes
, asBigInteger(divisor
)));
78 public Yobibyte
multiply(final long factor
) {
79 return new Yobibyte(multiplyNullsafe(bytes
, asBigInteger(factor
)));
83 public Yobibyte
subtract(final long bytesToSubtract
) {
84 return new Yobibyte(subtractNullsafe(bytes
, asBigInteger(bytesToSubtract
)));
88 public Yobibyte
subtract(final StorageUnit
<?
> storageAmount
) {
89 return new Yobibyte(subtractNullsafe(bytes
, storageAmount
.bytes
));
93 protected BigInteger
getNumberOfBytesPerUnit() {
94 return StorageUnit
.BYTES_IN_A_YOBIBYTE
;
98 protected String
getSymbol() {
99 return "YiB"; //$NON-NLS-1$
103 protected Function
<@NonNull BigInteger
, @NonNull StorageUnit
<?
>> converter() {
104 return StorageUnits
::binaryValueOf
;