Add number of bytes per unit to javadoc + test
[storage-units.git] / src / main / java / com / github / sebhoss / units / storage / Zettabyte.java
blob5a8eb26c20d881241fe3618fa61fc146e933e3a7
1 /*
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
7 * means.
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;
31 /**
32 * Zettabyte as specified in ISO IEC 80000-13:2008 (1 Zettabyte = 1 000 000 000 000 000 000 000 Byte).
34 public class Zettabyte extends StorageUnit<Zettabyte> {
36 private static final long serialVersionUID = 8849006574018911826L;
38 Zettabyte(final BigInteger bytes) {
39 super(bytes);
42 /**
43 * @param numberOfBytes
44 * The amount of bytes the zettabyte contains.
45 * @return A new Zettabyte unit with the given value.
47 public static Zettabyte valueOf(final BigInteger numberOfBytes) {
48 return new Zettabyte(numberOfBytes);
51 /**
52 * @param numberOfBytes
53 * The amount of bytes the zettabytes contains.
54 * @return A new Zettabyte unit with the given value.
56 public static Zettabyte valueOf(final long numberOfBytes) {
57 return new Zettabyte(BigInteger.valueOf(numberOfBytes));
60 /**
61 * @param numberOfBytes
62 * The amount of bytes the zettabytes contains.
63 * @return A new Zettabyte unit with the given value.
65 public static Zettabyte valueOf(final Long numberOfBytes) {
66 return valueOf(numberOfBytes.longValue());
69 @Override
70 public Zettabyte add(final long bytesToAdd) {
71 return new Zettabyte(bytes.add(BigInteger.valueOf(bytesToAdd)));
74 @Override
75 public Zettabyte add(final StorageUnit<?> storageAmount) {
76 return new Zettabyte(bytes.add(storageAmount.bytes));
79 @Override
80 public Zettabyte divide(final long divisor) {
81 return new Zettabyte(bytes.divide(BigInteger.valueOf(divisor)));
84 @Override
85 public Zettabyte multiply(final long factor) {
86 return new Zettabyte(bytes.multiply(BigInteger.valueOf(factor)));
89 @Override
90 public Zettabyte subtract(final long bytesToSubtract) {
91 return new Zettabyte(bytes.subtract(BigInteger.valueOf(bytesToSubtract)));
94 @Override
95 public Zettabyte subtract(final StorageUnit<?> storageAmount) {
96 return new Zettabyte(bytes.subtract(storageAmount.bytes));
99 @Override
100 protected BigInteger getNumberOfBytesPerUnit() {
101 return StorageUnit.BYTES_IN_A_ZETTABYTE;
104 @Override
105 protected String getSymbol() {
106 return "ZB"; //$NON-NLS-1$