Package Overview
All modules are published under the com.onixbyte group ID. Each module has its own base package:
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
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);
Provides a clean abstraction for loading cryptographic keys in PEM format. Supports both RSA and ECDSA algorithms.
Key Loaders
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
Statistical computation utilities for working with numeric datasets.
Core Classes
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
Tuple
Lightweight generic tuple types for when you need to return multiple values without defining a dedicated class.
Classes
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
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