OnixByte Toolbox API

Package Overview

All modules are published under the com.onixbyte group ID. Each module has its own base package:

ModuleMaven ArtifactBase Package
Common Toolboxcommon-toolboxcom.onixbyte.common
Crypto Toolboxcrypto-toolboxcom.onixbyte.crypto
Math Toolboxmath-toolboxcom.onixbyte.math
Tupletuplecom.onixbyte.tuple
Identity Generatoridentity-generatorcom.onixbyte.identitygenerator

Common Toolbox

Adapter

ObjectMapAdapter — Converts between objects and maps. Useful for serialisation or data transformation scenarios where key-value representations are preferred.

import com.onixbyte.common.adapter.ObjectMapAdapter;

Utility Classes

ClassDescription
AesUtilAES symmetric encryption/decryption with key generation
Base64UtilBase64 encoding and decoding with multiple charset support
BoolUtilBoolean parsing and conversion utilities
BranchUtilConditional branching helpers with functional-style chains
CollectionUtilCollection manipulation — grouping, partitioning, merging
HashUtilHashing utilities supporting MD5, SHA-1, SHA-256, SHA-512
MapUtilMap builder, merge, and transformation helpers
RangeUtilNumeric range operations with boundary handling

AesUtil Example:

var key = AesUtil.generateKey();
var encrypted = AesUtil.encrypt("hello world", key);
var decrypted = AesUtil.decrypt(encrypted, key);

HashUtil Example:

var md5 = HashUtil.md5("hello world");
var sha256 = HashUtil.sha256("hello world");
var fileSha = HashUtil.sha256(new File("data.bin"));

CollectionUtil Example:

var partitioned = CollectionUtil.partition(list, 100);
var grouped = CollectionUtil.groupBy(users, User::getDepartment);

Crypto Toolbox

Provides a clean abstraction for loading cryptographic keys in PEM format. Supports both RSA and ECDSA algorithms.

Key Loaders

ClassDescription
RSAPrivateKeyLoaderLoad RSA private keys from PEM strings
RSAPublicKeyLoaderLoad RSA public keys from PEM strings
ECPrivateKeyLoaderLoad ECDSA private keys from PEM strings
ECPublicKeyLoaderLoad ECDSA public keys from PEM strings

All key loaders implement either PrivateKeyLoader or PublicKeyLoader interfaces.

RSA Example:

var privateKey = new RSAPrivateKeyLoader().load(pemString);
var publicKey = new RSAPublicKeyLoader().load(pemString);

ECDSA Example:

var ecPrivateKey = new ECPrivateKeyLoader().load(pemString);
var ecPublicKey = new ECPublicKeyLoader().load(pemString);

Utility

CryptoUtil — Provides convenient methods for digital signature creation and verification, as well as general-purpose cryptographic helpers.

Exceptions

ClassDescription
KeyLoadingExceptionThrown when a PEM-formatted key fails to parse

Math Toolbox

Statistical computation utilities for working with numeric datasets.

Core Classes

ClassDescription
CalculatorStatistical calculator for mean, median, variance, standard deviation, sum, min, max
PercentileCalculatorPercentile computation with configurable interpolation strategies

Calculator Example:

var stats = new Calculator(Arrays.asList(1.0, 2.0, 3.0, 4.0, 5.0));
double mean = stats.getMean();
double median = stats.getMedian();
double stdDev = stats.getStandardDeviation();

PercentileCalculator Example:

var calculator = new PercentileCalculator(data);
double p95 = calculator.calculate(95);
double p99 = calculator.calculate(99);

Model

ClassDescription
QuartileBoundsHolds Q1, median (Q2), Q3 values along with IQR and whisker bounds

Tuple

Lightweight generic tuple types for when you need to return multiple values without defining a dedicated class.

Classes

ClassType ParametersMutability
Tuple<A, B>Two elementsMutable
ImmutableTuple<A, B>Two elementsImmutable
Triple<A, B, C>Three elementsMutable
ImmutableTriple<A, B, C>Three elementsImmutable

Example:

var pair = Tuple.of("key", 42);
var triple = Triple.of("id", "name", 100);
var immutable = ImmutableTuple.of("constant", true);

// Accessors
String first = pair.getFirst();
Integer second = pair.getSecond();

// Triple accessors
String a = triple.getFirst();
String b = triple.getSecond();
Integer c = triple.getThird();

Identity Generator

Generates unique identifiers suitable for use as database primary keys or distributed IDs.

Interface

IdentityGenerator<T> — Generates identities of type T.

Implementations

ClassDescription
SequentialUuidGeneratorGenerates time-ordered, sequential UUIDs (optimised for DB indexes)
SnowflakeIdentityGeneratorSnowflake-style distributed unique ID generation

Sequential UUID:

var generator = new SequentialUuidGenerator();
UUID id = generator.nextId(); // time-ordered UUID, B-tree friendly

Snowflake:

var generator = new SnowflakeIdentityGenerator(workerId, datacenterId);
long id = generator.nextId(); // 64-bit snowflake ID

Exceptions

ClassDescription
TimingExceptionThrown when the system clock moves backwards, compromising ID uniqueness