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 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
) {}

See also

Functions

Link copied to clipboard
abstract fun annotationType(): Class<out Annotation>
Link copied to clipboard
abstract fun equals(p: Any): Boolean
Link copied to clipboard
abstract fun handler(): Class<out ErrorHandlerWith>
Specifies the handler class to invoke if the field value is null or blank.
Link copied to clipboard
abstract fun hashCode(): Int
Link copied to clipboard
abstract fun toString(): String