Annotation Interface CustomLoader


@Target(FIELD) @Retention(RUNTIME) public @interface CustomLoader
Specifies a custom FieldLoader to transform the raw parsed value into the final value assigned to the annotated field.

This is useful when the configuration format provides generic structures (e.g., lists, strings), and you need to convert them into specific types like enums, wrappers, or complex objects.

The loader is instantiated via its no-arg constructor and invoked during config loading.

Example:


 public class EnumListLoader implements FieldLoader {
     public Object load(Object raw) {
         List<?> list = (List<?>) raw;
         return list.stream()
             .map(e -> MyEnum.valueOf(e.toString()))
             .collect(Collectors.toList());
     }
 }

 public record AppConfig(
     @CustomLoader(loader = EnumListLoader.class)
     List<MyEnum> modes
 ) {}
 
関連項目:
  • FieldLoader
  • 必須要素の概要

    必須要素
    修飾子とタイプ
    必須要素
    説明
    Class<? extends net.ririfa.yacla.loader.FieldLoader>
    Specifies the loader class responsible for transforming the raw value.
  • 要素の詳細

    • loader

      Class<? extends net.ririfa.yacla.loader.FieldLoader> loader
      Specifies the loader class responsible for transforming the raw value.
      戻り値:
      the class implementing FieldLoader