Nomad changes
All checks were successful
Deploy fil (kreuzberg) / deploy (push) Successful in 49s

This commit is contained in:
Henrik Jess Nielsen
2026-06-01 23:40:55 +02:00
parent 72b1a0a6ed
commit b4c07d3693
5723 changed files with 1130655 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
// This file is auto-generated by alef — DO NOT EDIT.
// alef:hash:4e15143f4af1ae8bafbdb1506ef057da924484c66a19483966333558ad437e75
// To regenerate: alef generate
// To verify freshness: alef verify --exit-code
// Issues & docs: https://github.com/kreuzberg-dev/alef
package dev.kreuzberg;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
/** Centralized JSON deserialization utility for all DTOs. */
@SuppressWarnings("checkstyle:LineLength")
public final class JsonUtil {
private static final ObjectMapper MAPPER;
static {
MAPPER = new ObjectMapper()
.registerModule(new Jdk8Module())
.findAndRegisterModules()
.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE)
.setSerializationInclusion(JsonInclude.Include.NON_NULL)
.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS, true);
}
private JsonUtil() {
// Utility class; no instances
}
/**
* Deserialize a JSON string into the given class.
*
* @param <T> The target type
* @param json JSON string with Rust-side field names (snake_case)
* @param targetClass The class to deserialize into
* @return The deserialized instance
* @throws KreuzbergRsException if deserialization fails
*/
public static <T> T fromJson(final String json, final Class<T> targetClass) throws KreuzbergRsException {
try {
return MAPPER.readValue(json, targetClass);
} catch (Exception e) {
throw new KreuzbergRsException(
"Failed to parse " + targetClass.getSimpleName() + " from JSON: " + e.getMessage(),
e
);
}
}
}