@Override public final String convert(final T object) { final StringBuilder string = new StringBuilder(); for (int i = 0; i < fields.length; i++) { if (i > 0) { string.append(delimiter); } final String value = fields[i].get(object); if (value != null) { if (value.contains(delimiter)) { throw new DynamoDBMappingException(String.format( "%s[%s] field value \"%s\" must not contain delimiter %s", targetType, fields[i].bean.properties().attributeName(), value, delimiter )); } string.append(value); } } return string.length() < fields.length ? null : string.toString(); }
/** * @deprecated replaced by {@link DynamoDBMapperFieldModel#name} */ @Deprecated public String getDynamoDBAttributeName() { return properties.attributeName(); }
@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 final String convert(final T object) { final StringBuilder string = new StringBuilder(); for (int i = 0; i < fields.length; i++) { if (i > 0) { string.append(delimiter); } final String value = fields[i].get(object); if (value != null) { if (value.contains(delimiter)) { throw new DynamoDBMappingException(String.format( "%s[%s] field value \"%s\" must not contain delimiter %s", targetType, fields[i].bean.properties().attributeName(), value, delimiter )); } string.append(value); } } return string.length() < fields.length ? null : string.toString(); }
@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; }
final String getAttributeName() { return bean.properties().attributeName(); } }
private TableBuilder(Class<T> clazz, Beans<T> beans, RuleFactory<Object> rules) { super(clazz, beans.properties()); for (final Bean<T,Object> bean : beans.map().values()) { try { with(new FieldBuilder<T,Object>(clazz, bean, rules.getRule(bean.type())).build()); } catch (final RuntimeException e) { throw new DynamoDBMappingException(String.format( "%s[%s] could not be mapped for type %s", clazz.getSimpleName(), bean.properties().attributeName(), bean.type() ), e); } } }
/** * Gets the attribute name. * @return The attribute name. */ public final String name() { return properties.attributeName(); }
/** * @deprecated replaced by {@link DynamoDBMapperFieldModel#name} */ @Deprecated public String getDynamoDBAttributeName() { return properties.attributeName(); }
private void putOrFlatten(FieldMap<V> annotations, Reflect<T,V> reflect, Method getter) { if (annotations.flattened()) { flatten((Class<T>)annotations.targetType(), annotations.attributes(), (Reflect<T,T>)reflect); } else { final Bean<T,V> bean = new Bean<T,V>(annotations, reflect, getter); if (put(bean.properties().attributeName(), bean) != null) { throw new DynamoDBMappingException("duplicate attribute name " + bean.properties().attributeName()); } } }
public Immutable(final Properties<V> properties) { this.attributeName = properties.attributeName(); this.keyType = properties.keyType(); this.versioned = properties.versioned(); this.globalSecondaryIndexNames = properties.globalSecondaryIndexNames(); this.localSecondaryIndexNames = properties.localSecondaryIndexNames(); this.autoGenerator = properties.autoGenerator(); }
@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; }
final String getAttributeName() { return bean.properties().attributeName(); } }
private TableBuilder(Class<T> clazz, Beans<T> beans, RuleFactory<Object> rules) { super(clazz, beans.properties()); for (final Bean<T,Object> bean : beans.map().values()) { try { with(new FieldBuilder<T,Object>(clazz, bean, rules.getRule(bean.type())).build()); } catch (final RuntimeException e) { throw new DynamoDBMappingException(String.format( "%s[%s] could not be mapped for type %s", clazz.getSimpleName(), bean.properties().attributeName(), bean.type() ), e); } } }
private void putOrFlatten(FieldMap<V> annotations, Reflect<T,V> reflect, Method getter) { if (annotations.flattened()) { flatten((Class<T>)annotations.targetType(), annotations.attributes(), (Reflect<T,T>)reflect); } else { final Bean<T,V> bean = new Bean<T,V>(annotations, reflect, getter); if (put(bean.properties().attributeName(), bean) != null) { throw new DynamoDBMappingException("duplicate attribute name " + bean.properties().attributeName()); } } }
public Immutable(final Properties<V> properties) { this.attributeName = properties.attributeName(); this.keyType = properties.keyType(); this.versioned = properties.versioned(); this.globalSecondaryIndexNames = properties.globalSecondaryIndexNames(); this.localSecondaryIndexNames = properties.localSecondaryIndexNames(); this.autoGenerator = properties.autoGenerator(); }
/** * Gets the attribute name. * @return The attribute name. */ public final String name() { return properties.attributeName(); }