TypeReflector { public void set(T bean, String name, Object value) { validate(bean, name); BiConsumer<T, Object> setter = setters.get(name); if (setter == null) { throw new IllegalArgumentException("No setter specified for property '" + name + "' on bean class '" + bean.getClass() + "'"); } setter.accept(bean, value); } TypeReflector(Class<T> clazz);  TypeReflector(JavaType javaType); @Override boolean equals(Object o); @Override int hashCode(); JavaType getJavaType(); @SuppressWarnings("unchecked") Class<T> getTypeClass(); T instantiate(); List<PropertyDescriptor> getPropertyDescriptors(); Map<String, PropertyDescriptor> getPropertyDescriptorIndex(); Object get(T bean, String name); void set(T bean, String name, Object value); A getAnnotation(Class<A> annotationClass); A getAnnotation(PropertyDescriptor propertyDescriptor, Class<A> annotationClass); A getAnnotation(String propertyName, Class<A> annotationClass); Class reifyPropertyType(String property); Class reifyPropertyType(PropertyDescriptor property);  }
@Test public void testSet() { TypeReflector<TestClass> underTest = new TypeReflector<>(TestClass.class); assertEquals(1, underTest.getPropertyDescriptors().size()); TestClass instance = new TestClass(); assertNull(instance.getValue()); underTest.set(instance, "value", "test"); assertEquals("test", instance.getValue()); }
@Test(expected = IllegalArgumentException.class) public void testSetUnknownProperty() { TypeReflector<TestClass> underTest = new TypeReflector<>(TestClass.class); TestClass instance = new TestClass(); underTest.set(instance, "unknown", "test"); }
@Test(expected = IllegalArgumentException.class) public void testSetIllegalCast() { TypeReflector<TestClass> underTest = new TypeReflector<>(TestClass.class); TestClass instance = new TestClass(); underTest.set(instance, "value", 1); }
@Test(expected = IllegalArgumentException.class) public void testSetPrivate() { TypeReflector<TestPrivateSetter> underTest = new TypeReflector<>(TestPrivateSetter.class); TestPrivateSetter instance = new TestPrivateSetter(); underTest.set(instance, "value", 1); }
@Test(expected = IllegalArgumentException.class) public void testGetPrivate() { TypeReflector<TestPrivateGetter> underTest = new TypeReflector<>(TestPrivateGetter.class); TestPrivateGetter instance = new TestPrivateGetter(); underTest.set(instance, "value", 1); }
@Test(expected = IllegalArgumentException.class) public void testSetNullBean() { TypeReflector<TestClass> underTest = new TypeReflector<>(TestClass.class); underTest.set(null, "value", "test"); }
@Test(expected = IllegalArgumentException.class) public void testSetNullName() { TypeReflector<TestClass> underTest = new TypeReflector<>(TestClass.class); underTest.set(new TestClass(), null, "test"); }