If Null Even Required
Indicates that if the annotated field is found to be null or blank during config loading, the specified ErrorHandlerWith should be invoked instead of failing immediately.
This is especially useful for recovering from partially missing configuration, or for performing side-effects (e.g., logging, fallback mutation) when required fields are not present.
Typically used in combination with net.ririfa.yacla.annotation.Required. This annotation does not override validation failure unless ErrorHandlerWith handles it explicitly.
Example:
public class FallbackHandler implements ErrorHandlerWith {
public void handle(Object fieldValue) {
System.out.println("Field was null! Recovering...");
}
}
public record AppConfig(
= FallbackHandler.class)
String importantToken
) {}
Content copied to clipboard