junit
diff --git a/aws-android-sdk-ddb-mapper/src/main/java/com/amazonaws/mobileconnectors/dynamodbv2/dynamodbmapper/DynamoDBMapper.java b/aws-android-sdk-ddb-mapper/src/main/java/com/amazonaws/mobileconnectors/dynamodbv2/dynamodbmapper/DynamoDBMapper.java
index 28095fa45f..354631eec4 100644
--- a/aws-android-sdk-ddb-mapper/src/main/java/com/amazonaws/mobileconnectors/dynamodbv2/dynamodbmapper/DynamoDBMapper.java
+++ b/aws-android-sdk-ddb-mapper/src/main/java/com/amazonaws/mobileconnectors/dynamodbv2/dynamodbmapper/DynamoDBMapper.java
@@ -91,45 +91,45 @@
*
* @DynamoDBTable(tableName = "TestTable")
* public class TestClass {
- *
+ *
* private Long key;
* private double rangeKey;
* private Long version;
- *
+ *
* private Set<Integer> integerSetAttribute;
- *
+ *
* @DynamoDBHashKey
* public Long getKey() {
* return key;
* }
- *
+ *
* public void setKey(Long key) {
* this.key = key;
* }
- *
+ *
* @DynamoDBRangeKey
* public double getRangeKey() {
* return rangeKey;
* }
- *
+ *
* public void setRangeKey(double rangeKey) {
* this.rangeKey = rangeKey;
* }
- *
+ *
* @DynamoDBAttribute(attributeName = "integerSetAttribute")
* public Set<Integer> getIntegerAttribute() {
* return integerSetAttribute;
* }
- *
+ *
* public void setIntegerAttribute(Set<Integer> integerAttribute) {
* this.integerSetAttribute = integerAttribute;
* }
- *
+ *
* @DynamoDBVersionAttribute
* public Long getVersion() {
* return version;
* }
- *
+ *
* public void setVersion(Long version) {
* this.version = version;
* }
@@ -317,7 +317,7 @@ public DynamoDBMapper(
if (s3CredentialsProvider == null) {
this.s3cc = null;
} else {
- this.s3cc = new S3ClientCache(s3CredentialsProvider.getCredentials());
+ this.s3cc = new S3ClientCache(s3CredentialsProvider);
}
}
@@ -374,29 +374,30 @@ public T load(T keyObject) {
*/
public T load(T keyObject, DynamoDBMapperConfig config) {
@SuppressWarnings("unchecked")
+ final
Class clazz = (Class) keyObject.getClass();
config = mergeConfig(config);
- ItemConverter converter = getConverter(config);
+ final ItemConverter converter = getConverter(config);
- String tableName = getTableName(clazz, keyObject, config);
+ final String tableName = getTableName(clazz, keyObject, config);
- GetItemRequest rq = new GetItemRequest()
+ final GetItemRequest rq = new GetItemRequest()
.withRequestMetricCollector(config.getRequestMetricCollector());
- Map key = getKey(converter, keyObject, clazz);
+ final Map key = getKey(converter, keyObject, clazz);
rq.setKey(key);
rq.setTableName(tableName);
rq.setConsistentRead(config.getConsistentReads() == ConsistentReads.CONSISTENT);
- GetItemResult item = db.getItem(applyUserAgent(rq));
- Map itemAttributes = item.getItem();
+ final GetItemResult item = db.getItem(applyUserAgent(rq));
+ final Map itemAttributes = item.getItem();
if (itemAttributes == null) {
return null;
}
- T object = privateMarshallIntoObject(
+ final T object = privateMarshallIntoObject(
converter,
toParameters(itemAttributes, clazz, tableName, config));
@@ -422,12 +423,12 @@ private Map getKey(
T keyObject,
Class clazz) {
- Map key = new HashMap();
- for (Method keyGetter : reflector.getPrimaryKeyGetters(clazz)) {
- Object getterResult =
+ final Map key = new HashMap();
+ for (final Method keyGetter : reflector.getPrimaryKeyGetters(clazz)) {
+ final Object getterResult =
ReflectionUtils.safeInvoke(keyGetter, keyObject);
- AttributeValue keyAttributeValue =
+ final AttributeValue keyAttributeValue =
converter.convert(keyGetter, getterResult);
if (keyAttributeValue == null) {
@@ -462,7 +463,7 @@ private Map getKey(
public T load(Class clazz, Object hashKey, Object rangeKey,
DynamoDBMapperConfig config) {
config = mergeConfig(config);
- T keyObject = createKeyObject(clazz, hashKey, rangeKey);
+ final T keyObject = createKeyObject(clazz, hashKey, rangeKey);
return load(keyObject, config);
}
@@ -474,12 +475,12 @@ T createKeyObject(Class clazz, Object hashKey, Object rangeKey) {
T keyObject = null;
try {
keyObject = clazz.newInstance();
- } catch (Exception e) {
+ } catch (final Exception e) {
throw new DynamoDBMappingException("Failed to instantiate class", e);
}
boolean seenHashKey = false;
boolean seenRangeKey = false;
- for (Method getter : reflector.getPrimaryKeyGetters(clazz)) {
+ for (final Method getter : reflector.getPrimaryKeyGetters(clazz)) {
if (ReflectionUtils.getterOrFieldHasAnnotation(getter, DynamoDBHashKey.class)) {
if (seenHashKey) {
throw new DynamoDBMappingException(
@@ -529,18 +530,18 @@ private Map getHashKeyEqualsConditions(
ItemConverter converter,
Object obj) {
- Map conditions = new HashMap();
+ final Map conditions = new HashMap();
if (obj == null) {
return conditions;
}
- for (Method getter : reflector.getRelevantGetters(obj.getClass())) {
+ for (final Method getter : reflector.getRelevantGetters(obj.getClass())) {
if (ReflectionUtils.getterOrFieldHasAnnotation(
getter, DynamoDBHashKey.class)
|| ReflectionUtils.getterOrFieldHasAnnotation(
getter, DynamoDBIndexHashKey.class)) {
- Object getterReturnResult =
+ final Object getterReturnResult =
ReflectionUtils.safeInvoke(getter, obj);
if (getterReturnResult != null) {
@@ -581,7 +582,7 @@ static String internalGetTableName(final Class> clazz,
final DynamoDBMapperConfig config) {
// Resolve by object, if possible and desired
- DynamoDBMapperConfig.ObjectTableNameResolver objectResolver = config
+ final DynamoDBMapperConfig.ObjectTableNameResolver objectResolver = config
.getObjectTableNameResolver();
if (object != null && objectResolver != null) {
return objectResolver.getTableName(object, config);
@@ -614,9 +615,9 @@ public T marshallIntoObject(
Class clazz,
Map itemAttributes) {
- ItemConverter converter = getConverter(config);
+ final ItemConverter converter = getConverter(config);
- String tableName = getTableName(clazz, config);
+ final String tableName = getTableName(clazz, config);
return privateMarshallIntoObject(
converter,
@@ -630,8 +631,8 @@ private T privateMarshallIntoObject(
ItemConverter converter,
AttributeTransformer.Parameters parameters) {
- Class clazz = parameters.getModelClass();
- Map values = untransformAttributes(parameters);
+ final Class clazz = parameters.getModelClass();
+ final Map values = untransformAttributes(parameters);
return converter.unconvert(clazz, values);
}
@@ -646,8 +647,8 @@ private T privateMarshallIntoObject(
*/
public List marshallIntoObjects(Class clazz,
List