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.
TypeConverterAdapter is the extension point that teaches JungleConfig how to serialize and deserialize a specific Java type. Every value stored through JungleConfig.Set is routed to the adapter whose getType() matches the value’s class simple name. If no matching adapter exists and Jackson fallback is enabled, the value is serialized as JSON instead. Implementing this interface and registering the adapter with NativeTypeConverter gives you full, zero-overhead control over how a type is persisted to disk.
Package: com.codehack.JungleConfig.Core
Interface Declaration
Method Reference
getType() → String
Returns the type identifier that this adapter handles. JungleConfig uses this string as the lookup key when deciding which adapter to invoke for a given value. The returned value must equal the Java class simple name of the type you are supporting — that is, MyClass.class.getSimpleName().
For example:
BigDecimal.class.getSimpleName()→"BigDecimal"UUID.class.getSimpleName()→"UUID"LocalDate.class.getSimpleName()→"LocalDate"
JungleConfig.Set(key, value) is called without an explicit type hint, the framework calls value.getClass().getSimpleName() and looks for an adapter with a matching getType(). When JungleConfig.Set(key, value, type) is called with an explicit hint, the type argument is compared directly to getType(). The string returned by getType() is also written verbatim into the configuration file as the type tag for the entry, so it must be stable across restarts.
ConvertToSave(Object object) → String
Converts the in-memory object to a plain String suitable for storage. The object parameter is the already-resolved Java value passed to JungleConfig.Set after the adapter has been selected — it is not raw user input. The returned string is URL-encoded by the underlying ConverterInterface before being written to the configuration file, so you do not need to escape special characters yourself — return the natural string representation of the value.
The value to serialize. Guaranteed to be an instance of the type this adapter handles when called through the normal
JungleConfig.Set path.CastToUse: CastToUse(ConvertToSave(x)) must return a value equal to x.
CastToUse(String data) → Object
Converts the stored string back to the target Java type. The string passed here has already been URL-decoded by the ConverterInterface layer — it is the same string that ConvertToSave originally returned.
The URL-decoded string previously produced by
ConvertToSave.CastToUse returns Object, not a generic T. The NativeTypeConverter casts the return value to the type requested by the caller. Your implementation must therefore return an instance of exactly the class this adapter handles. Returning the wrong type will cause a ClassCastException at the call site.Registration
Custom adapters are registered by passing them as varargs toNativeTypeConverter’s constructor. The getDefaultAdapters() method in JungleConfig is private, so there is no programmatic way to retrieve the built-in adapter list to extend it. When supplying a custom NativeTypeConverter, you must include every adapter you need — both your custom ones and any built-in types you still want to support.
JungleConfig(TypeConverter) constructor accepts any fully assembled TypeConverter, so you can compose custom stacks while still using the standard caching and transaction layers. See the Custom Adapters guide for a complete wiring walkthrough.
Example: BigDecimal Adapter
The following is a complete, production-ready adapter forjava.math.BigDecimal:
CastToUse returns Object, not T — the NativeTypeConverter casts the return value to the requested type, so your adapter must return an instance of the correct class. Returning any other type results in a ClassCastException at the call site.JungleConfig stack, see Custom Adapters.