public <S,T> Builder with(Class<S> sourceType, Class<T> targetType, DynamoDBTypeConverter<? extends S,? extends T> converter) { if (Vector.SET.is(sourceType) || Vector.LIST.is(sourceType) || Vector.MAP.is(sourceType)) { throw new DynamoDBMappingException("type [" + sourceType + "] is not supported" + "; type-converter factory only supports scalar conversions"); } overrides.put(sourceType, targetType, converter); return this; }
public StandardConversionSchema( String name, MarshallerSet marshallers, UnmarshallerSet unmarshallers) { this.name = name; this.marshallers = new CachingMarshallerSet( new AnnotationAwareMarshallerSet(marshallers)); this.unmarshallers = new CachingUnmarshallerSet( new AnnotationAwareUnmarshallerSet(unmarshallers)); }
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()); } } }
@Override public <T extends Object> T load(Class<T> clazz, Object hashKey, Object rangeKey, DynamoDBMapperConfig config) { config = mergeConfig(config); final DynamoDBMapperTableModel<T> model = getTableModel(clazz, config); T keyObject = model.createKey(hashKey, rangeKey); return load(keyObject, config); }
/** * Loads an object with the hash key given. * @param hashKey The hash key value. * @return The object. * @see com.amazonaws.services.dynamodbv2.datamodeling.DynamoDBMapper#load */ public T load(H hashKey) { return mapper.<T>load(model.targetType(), hashKey); }
/** * The one true implementation of marshallIntoObject. */ private <T> T privateMarshallIntoObject( AttributeTransformer.Parameters<T> parameters) { Class<T> clazz = parameters.getModelClass(); Map<String, AttributeValue> values = untransformAttributes(parameters); final DynamoDBMapperTableModel<T> model = getTableModel(clazz, parameters.getMapperConfig()); return model.unconvert(values); }
@Override public <T> PaginatedParallelScanList<T> parallelScan(Class<T> clazz, DynamoDBScanExpression scanExpression, int totalSegments, DynamoDBMapperConfig config) { config = mergeConfig(config); // Create hard copies of the original scan request with difference segment number. List<ScanRequest> parallelScanRequests = createParallelScanRequestsFromExpression(clazz, scanExpression, totalSegments, config); ParallelScanTask parallelScanTask = new ParallelScanTask(db, parallelScanRequests); return new PaginatedParallelScanList<T>(this, clazz, db, parallelScanTask, config.getPaginationLoadingStrategy(), config); }
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 ItemConverterRule(final ConvertibleType<V> type) { this.type = type; } @Override
private Field(final Class<T> type, final Bean<T,V> bean) { if (bean.type().typeConverter() == null) { this.converter = StandardTypeConverters.factory().getConverter(String.class, bean.type().targetType()); } else { this.converter = bean.type().<String>typeConverter(); } this.bean = bean; } private final String get(final T object) {
protected final String getTableName(Class<?> clazz, DynamoDBMapperConfig config) { if (config.getTableNameResolver() == null) { return DynamoDBMapperConfig.DefaultTableNameResolver.INSTANCE.getTableName(clazz, config); } return config.getTableNameResolver().getTableName(clazz, config); }
public Generator(Class<T> targetType, DynamoDBAutoGeneratedDefault annotation) { super(DynamoDBAutoGenerateStrategy.CREATE); this.converter = StandardTypeConverters.factory().getConverter(targetType, String.class); this.defaultValue = annotation.value(); }
public ConversionSchema build() { return new StandardConversionSchema(name, new AbstractMarshallerSet(marshallers, setMarshallers), new StandardUnmarshallerSet(unmarshallers, setUnmarshallers)); } }
@Override public Rule<V> getRule(ConvertibleType<V> type) { if (customSchema && type.typeConverter() == null) { return new ItemConverterRule<V>(type); } else { return typeConverters.getRule(type); } }
protected final String getTableName(Class<?> clazz, Object object, DynamoDBMapperConfig config) { if (config.getObjectTableNameResolver() != null && object != null) { return config.getObjectTableNameResolver().getTableName(object, config); } return getTableName(clazz, config); }
@Override public String getRangeKeyName() { return model.rangeKeyIfExists() == null ? null : model.rangeKey().name(); } }
public DynamoDBMapperTableModel<T> build() { final DynamoDBMapperTableModel<T> result = new DynamoDBMapperTableModel<T>(this); if (properties.tableName() != null) { result.hashKey(); //<- make sure the hash key is present } return result; } }
@Override public ItemConverter getConverter(Dependencies dependencies) { S3ClientCache s3cc = dependencies.get(S3ClientCache.class); return new StandardItemConverter( marshallers, unmarshallers, s3cc); }
/** * {@inheritDoc} */ @Override public final DynamoDBAutoGenerateStrategy getGenerateStrategy() { if (properties.autoGenerator() != null) { return properties.autoGenerator().getGenerateStrategy(); } return null; }