X: Move classes from 'java' to 'tjava'

This commit is contained in:
2026-07-04 13:11:02 +02:00
parent 89a2e0e1c4
commit 5d06316acc
15 changed files with 0 additions and 0 deletions
@@ -0,0 +1,13 @@
package com.r35157.libs.math;
import java.math.BigDecimal;
import java.math.MathContext;
public interface UtilsBigDecimal {
BigDecimal min(BigDecimal a, BigDecimal b);
BigDecimal max(BigDecimal a, BigDecimal b);
BigDecimal sqrt(BigDecimal value, MathContext mc);
BigDecimal TWO = new BigDecimal("2");
BigDecimal THREE = new BigDecimal("3");
}
@@ -0,0 +1,7 @@
package com.r35157.libs.math;
import java.math.BigDecimal;
public interface UtilsDouble {
double erf(BigDecimal x);
}
@@ -0,0 +1,14 @@
package com.r35157.libs.notification;
import java.io.IOException;
public interface AddressedNotifier<
D extends NotificationDestination,
M extends NotificationMessage>
{
void push(D destination, M message) throws IOException;
default BoundNotifier<M> bind(D destination) {
return message -> push(destination, message);
}
}
@@ -0,0 +1,7 @@
package com.r35157.libs.notification;
import java.io.IOException;
public interface BoundNotifier<M extends NotificationMessage> {
void push(M message) throws IOException;
}
@@ -0,0 +1,3 @@
package com.r35157.libs.notification;
public interface NotificationDestination {}
@@ -0,0 +1,4 @@
package com.r35157.libs.notification;
public interface NotificationMessage {
}
@@ -0,0 +1,52 @@
package com.r35157.libs.solana.valuetypes;
import com.r35157.libs.valuetypes.basic.CurrencyType;
import java.util.UUID;
/**
* Defines well-known currency types used by the Solana integration.
*
* <p>Each enum value wraps a {@link CurrencyType} with a stable identifier and a
* human-readable currency name. These predefined values are intended for common
* currencies that the Solana-related modules need to reference consistently.</p>
*/
public enum WellKnownCurrencyTypes {
/**
* Native Solana currency.
*/
SOLANA(new CurrencyType(
UUID.fromString("019e0116-fce5-792f-a647-fa6da4dffec5"),
"Solana",
"SOL")
),
/**
* Syrup USDC token currency.
*/
SYRUPUSDC(new CurrencyType(
UUID.fromString("019e1d51-0600-7956-8231-f3b7058a91c2"),
"SyrupUSDC",
"SyrupUSDC")
);
/**
* Creates a well-known currency type entry.
*
* @param currencyType the currency type represented by this enum value
*/
WellKnownCurrencyTypes(CurrencyType currencyType) {
this.currencyType = currencyType;
}
/**
* Returns the currency type represented by this enum value.
*
* @return the represented currency type
*/
public CurrencyType getCurrencyType() {
return currencyType;
}
private final CurrencyType currencyType;
}
@@ -0,0 +1,16 @@
package com.r35157.libs.valuetypes.basic;
import org.jetbrains.annotations.NotNull;
import java.util.UUID;
public record CurrencyType(
UUID id,
String name,
String symbol
) {
@Override
public @NotNull String toString() {
return symbol;
}
}
@@ -0,0 +1,70 @@
package com.r35157.libs.valuetypes.basic;
import org.jetbrains.annotations.NotNull;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Semantic Versioning (SemVer):
* A version number has the form MAJOR.MINOR.PATCH.
* - Increment MAJOR for incompatible API changes,
* - Increment MINOR for added functionality in a backward-compatible way,
* - Increment PATCH for backward-compatible bug fixes or improvements.
* TODO: Not the whole specification is implemented yet!
*/
public record SemanticVersion(int major, int minor, int patch) {
/**
* Creates a SemanticVersion and validates that all components are valid.
*
* @throws IllegalArgumentException if any of {@code major}, {@code minor}, or {@code patch} is negative
*/
public SemanticVersion {
initializationGuardClause(major, minor, patch);
}
public static SemanticVersion of(int major, int minor, int patch) {
return new SemanticVersion(major, minor, patch);
}
public static SemanticVersion of(int major, int minor) {
return of(major, minor, 0);
}
public static SemanticVersion of(int major) {
return of(major, 0);
}
public static SemanticVersion of(@NotNull String versionStr) {
final String s = versionStr.trim();
final Matcher m = SEMVER_REGEX.matcher(s);
if (!m.matches()) {
throw new IllegalArgumentException("Invalid semantic version: '" + versionStr + "'!");
}
try {
final int major = Integer.parseInt(m.group(1));
final int minor = m.group(2) != null ? Integer.parseInt(m.group(2)) : 0;
final int patch = m.group(3) != null ? Integer.parseInt(m.group(3)) : 0;
return of(major, minor, patch);
} catch (NumberFormatException e) {
// Happens only with overruns
throw new IllegalArgumentException("Invalid semantic version: '" + versionStr + "'!", e);
}
}
@Override
public @NotNull String toString() {
return "%d.%d.%d".formatted(major, minor, patch);
}
private void initializationGuardClause(int major, int minor, int patch) throws IllegalArgumentException {
if (major < 0) throw new IllegalArgumentException("Version element 'major' cannot be negative - was '" + major + "'!");
if (minor < 0) throw new IllegalArgumentException("Version element 'minor' cannot be negative - was '" + minor + "'!");
if (patch < 0) throw new IllegalArgumentException("Version element 'patch' cannot be negative - was '" + patch + "'!");
}
private static final Pattern SEMVER_REGEX =
Pattern.compile("^(\\d+)(?:\\.(\\d+)(?:\\.(\\d+))?)?$");
}
@@ -0,0 +1,7 @@
package com.r35157.libs.valuetypes.basic;
public record SmtpConfiguration(
NetworkEndPoint networkEndPoint,
Credentials credentials
) {
}
@@ -0,0 +1,6 @@
package com.r35157.libs.valuetypes.basic;
public record TradingPair(
CurrencyType base, // The thing you are buying or selling.
CurrencyType quote // The currency/unit used to price the base asset.
) { }
@@ -0,0 +1,18 @@
package com.r35157.nenjim.hubd;
import com.r35157.nenjim.hubd.journal.Journal;
import org.jetbrains.annotations.NotNull;
public interface NenjimHub {
/**
* A no-operation (noop). This method is suppoted to do nothing.
*/
void noop();
/**
*
* @param journal
*/
void monitorJournal(@NotNull Journal journal);
}
@@ -0,0 +1,14 @@
package com.r35157.nenjim.hubd.ctx;
import com.r35157.libs.valuetypes.basic.SemanticVersion;
public record Context(
) {
public String getName() {
return "Some Context";
}
public SemanticVersion getVersion(String fqPackageName) {
return null; // new SemanticVersion(0, 1, 0);
}
}
@@ -0,0 +1,5 @@
package com.r35157.nenjim.hubd.journal;
public interface JournalManager {
Journal getJournal(String moduleName);
}
@@ -0,0 +1,4 @@
package com.r35157.nenjim.hubd.module;
public record Module() {
}