JavaBeanUtils { public static List<FieldValueGetter> getGetters( Class<?> clazz, Schema schema, FieldValueTypeSupplier fieldValueTypeSupplier, TypeConversionsFactory typeConversionsFactory) { return CACHED_GETTERS.computeIfAbsent( ClassWithSchema.create(clazz, schema), c -> { List<FieldValueTypeInformation> types = fieldValueTypeSupplier.get(clazz, schema); return types.stream() .map(t -> createGetter(t, typeConversionsFactory)) .collect(Collectors.toList()); }); }  static Schema schemaFromJavaBeanClass(
      Class<?> clazz, FieldValueTypeSupplier fieldValueTypeSupplier); static void validateJavaBean(
      List<FieldValueTypeInformation> getters, List<FieldValueTypeInformation> setters); static List<FieldValueTypeInformation> getFieldTypes(
      Class<?> clazz, Schema schema, FieldValueTypeSupplier fieldValueTypeSupplier); static List<FieldValueGetter> getGetters(
      Class<?> clazz,
      Schema schema,
      FieldValueTypeSupplier fieldValueTypeSupplier,
      TypeConversionsFactory typeConversionsFactory); static FieldValueGetter createGetter(
      FieldValueTypeInformation typeInformation, TypeConversionsFactory typeConversionsFactory); static List<FieldValueSetter> getSetters(
      Class<?> clazz,
      Schema schema,
      FieldValueTypeSupplier fieldValueTypeSupplier,
      TypeConversionsFactory typeConversionsFactory); static FieldValueSetter createSetter(
      FieldValueTypeInformation typeInformation, TypeConversionsFactory typeConversionsFactory); static SchemaUserTypeCreator getConstructorCreator(
      Class clazz,
      Constructor constructor,
      Schema schema,
      FieldValueTypeSupplier fieldValueTypeSupplier,
      TypeConversionsFactory typeConversionsFactory); static SchemaUserTypeCreator createConstructorCreator(
      Class<T> clazz,
      Constructor<T> constructor,
      Schema schema,
      List<FieldValueTypeInformation> types,
      TypeConversionsFactory typeConversionsFactory); static SchemaUserTypeCreator getStaticCreator(
      Class clazz,
      Method creator,
      Schema schema,
      FieldValueTypeSupplier fieldValueTypeSupplier,
      TypeConversionsFactory typeConversionsFactory); static SchemaUserTypeCreator createStaticCreator(
      Class<T> clazz,
      Method creator,
      Schema schema,
      List<FieldValueTypeInformation> types,
      TypeConversionsFactory typeConversionsFactory); static final Map<ClassWithSchema, SchemaUserTypeCreator> CACHED_CREATORS; }
@Test public void testGeneratedSimpleGetters() { SimpleBean simpleBean = new SimpleBean(); simpleBean.setStr("field1"); simpleBean.setaByte((byte) 41); simpleBean.setaShort((short) 42); simpleBean.setAnInt(43); simpleBean.setaLong(44); simpleBean.setaBoolean(true); simpleBean.setDateTime(DateTime.parse("1979-03-14")); simpleBean.setInstant(DateTime.parse("1979-03-15").toInstant()); simpleBean.setBytes("bytes1".getBytes(Charset.defaultCharset())); simpleBean.setByteBuffer(ByteBuffer.wrap("bytes2".getBytes(Charset.defaultCharset()))); simpleBean.setBigDecimal(new BigDecimal(42)); simpleBean.setStringBuilder(new StringBuilder("stringBuilder")); List<FieldValueGetter> getters = JavaBeanUtils.getGetters( SimpleBean.class, SIMPLE_BEAN_SCHEMA, new JavaBeanSchema.GetterTypeSupplier(), new DefaultTypeConversionsFactory()); assertEquals(12, getters.size()); assertEquals("str", getters.get(0).name()); assertEquals("field1", getters.get(0).get(simpleBean)); assertEquals((byte) 41, getters.get(1).get(simpleBean)); assertEquals((short) 42, getters.get(2).get(simpleBean)); assertEquals((int) 43, getters.get(3).get(simpleBean)); assertEquals((long) 44, getters.get(4).get(simpleBean)); assertTrue((Boolean) getters.get(5).get(simpleBean)); assertEquals(DateTime.parse("1979-03-14").toInstant(), getters.get(6).get(simpleBean)); assertEquals(DateTime.parse("1979-03-15").toInstant(), getters.get(7).get(simpleBean)); assertArrayEquals( "Unexpected bytes", "bytes1".getBytes(Charset.defaultCharset()), (byte[]) getters.get(8).get(simpleBean)); assertArrayEquals( "Unexpected bytes", "bytes2".getBytes(Charset.defaultCharset()), (byte[]) getters.get(9).get(simpleBean)); assertEquals(new BigDecimal(42), getters.get(10).get(simpleBean)); assertEquals("stringBuilder", getters.get(11).get(simpleBean).toString()); }
@Test public void testGeneratedSimpleBoxedGetters() { BeanWithBoxedFields bean = new BeanWithBoxedFields(); bean.setaByte((byte) 41); bean.setaShort((short) 42); bean.setAnInt(43); bean.setaLong(44L); bean.setaBoolean(true); List<FieldValueGetter> getters = JavaBeanUtils.getGetters( BeanWithBoxedFields.class, BEAN_WITH_BOXED_FIELDS_SCHEMA, new JavaBeanSchema.GetterTypeSupplier(), new DefaultTypeConversionsFactory()); assertEquals((byte) 41, getters.get(0).get(bean)); assertEquals((short) 42, getters.get(1).get(bean)); assertEquals((int) 43, getters.get(2).get(bean)); assertEquals((long) 44, getters.get(3).get(bean)); assertTrue((Boolean) getters.get(4).get(bean)); }