Documentation Index
Fetch the complete documentation index at: https://mintlify.com/himansaBro/JungleConfig/llms.txt
Use this file to discover all available pages before exploring further.
JungleConfig is the primary entry point for the JungleConfig library. It wraps a fully assembled TypeConverter stack and exposes a clean, chainable API for reading, writing, and managing typed configuration entries backed by a file, encrypted file, or in-memory store. Every convenience constructor pre-wires a NativeConverter, NativeInternalCache, NativeInternalTransaction, NativeExtendedCache, and NativeTypeConverter with all ten default type adapters so you can start persisting configuration values without any additional setup.
Package: com.codehack.JungleConfig
Constructors & Factory Methods
JungleConfig(File file)
Creates a fully wired, file-backed configuration instance. The internal stack is assembled as follows:
- IO layer —
NativeIOHandlerreading and writingfile - Converter layer —
NativeConverter(custom key-value format, URL-encoded values) - Internal cache —
NativeInternalCachewith a write margin of10and a read margin of100, flush-on-write enabled - Transaction layer —
NativeInternalTransaction - Extended cache —
NativeExtendedCache - Type converter —
NativeTypeConverterwith Jackson fallback enabled and all 10 default adapters registered
The file to use as the configuration store. Created automatically if it does not exist.
JungleConfig(TypeConverter converter)
Low-level constructor for assembling a custom stack. Pass any implementation of TypeConverter — useful when you need a non-standard converter chain, a custom IOHandlerInterface, or a different caching strategy.
A fully assembled
TypeConverter implementation that will handle all read, write, and transaction operations.static JungleConfig EncryptedConfig(File file, String password)
Factory method that builds the same full stack as the File constructor but replaces NativeConverter with NativeEncryptedConverter, which encrypts the configuration file contents using the supplied password. All other layers — caching, transactions, type adapters — are identical to the default stack.
The file to use as the encrypted configuration store.
The encryption password. Must be the same value on every subsequent read.
static JungleConfig InMemoryConfig()
Factory method that creates a configuration instance backed entirely by memory using NativeInMemoryIOHandler. No file is created or read. Data is lost when the JVM exits. Useful for tests, ephemeral configuration, and unit-testing application logic that depends on JungleConfig.
static JungleConfig FlatJsonConfig()
Factory method that uses NativeFlatJsonConverter together with NativeInMemoryIOHandler. Configuration entries are encoded as flat JSON rather than the native key-value format. Data is stored in memory only.
Write Methods
Set(String key, Object data) → JungleConfig
Stores a value under the given key. The type tag is determined automatically by calling data.getClass().getSimpleName() and looking up a matching TypeConverterAdapter. If no adapter is found and Jackson fallback is enabled (the default), the value is serialized to JSON and stored with the tag "Json". Returns this to allow method chaining.
The configuration key under which the value is stored. Keys are arbitrary strings; dots are a conventional but not enforced namespace separator.
The value to store. Must not be
null when relying on automatic type detection. Any type with a registered adapter or any Jackson-serializable POJO is accepted.Set(String key, Object data, String type) → JungleConfig
Stores a value with an explicit type hint. The type string must exactly match either an adapter’s getType() return value (e.g. "Integer", "UUID") or the literal "Json" to force Jackson serialization. Use this overload when the runtime class of data differs from the target adapter name, or when you want to guarantee a specific serialization path.
The configuration key.
The value to store.
The type tag. Must match an adapter’s
getType() value or "Json".SetPOJO(String key, Object pojo) → JungleConfig
Forces Jackson serialization regardless of whether a native adapter exists for the object’s type. The value is always stored with the tag "Json". Use this method when storing complex objects, generic containers, or any type where you want Jackson’s full serialization capabilities rather than a custom adapter.
The configuration key.
Any Jackson-serializable object. The object’s class must be visible to the default Jackson
ObjectMapper.Read Methods
get(String key, Class<T> type) → T
Returns the value stored under key, deserialized to type. Returns null if the key does not exist. This is the low-level, null-returning variant — prefer Get when you want to avoid null checks.
The configuration key to look up.
The target Java type. Must match the type with which the value was stored, or be a Jackson-compatible target for JSON-tagged entries.
Get(String key, Class<T> type) → Optional<T>
Safe variant of get. Returns Optional.empty() when the key does not exist, instead of null. Prefer this method in application code where missing keys are a normal condition rather than an error.
The configuration key to look up.
The target Java type.
getCollection(String key, TypeReference<T> type) → T
Reads a value into a generic collection type such as List<String> or Map<String, Integer>. Because Java erases generic type parameters at runtime, Class<T> is insufficient for these cases; pass a Jackson TypeReference instead. Returns null if the key does not exist.
The configuration key to look up.
A Jackson
TypeReference capturing the full generic type, including type parameters.GetCollection(String key, TypeReference<T> type) → Optional<T>
Optional-returning variant of getCollection. Returns Optional.empty() when the key does not exist.
The configuration key to look up.
A Jackson
TypeReference capturing the full generic type.Transaction Methods
JungleConfig supports explicit transactions that batch multiple writes and defer disk persistence untilCommit() or EndTransaction() is called. Transactions are managed at the NativeInternalTransaction layer.
BeginTransaction() → JungleConfig
Suspends auto-commit so that subsequent Set, Remove, and RemoveAllKeys calls are buffered in memory and not written to disk. Returns this for chaining.
Commit() → JungleConfig
Flushes all pending writes accumulated since the last BeginTransaction() or Commit() to the underlying store. Does not re-enable auto-commit — call EndTransaction() for that. Returns this.
Rollback() → JungleConfig
Discards all pending writes accumulated since the last BeginTransaction() or Commit(). The configuration store is left unchanged. Returns this.
EndTransaction() → void
Re-enables auto-commit and immediately flushes any pending writes that were buffered since the last explicit Commit() or Rollback(). After this call, every Set or Remove is immediately persisted. This method returns void and cannot be chained.
Key Operations
Remove(String key) → boolean
Removes the entry with the given key. Returns true if the key existed and was removed, false if the key was not present.
The key to remove.
RemoveAllKeys() → void
Clears every entry in the configuration store. Equivalent to calling Remove on every key returned by getAllKeys(), but implemented as a single atomic clear operation at the cache layer.
Exists(String key) → boolean
Returns true if the given key is present in the configuration store.
The key to test.
getAllKeys() → List<String>
Returns an unordered list of every key currently stored in the configuration.
getAllKeys(String regx) → List<String>
Returns the subset of keys whose full string matches the supplied Java regular expression. The regex is applied as a full-match (equivalent to String.matches(regx)), not a substring search.
A Java regular expression. Only keys whose entire string matches are included.
getTypeSimpleName(String key) → String
Returns the type tag stored alongside the value for the given key (e.g. "String", "Integer", "Json"). Returns null if the key does not exist.
The key whose type tag to retrieve.
GetTypeSimpleName(String key) → Optional<String>
Optional-returning variant of getTypeSimpleName. Wraps the result in Optional.of(...).
The key whose type tag to retrieve.
Cache & Backup
InvalidateCache() → void
Marks the internal cache as dirty. The next read operation will reload data from the underlying ConverterInterface (i.e., from disk or the in-memory store), discarding any cached state. Use this when the backing file may have been modified externally.
Backup(File path, boolean override) → boolean
Copies the current configuration store to path. Returns true if the backup succeeded.
Destination file for the backup copy.
When
true, an existing file at path is overwritten. When false, the backup is aborted and false is returned if the destination already exists.Query
query(boolean iKey, String keyReg, boolean iType, String typeReg, boolean iVal, String valReg) → TypeMap<String, String, String>
Performs a regex-filtered scan over all entries in the configuration store. Each stored entry is represented as a triple of (key, typeName, encodedValue). The method applies three independent XOR filters — one for each field — and returns only entries that satisfy all three conditions simultaneously.
For each field, an entry is included when (iFlag XOR field.matches(regex)) evaluates to true. Concretely:
- When
iFlag = false: the entry is included if the field matches the regex. - When
iFlag = true: the entry is included if the field does not match the regex (inversion).
XOR flag for the key filter. When
false, includes entries whose key matches keyReg. When true, includes entries whose key does not match keyReg.Java regular expression applied against each entry’s key string.
XOR flag for the type filter. When
false, includes entries whose type tag matches typeReg. When true, includes entries whose type tag does not match typeReg.Java regular expression applied against each entry’s type tag (e.g.
"String", "Integer", "Json").XOR flag for the value filter. When
false, includes entries whose stored value matches valReg. When true, includes entries whose stored value does not match valReg.Java regular expression applied against each entry’s encoded (string) value as it is stored internally.
TypeMap<String, String, String> where each Entry provides:
getKey()— the configuration keygetValue1()— the type simple name taggetValue2()— the encoded value string
".+" for any regex and false for its invert flag to match all entries for that field.
