Annotation Interface IfNullEvenRequired


@Target(FIELD) @Retention(RUNTIME) public @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
  • 必須要素の概要

    必須要素
    修飾子とタイプ
    必須要素
    説明
    Class<? extends net.ririfa.yacla.loader.ErrorHandlerWith>
    Specifies the handler class to invoke if the field value is null or blank.
  • 要素の詳細

    • handler

      Class<? extends net.ririfa.yacla.loader.ErrorHandlerWith> handler
      Specifies the handler class to invoke if the field value is null or blank.
      戻り値:
      the class implementing ErrorHandlerWith