Annotation Interface IfNullEvenRequired
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 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(
@IfNullEvenRequired(handler = FallbackHandler.class)
@Required
String importantToken
) {}
- 関連項目:
-
ErrorHandlerWith
-
必須要素の概要
必須要素
-
要素の詳細
-
handler
Class<? extends net.ririfa.yacla.loader.ErrorHandlerWith> handlerSpecifies the handler class to invoke if the field value is null or blank.- 戻り値:
- the class implementing
ErrorHandlerWith
-