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 * Petabyte as specified in ISO IEC 80000-13:2008 (1 Petabyte = 1 000 000 000 000 000 Byte).
23 public class Petabyte
extends StorageUnit
<Petabyte
> {
25 private static final long serialVersionUID
= 5889808368085688387L;
27 Petabyte(@NonNull final BigInteger bytes
) {
32 * @param numberOfBytes
33 * The amount of bytes the Petabyte contains.
34 * @return A new Petabyte unit with the given value.
37 public static Petabyte
valueOf(@NonNull final BigInteger numberOfBytes
) {
38 return new Petabyte(numberOfBytes
);
42 * @param numberOfBytes
43 * The amount of bytes the Petabyte contains.
44 * @return A new Petabyte unit with the given value.
47 public static Petabyte
valueOf(final long numberOfBytes
) {
48 return new Petabyte(asBigInteger(numberOfBytes
));
52 * @param numberOfBytes
53 * The amount of bytes the Petabyte contains.
54 * @return A new Petabyte unit with the given value.
57 public static Petabyte
valueOf(@NonNull final Long numberOfBytes
) {
58 return valueOf(numberOfBytes
.longValue());
62 public Petabyte
add(final long bytesToAdd
) {
63 return new Petabyte(addNullsafe(bytes
, asBigInteger(bytesToAdd
)));
67 public Petabyte
add(final StorageUnit
<?
> storageAmount
) {
68 return new Petabyte(addNullsafe(bytes
, storageAmount
.bytes
));
72 public Petabyte
divide(final long divisor
) {
73 return new Petabyte(divideNullsafe(bytes
, asBigInteger(divisor
)));
77 public Petabyte
multiply(final long factor
) {
78 return new Petabyte(multiplyNullsafe(bytes
, asBigInteger(factor
)));
82 public Petabyte
subtract(final long bytesToSubtract
) {
83 return new Petabyte(subtractNullsafe(bytes
, asBigInteger(bytesToSubtract
)));
87 public Petabyte
subtract(final StorageUnit
<?
> storageAmount
) {
88 return new Petabyte(subtractNullsafe(bytes
, storageAmount
.bytes
));
92 protected BigInteger
getNumberOfBytesPerUnit() {
93 return StorageUnit
.BYTES_IN_A_PETABYTE
;
97 protected String
getSymbol() {
98 return "PB"; //$NON-NLS-1$
102 protected Function
<@NonNull BigInteger
, @NonNull StorageUnit
<?
>> converter() {
103 return StorageUnits
::metricValueOf
;