/** * Return a ConstructorMapper for the given type and prefix. * * @param <T> the type to map * @param type the mapped type * @param prefix the column name prefix * @return the mapper */ public static <T> RowMapper<T> of(Class<T> type, String prefix) { return new ConstructorMapper<>(findFactoryFor(type), prefix); }
/** * Instantiate a ConstructorMapper using the given constructor and prefix * * @param <T> the type to map * @param constructor the constructor to be used in mapping * @param prefix the column name prefix * @return the mapper */ public static <T> RowMapper<T> of(Constructor<T> constructor, String prefix) { return new ConstructorMapper<>(new ConstructorInstanceFactory<>(constructor), prefix); }
/** * Returns a mapper for the given bean class * * @param <T> the type to map * @param type the mapped class * @return a mapper for the given bean class */ public static <T> RowMapper<T> of(Class<T> type) { return FieldMapper.of(type, DEFAULT_PREFIX); }
/** * Create a default configuration that attempts case insensitive and * snake_case matching for names. */ public ReflectionMappers() { columnNameMatchers = Arrays.asList( new CaseInsensitiveColumnNameMatcher(), new SnakeCaseColumnNameMatcher()); strictMatching = false; }
@JdbiConstructor static MultipleStaticFactoryMethodsBean two(String s) { return new MultipleStaticFactoryMethodsBean(); } }
/** * Returns a mapper for the given bean class * * @param <T> the type to find the mapper for * @param type the mapped class * @return a mapper for the given bean class */ public static <T> RowMapper<T> of(Class<T> type) { return BeanMapper.of(type, DEFAULT_PREFIX); }
/** * Return a ConstructorMapper using the given constructor * * @param <T> the type to map * @param constructor the constructor to be used in mapping * @return the mapper */ public static <T> RowMapper<T> of(Constructor<T> constructor) { return ConstructorMapper.of(constructor, DEFAULT_PREFIX); }
@JdbiConstructor static StaticFactoryMethodBean create(String s, int i) { return new StaticFactoryMethodBean(s, i, 42); } }
@JdbiConstructor ConstructorBean(String s, int i) { this.s = s; this.i = i; } }
/** * Returns a mapper for the given bean class * * @param <T> the type to map * @param type the mapped class * @param prefix the column name prefix for each mapped field * @return a mapper for the given bean class */ public static <T> RowMapper<T> of(Class<T> type, String prefix) { return new FieldMapper<>(type, prefix); }
@Override public ReflectionMappers createCopy() { return new ReflectionMappers(this); } }
/** * Returns a mapper for the given bean class * * @param <T> the type to find the mapper for * @param type the mapped class * @param prefix the column name prefix for each mapped bean property * @return a mapper for the given bean class */ public static <T> RowMapper<T> of(Class<T> type, String prefix) { return new BeanMapper<>(type, prefix); }
@ColumnName("name") public void setS(String s) { this.s = s; } }
private ConstructorMapper(InstanceFactory<T> factory, String prefix) { this.factory = factory; this.prefix = prefix.toLowerCase(); this.constructorProperties = factory.getAnnotation(ConstructorProperties.class); }
@JdbiConstructor static MultipleStaticFactoryMethodsBean one(String s) { return new MultipleStaticFactoryMethodsBean(); }
/** * Returns a mapper factory that maps to the given bean class * * @param type the mapped class * @return a mapper factory that maps to the given bean class */ public static RowMapperFactory factory(Class<?> type) { return RowMapperFactory.of(type, BeanMapper.of(type)); }
/** * Return a ConstructorMapper for the given type. * * @param <T> the type to map * @param type the mapped type * @return the mapper */ public static <T> RowMapper<T> of(Class<T> type) { return ConstructorMapper.of(type, DEFAULT_PREFIX); }
@JdbiConstructor public Character(int id, String name, Instant created, Instant modified) { this.id = id; this.name = name; this.created = created; this.modified = modified; }
NamedParameterBean(@ColumnName("xyz") int i) { this.i = i; } }
@ColumnName("id") public int getI() { return i; }