private final void set(final T object, final String string) { if (!string.isEmpty()) { final V value = converter.unconvert(string); if (value != null) { bean.reflect().set(object, value); } } } }
@Override public Map<String, AttributeValue> convert(Object object) { if (object == null) { return null; } Class<Object> clazz = (Class<Object>)object.getClass(); Map<String, AttributeValue> result = new HashMap<String, AttributeValue>(); for (final Bean<Object,Object> bean : StandardBeanProperties.of(clazz).map().values()) { Object getterResult = bean.reflect().get(object); if (getterResult != null) { AttributeValue value = convert(bean.type().getter(), getterResult); if (value != null) { result.put(bean.properties().attributeName(), value); } } } return result; }
@Override public <T> T unconvert( Class<T> clazz, Map<String, AttributeValue> value) { T result = createObject(clazz); if (value == null || value.isEmpty()) { return result; } for (final Bean<T,Object> bean : StandardBeanProperties.of(clazz).map().values()) { AttributeValue av = value.get(bean.properties().attributeName()); if (av != null) { ArgumentUnmarshaller unmarshaller = getUnmarshaller(bean.type().getter(), bean.type().setter()); Object unmarshalled = unmarshall(unmarshaller, bean.type().setter(), av); bean.reflect().set(result, unmarshalled); } } return result; }
@Override public Map<String, AttributeValue> convert(Object object) { if (object == null) { return null; } Class<Object> clazz = (Class<Object>)object.getClass(); Map<String, AttributeValue> result = new HashMap<String, AttributeValue>(); for (final Bean<Object,Object> bean : StandardBeanProperties.of(clazz).map().values()) { Object getterResult = bean.reflect().get(object); if (getterResult != null) { AttributeValue value = convert(bean.type().getter(), getterResult); if (value != null) { result.put(bean.properties().attributeName(), value); } } } return result; }
@Override public <T> T unconvert( Class<T> clazz, Map<String, AttributeValue> value) { T result = createObject(clazz); if (value == null || value.isEmpty()) { return result; } for (final Bean<T,Object> bean : StandardBeanProperties.of(clazz).map().values()) { AttributeValue av = value.get(bean.properties().attributeName()); if (av != null) { ArgumentUnmarshaller unmarshaller = getUnmarshaller(bean.type().getter(), bean.type().setter()); Object unmarshalled = unmarshall(unmarshaller, bean.type().setter(), av); bean.reflect().set(result, unmarshalled); } } return result; }
private final void set(final T object, final String string) { if (!string.isEmpty()) { final V value = converter.unconvert(string); if (value != null) { bean.reflect().set(object, value); } } } }
private final String get(final T object) { final V value = bean.reflect().get(object); if (value == null) { return null; } return converter.convert(value); } private final void set(final T object, final String string) {
private FieldBuilder(Class<T> clazz, Bean<T,V> bean, Rule<V> rule) { super(clazz, bean.properties()); if (bean.type().attributeType() != null) { with(bean.type().attributeType()); } else { with(rule.getAttributeType()); } with(rule.newConverter(bean.type())); with(bean.reflect()); } }
private FieldBuilder(Class<T> clazz, Bean<T,V> bean, Rule<V> rule) { super(clazz, bean.properties()); if (bean.type().attributeType() != null) { with(bean.type().attributeType()); } else { with(rule.getAttributeType()); } with(rule.newConverter(bean.type())); with(bean.reflect()); } }
private final String get(final T object) { final V value = bean.reflect().get(object); if (value == null) { return null; } return converter.convert(value); } private final void set(final T object, final String string) {