/** * Register bean arguments and row mapping for an {@code Modifiable*} value class, expecting the default generated class and public nullary constructor. * @param spec the specification interface or abstract class * @param <S> the specification class * @return a plugin that configures type mapping for the given class */ public <S> JdbiImmutables registerModifiable(Class<S> spec) { final Class<? extends S> impl = classByPrefix("Modifiable", spec); return registerModifiable(spec, impl, nullaryMethodOf(impl, "create") .orElseGet(() -> constructorOf(impl))); }
/** * Register bean arguments and row mapping for an {@code Immutable*} value class, expecting the default generated class and builder names. * @param spec the specification interface or abstract class * @param <S> the specification class * @return a plugin that configures type mapping for the given class */ public <S> JdbiImmutables registerImmutable(Class<S> spec) { final Class<? extends S> impl = classByPrefix("Immutable", spec); return registerImmutable(spec, impl, JdbiOptionals.findFirstPresent( () -> nullaryMethodOf(spec, "builder"), () -> nullaryMethodOf(impl, "builder")) .orElseThrow(() -> new IllegalArgumentException("Neither " + spec + " nor " + impl + " have a 'builder' method"))); }