@@ -69,53 +69,7 @@ public String getDynamoDBTableName() {
6969 * must not be {@literal null}.
7070 */
7171 public DynamoDBEntityMetadataSupport (final Class <T > domainType ) {
72-
73- Assert .notNull (domainType , "Domain type must not be null!" );
74- this .domainType = domainType ;
75-
76- DynamoDBTable table = this .domainType .getAnnotation (DynamoDBTable .class );
77- Assert .notNull (table , "Domain type must by annotated with DynamoDBTable!" );
78-
79- this .dynamoDBTableName = table .tableName ();
80- this .hashKeyPropertyName = null ;
81- this .globalSecondaryIndexNames = new HashMap <>();
82- this .globalIndexHashKeyPropertyNames = new ArrayList <>();
83- this .globalIndexRangeKeyPropertyNames = new ArrayList <>();
84- ReflectionUtils .doWithMethods (domainType , method -> {
85- if (method .getAnnotation (DynamoDBHashKey .class ) != null ) {
86- hashKeyPropertyName = getPropertyNameForAccessorMethod (method );
87- }
88- if (method .getAnnotation (DynamoDBRangeKey .class ) != null ) {
89- hasRangeKey = true ;
90- }
91- DynamoDBIndexRangeKey dynamoDBRangeKeyAnnotation = method .getAnnotation (DynamoDBIndexRangeKey .class );
92- DynamoDBIndexHashKey dynamoDBHashKeyAnnotation = method .getAnnotation (DynamoDBIndexHashKey .class );
93-
94- if (dynamoDBRangeKeyAnnotation != null ) {
95- addGlobalSecondaryIndexNames (method , dynamoDBRangeKeyAnnotation );
96- }
97- if (dynamoDBHashKeyAnnotation != null ) {
98- addGlobalSecondaryIndexNames (method , dynamoDBHashKeyAnnotation );
99- }
100- });
101- ReflectionUtils .doWithFields (domainType , field -> {
102- if (field .getAnnotation (DynamoDBHashKey .class ) != null ) {
103- hashKeyPropertyName = getPropertyNameForField (field );
104- }
105- if (field .getAnnotation (DynamoDBRangeKey .class ) != null ) {
106- hasRangeKey = true ;
107- }
108- DynamoDBIndexRangeKey dynamoDBRangeKeyAnnotation = field .getAnnotation (DynamoDBIndexRangeKey .class );
109- DynamoDBIndexHashKey dynamoDBHashKeyAnnotation = field .getAnnotation (DynamoDBIndexHashKey .class );
110-
111- if (dynamoDBRangeKeyAnnotation != null ) {
112- addGlobalSecondaryIndexNames (field , dynamoDBRangeKeyAnnotation );
113- }
114- if (dynamoDBHashKeyAnnotation != null ) {
115- addGlobalSecondaryIndexNames (field , dynamoDBHashKeyAnnotation );
116- }
117- });
118- Assert .notNull (hashKeyPropertyName , "Unable to find hash key field or getter method on " + domainType + "!" );
72+ this (domainType , null );
11973 }
12074
12175 /**
@@ -125,7 +79,7 @@ public DynamoDBEntityMetadataSupport(final Class<T> domainType) {
12579 * @param domainType
12680 * must not be {@literal null}.
12781 * @param dynamoDBOperations
128- * must not be {@literal null}.
82+ * dynamoDBOperations as populated from Spring Data DynamoDB Configuration
12983 */
13084 public DynamoDBEntityMetadataSupport (final Class <T > domainType , DynamoDBOperations dynamoDBOperations ) {
13185
@@ -135,7 +89,11 @@ public DynamoDBEntityMetadataSupport(final Class<T> domainType, DynamoDBOperatio
13589 DynamoDBTable table = this .domainType .getAnnotation (DynamoDBTable .class );
13690 Assert .notNull (table , "Domain type must by annotated with DynamoDBTable!" );
13791
138- this .dynamoDBTableName = dynamoDBOperations .getOverriddenTableName (domainType , table .tableName ());
92+ if (dynamoDBOperations != null ) {
93+ this .dynamoDBTableName = dynamoDBOperations .getOverriddenTableName (domainType , table .tableName ());
94+ } else {
95+ this .dynamoDBTableName = table .tableName ();
96+ }
13997 this .hashKeyPropertyName = null ;
14098 this .globalSecondaryIndexNames = new HashMap <>();
14199 this .globalIndexHashKeyPropertyNames = new ArrayList <>();
0 commit comments