-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Sebastian Hoß <seb@hoß.de>
- Loading branch information
Showing
21 changed files
with
1,398 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
131 changes: 131 additions & 0 deletions
131
storage-units-model/src/main/java/wtf/metio/storageunits/model/Qubibyte.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
/* | ||
* SPDX-FileCopyrightText: The Storage-Units Authors | ||
* SPDX-License-Identifier: 0BSD | ||
*/ | ||
package wtf.metio.storageunits.model; | ||
|
||
import edu.umd.cs.findbugs.annotations.CheckReturnValue; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.io.Serial; | ||
import java.math.BigInteger; | ||
import java.util.function.Function; | ||
|
||
/** | ||
* Qubibyte as specified in ISO IEC 80000-13:2008 (1 Qubibyte = 1 267 650 600 228 229 401 496 703 205 376 Byte). | ||
*/ | ||
public final class Qubibyte extends StorageUnit<Qubibyte> { | ||
|
||
@Serial | ||
private static final long serialVersionUID = 8611754914470986560L; | ||
|
||
Qubibyte(final @NotNull BigInteger bytes) { | ||
super(bytes); | ||
} | ||
|
||
/** | ||
* @param numberOfBytes The amount of bytes the Qubibyte contains. | ||
* @return A new Qubibyte unit with the given value. | ||
*/ | ||
@CheckReturnValue | ||
public static @NotNull Qubibyte valueOf(final @NotNull BigInteger numberOfBytes) { | ||
return new Qubibyte(numberOfBytes); | ||
} | ||
|
||
/** | ||
* @param numberOfBytes The amount of bytes the Qubibyte contains. | ||
* @return A new Qubibyte unit with the given value. | ||
*/ | ||
@CheckReturnValue | ||
public static @NotNull Qubibyte valueOf(final long numberOfBytes) { | ||
return valueOf(BigInteger.valueOf(numberOfBytes)); | ||
} | ||
|
||
/** | ||
* @param numberOfBytes The amount of bytes the Qubibyte contains. | ||
* @return A new Qubibyte unit with the given value. | ||
*/ | ||
@CheckReturnValue | ||
public static @NotNull Qubibyte valueOf(final @NotNull Long numberOfBytes) { | ||
return valueOf(numberOfBytes.longValue()); | ||
} | ||
|
||
@Override | ||
@CheckReturnValue | ||
public @NotNull Qubibyte add(final long bytesToAdd) { | ||
return add(BigInteger.valueOf(bytesToAdd)); | ||
} | ||
|
||
@Override | ||
@CheckReturnValue | ||
public @NotNull Qubibyte add(final @NotNull BigInteger bytesToAdd) { | ||
return new Qubibyte(bytes.add(bytesToAdd)); | ||
} | ||
|
||
@Override | ||
@CheckReturnValue | ||
public @NotNull Qubibyte add(final @NotNull StorageUnit<?> storageAmount) { | ||
return add(storageAmount.bytes); | ||
} | ||
|
||
@Override | ||
@CheckReturnValue | ||
public @NotNull Qubibyte divide(final long divisor) { | ||
return divide(BigInteger.valueOf(divisor)); | ||
} | ||
|
||
@Override | ||
@CheckReturnValue | ||
public @NotNull Qubibyte divide(final @NotNull BigInteger divisor) { | ||
return new Qubibyte(bytes.divide(divisor)); | ||
} | ||
|
||
@Override | ||
@CheckReturnValue | ||
public @NotNull Qubibyte multiply(final long factor) { | ||
return multiply(BigInteger.valueOf(factor)); | ||
} | ||
|
||
@Override | ||
@CheckReturnValue | ||
public @NotNull Qubibyte multiply(final @NotNull BigInteger factor) { | ||
return new Qubibyte(bytes.multiply(factor)); | ||
} | ||
|
||
@Override | ||
@CheckReturnValue | ||
public @NotNull Qubibyte subtract(final long bytesToSubtract) { | ||
return subtract(BigInteger.valueOf(bytesToSubtract)); | ||
} | ||
|
||
@Override | ||
@CheckReturnValue | ||
public @NotNull Qubibyte subtract(final @NotNull BigInteger bytesToSubtract) { | ||
return new Qubibyte(bytes.subtract(bytesToSubtract)); | ||
} | ||
|
||
@Override | ||
@CheckReturnValue | ||
public @NotNull Qubibyte subtract(final @NotNull StorageUnit<?> storageAmount) { | ||
return subtract(storageAmount.bytes); | ||
} | ||
|
||
@Override | ||
@CheckReturnValue | ||
protected @NotNull BigInteger getNumberOfBytesPerUnit() { | ||
return StorageUnit.BYTES_IN_A_QUBIBYTE; | ||
} | ||
|
||
@Override | ||
@CheckReturnValue | ||
protected @NotNull String getSymbol() { | ||
return "QiB"; | ||
} | ||
|
||
@Override | ||
@CheckReturnValue | ||
protected @NotNull Function<@NotNull BigInteger, @NotNull StorageUnit<?>> converter() { | ||
return StorageUnits::binaryValueOf; | ||
} | ||
|
||
} |
131 changes: 131 additions & 0 deletions
131
storage-units-model/src/main/java/wtf/metio/storageunits/model/Quettabyte.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
/* | ||
* SPDX-FileCopyrightText: The Storage-Units Authors | ||
* SPDX-License-Identifier: 0BSD | ||
*/ | ||
package wtf.metio.storageunits.model; | ||
|
||
import edu.umd.cs.findbugs.annotations.CheckReturnValue; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.io.Serial; | ||
import java.math.BigInteger; | ||
import java.util.function.Function; | ||
|
||
/** | ||
* Quettabyte as specified in ISO IEC 80000-13:2008 (1 Quettabyte = 1 000 000 000 000 000 000 000 000 000 000 Byte). | ||
*/ | ||
public final class Quettabyte extends StorageUnit<Quettabyte> { | ||
|
||
@Serial | ||
private static final long serialVersionUID = -7866123408102424489L; | ||
|
||
Quettabyte(final @NotNull BigInteger bytes) { | ||
super(bytes); | ||
} | ||
|
||
/** | ||
* @param numberOfBytes The amount of bytes the Quettabyte contains. | ||
* @return A new Quettabyte unit with the given value. | ||
*/ | ||
@CheckReturnValue | ||
public static @NotNull Quettabyte valueOf(final @NotNull BigInteger numberOfBytes) { | ||
return new Quettabyte(numberOfBytes); | ||
} | ||
|
||
/** | ||
* @param numberOfBytes The amount of bytes the Quettabyte contains. | ||
* @return A new Quettabyte unit with the given value. | ||
*/ | ||
@CheckReturnValue | ||
public static @NotNull Quettabyte valueOf(final long numberOfBytes) { | ||
return valueOf(BigInteger.valueOf(numberOfBytes)); | ||
} | ||
|
||
/** | ||
* @param numberOfBytes The amount of bytes the Quettabyte contains. | ||
* @return A new Quettabyte unit with the given value. | ||
*/ | ||
@CheckReturnValue | ||
public static @NotNull Quettabyte valueOf(final @NotNull Long numberOfBytes) { | ||
return valueOf(numberOfBytes.longValue()); | ||
} | ||
|
||
@Override | ||
@CheckReturnValue | ||
public @NotNull Quettabyte add(final long bytesToAdd) { | ||
return add(BigInteger.valueOf(bytesToAdd)); | ||
} | ||
|
||
@Override | ||
@CheckReturnValue | ||
public @NotNull Quettabyte add(final @NotNull BigInteger bytesToAdd) { | ||
return new Quettabyte(bytes.add(bytesToAdd)); | ||
} | ||
|
||
@Override | ||
@CheckReturnValue | ||
public @NotNull Quettabyte add(final @NotNull StorageUnit<?> storageAmount) { | ||
return add(storageAmount.bytes); | ||
} | ||
|
||
@Override | ||
@CheckReturnValue | ||
public @NotNull Quettabyte divide(final long divisor) { | ||
return divide(BigInteger.valueOf(divisor)); | ||
} | ||
|
||
@Override | ||
@CheckReturnValue | ||
public @NotNull Quettabyte divide(final @NotNull BigInteger divisor) { | ||
return new Quettabyte(bytes.divide(divisor)); | ||
} | ||
|
||
@Override | ||
@CheckReturnValue | ||
public @NotNull Quettabyte multiply(final long factor) { | ||
return multiply(BigInteger.valueOf(factor)); | ||
} | ||
|
||
@Override | ||
@CheckReturnValue | ||
public @NotNull Quettabyte multiply(final @NotNull BigInteger factor) { | ||
return new Quettabyte(bytes.multiply(factor)); | ||
} | ||
|
||
@Override | ||
@CheckReturnValue | ||
public @NotNull Quettabyte subtract(final long bytesToSubtract) { | ||
return subtract(BigInteger.valueOf(bytesToSubtract)); | ||
} | ||
|
||
@Override | ||
@CheckReturnValue | ||
public @NotNull Quettabyte subtract(final @NotNull BigInteger bytesToSubtract) { | ||
return new Quettabyte(bytes.subtract(bytesToSubtract)); | ||
} | ||
|
||
@Override | ||
@CheckReturnValue | ||
public @NotNull Quettabyte subtract(final @NotNull StorageUnit<?> storageAmount) { | ||
return subtract(storageAmount.bytes); | ||
} | ||
|
||
@Override | ||
@CheckReturnValue | ||
protected @NotNull BigInteger getNumberOfBytesPerUnit() { | ||
return StorageUnit.BYTES_IN_A_QUETTABYTE; | ||
} | ||
|
||
@Override | ||
@CheckReturnValue | ||
protected @NotNull String getSymbol() { | ||
return "QB"; | ||
} | ||
|
||
@Override | ||
@CheckReturnValue | ||
protected @NotNull Function<@NotNull BigInteger, @NotNull StorageUnit<?>> converter() { | ||
return StorageUnits::decimalValueOf; | ||
} | ||
|
||
} |
Oops, something went wrong.