@Test public void testSetProperty() { { House house = new House(); PropertySetter setter = new PropertySetter(new BeanDescriptionCache(context), house); setter.setProperty("count", "10"); setter.setProperty("temperature", "33.1"); setter.setProperty("name", "jack"); setter.setProperty("open", "true"); assertEquals(10, house.getCount()); assertEquals(33.1d, (double) house.getTemperature(), 0.01); assertEquals("jack", house.getName()); assertTrue(house.isOpen()); } { House house = new House(); PropertySetter setter = new PropertySetter(new BeanDescriptionCache(context), house); setter.setProperty("Count", "10"); setter.setProperty("Name", "jack"); setter.setProperty("Open", "true"); assertEquals(10, house.getCount()); assertEquals("jack", house.getName()); assertTrue(house.isOpen()); } }
public void setProperty(String name, String value) { if (value == null) { return; } Method setter = findSetterMethod(name); if (setter == null) { addWarn("No setter for property [" + name + "] in " + objClass.getName() + "."); } else { try { setProperty(setter, name, value); } catch (PropertySetterException ex) { addWarn("Failed to set property [" + name + "] to value \"" + value + "\". ", ex); } } }
PropertySetter extends ContextAwareBase { public void setProperty(String name, String value) { if (value == null) { return; } Method setter = findSetterMethod(name); if (setter == null) { addWarn("No setter for property [" + name + "] in " + objClass.getName() + "."); } else { try { setProperty(setter, name, value); } catch (PropertySetterException ex) { addWarn("Failed to set property [" + name + "] to value \"" + value + "\". ", ex); } } } }
PropertySetter extends ContextAwareBase { public void setProperty(String name, String value) { if (value == null) { return; } Method setter = findSetterMethod(name); if (setter == null) { addWarn("No setter for property [" + name + "] in " + objClass.getName() + "."); } else { try { setProperty(setter, name, value); } catch (PropertySetterException ex) { addWarn("Failed to set property [" + name + "] to value \"" + value + "\". ", ex); } } } PropertySetter(BeanDescriptionCache beanDescriptionCache, Object obj); }
PropertySetter extends ContextAwareBase { public void setProperty(String name, String value) { if (value == null) { return; } Method setter = findSetterMethod(name); if (setter == null) { addWarn("No setter for property [" + name + "] in " + objClass.getName() + "."); } else { try { setProperty(setter, name, value); } catch (PropertySetterException ex) { addWarn("Failed to set property [" + name + "] to value \"" + value + "\". ", ex); } } } PropertySetter(BeanDescriptionCache beanDescriptionCache, Object obj); void setProperty(String name, String value); AggregationType computeAggregationType(String name); Class<?> getObjClass(); void addComplexProperty(String name, Object complexProperty); void addBasicProperty(String name, String strValue); void setComplexProperty(String name, Object complexProperty); Object getObj(); Class<?> getClassNameViaImplicitRules(String name, AggregationType aggregationType, DefaultNestedComponentRegistry registry); }
PropertySetter extends ContextAwareBase { public void setProperty(String name, String value) { if (value == null) { return; } Method setter = findSetterMethod(name); if (setter == null) { addWarn("No setter for property [" + name + "] in " + objClass.getName() + "."); } else { try { setProperty(setter, name, value); } catch (PropertySetterException ex) { addWarn("Failed to set property [" + name + "] to value \"" + value + "\". ", ex); } } } PropertySetter(BeanDescriptionCache beanDescriptionCache, Object obj); void setProperty(String name, String value); AggregationType computeAggregationType(String name); Class<?> getObjClass(); void addComplexProperty(String name, Object complexProperty); void addBasicProperty(String name, String strValue); void setComplexProperty(String name, Object complexProperty); Object getObj(); Class<?> getClassNameViaImplicitRules(String name, AggregationType aggregationType, DefaultNestedComponentRegistry registry);  }