Skip to content

Commit

Permalink
Fix Javadoc and cast warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
derjust committed Mar 7, 2018
1 parent 712448e commit 0056f92
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 39 deletions.
5 changes: 5 additions & 0 deletions src/changes/changes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
<author email="[email protected]">derjust</author>
</properties>
<body>
<release version="5.0.3" date="" description="Maintenance release">
<action dev="derjust" type="fix" date="2018-03-05">
Fix Javadoc and cast warnings
</action>
</release>
<release version="5.0.2" date="2018-03-05" description="Maintenance release">
<action dev="vitolimandibhrata" issue="40" type="add" date="2017-01-07">
Added support for Auditing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ protected String[] getMappingBasePackages() {
* Creates a {@link DynamoDBMappingContext} equipped with entity classes scanned from the mapping base package.
*
* @see #getMappingBasePackages()
* @return
* @throws ClassNotFoundException
* @return A newly created {@link DynamoDBMappingContext}
* @throws ClassNotFoundException if the class with {@link DynamoDBTable} annotation can't be loaded
*/
@Bean
public DynamoDBMappingContext dynamoDBMappingContext() throws ClassNotFoundException {
Expand All @@ -83,8 +83,8 @@ public DynamoDBMappingContext dynamoDBMappingContext() throws ClassNotFoundExcep
* Scans the mapping base package for classes annotated with {@link DynamoDBTable}.
*
* @see #getMappingBasePackages()
* @return
* @throws ClassNotFoundException
* @return All classes with {@link DynamoDBTable} annotation
* @throws ClassNotFoundException if the class with {@link DynamoDBTable} annotation can't be loaded
*/
protected Set<Class<?>> getInitialEntitySet() throws ClassNotFoundException {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,31 +37,23 @@
public @interface EnableDynamoDBAuditing {

/**
* Configures the {@link org.springframework.data.domain.AuditorAware} bean to be used to lookup the current principal.
*
* @return
* @return Configures the {@link org.springframework.data.domain.AuditorAware} bean to be used to lookup the current principal.
*/
String auditorAwareRef() default "";

/**
* Configures whether the creation and modification dates are set. Defaults to {@literal true}.
*
* @return
* @return Configures whether the creation and modification dates are set. Defaults to {@literal true}.
*/
boolean setDates() default true;

/**
* Configures whether the entity shall be marked as modified on creation. Defaults to {@literal true}.
*
* @return
* @return Configures whether the entity shall be marked as modified on creation. Defaults to {@literal true}.
*/
boolean modifyOnCreate() default true;

/**
* Configures a {@link org.springframework.data.auditing.DateTimeProvider} bean name that allows customizing the {@link org.joda.time.DateTime} to be
* @return Configures a {@link org.springframework.data.auditing.DateTimeProvider} bean name that allows customizing the {@link org.joda.time.DateTime} to be
* used for setting creation and modification dates.
*
* @return
*/
String dateTimeProviderRef() default "";
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,27 @@ public class DynamoDBTemplate implements DynamoDBOperations, ApplicationContextA
private final DynamoDBMapperConfig dynamoDBMapperConfig;
private ApplicationEventPublisher eventPublisher;

/** Convenient constructor to use the default {@link DynamoDBMapper#DynamoDBMapper(AmazonDynamoDB)} */
/** Convenient constructor to use the default {@link DynamoDBMapper#DynamoDBMapper(AmazonDynamoDB)}
* @param amazonDynamoDB The AWS SDK instance to talk to DynamoDB
* @param dynamoDBMapperConfig The config to use
* */
public DynamoDBTemplate(AmazonDynamoDB amazonDynamoDB, DynamoDBMapperConfig dynamoDBMapperConfig)
{
this(amazonDynamoDB, dynamoDBMapperConfig, null);
}

/** Convenient constructor to use the {@link DynamoDBMapperConfig#DEFAULT} */
/** Convenient constructor to use the {@link DynamoDBMapperConfig#DEFAULT}
* @param amazonDynamoDB The AWS SDK instance to talk to DynamoDB
* @param dynamoDBMapper The Mapper to use
* */
public DynamoDBTemplate(AmazonDynamoDB amazonDynamoDB, DynamoDBMapper dynamoDBMapper)
{
this(amazonDynamoDB, null, dynamoDBMapper);
}

/** Convenient construcotr to thse the {@link DynamoDBMapperConfig#DEFAULT} and default {@link DynamoDBMapper#DynamoDBMapper(AmazonDynamoDB)} */
/** Convenient construcotr to thse the {@link DynamoDBMapperConfig#DEFAULT} and default {@link DynamoDBMapper#DynamoDBMapper(AmazonDynamoDB)}
* @param amazonDynamoDB The AWS SDK instance to talk to DynamoDB
* */
public DynamoDBTemplate(AmazonDynamoDB amazonDynamoDB)
{
this(amazonDynamoDB, null, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,11 @@ protected QueryLookupStrategy getQueryLookupStrategy(Key key) {
/**
* Callback to create a {@link DynamoDBCrudRepository} instance with the given {@link RepositoryMetadata}
*
* @param <T>
* @param <ID>
* @param metadata
* @param <T> Type of the Entity
* @param <ID> Type of the Hash (Primary) Key
* @param metadata Metadata of the entity
* @see #getTargetRepository(RepositoryInformation)
* @return
* @return the created {@link DynamoDBCrudRepository} instance
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
protected <T, ID extends Serializable> DynamoDBCrudRepository<?, ?> getDynamoDBRepository(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@ public class SortHandler {
private SortHandler() {
}

public static void ensureNoSort(Pageable pageable) {
/**
* @param pageable The {@link Pageable} to check that no sort is specified
*/
public static void ensureNoSort(Pageable pageable) {
Sort sort = pageable.getSort();
ensureNoSort(sort);
}

/**
* @throws UnsupportedOperationException if a {@code sort} is initialized (non-null &amp;&amp; not {@link Sort#unsorted()}
* @param sort The {@link Sort} to check that no sort is specified
* @throws UnsupportedOperationException if a {@code sort} is initialized (non-null)
*/
public static void ensureNoSort(Sort sort) throws UnsupportedOperationException {
if (sort != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ public class DynamoDBTemplateTest {
private DynamoDBMapperConfig dynamoDBMapperConfig;
@Mock
private ApplicationContext applicationContext;

@Mock
private DynamoDBQueryExpression<User> countUserQuery;

private DynamoDBTemplate dynamoDBTemplate;

@Before
Expand Down Expand Up @@ -124,7 +126,7 @@ public void testBatchSave_CallsCorrectDynamoDBMapperMethod()

@Test
public void testCountQuery() {
DynamoDBQueryExpression<User> query = mock(DynamoDBQueryExpression.class);
DynamoDBQueryExpression<User> query = countUserQuery;
int actual = dynamoDBTemplate.count(User.class, query);

verify(dynamoDBMapper).count(User.class, query);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class QueryExpressionCountQueryTest {

@Before
public void setUp() {
underTest = new QueryExpressionCountQuery(dynamoDBOperations, User.class, queryExpression);
underTest = new QueryExpressionCountQuery<>(dynamoDBOperations, User.class, queryExpression);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void setUp() {

@Test
public void testNullOperationsOk() {
DynamoDBRepositoryBean underTest = new DynamoDBRepositoryBean(beanManager, amazonDynamoDBBean,
DynamoDBRepositoryBean<SampleRepository> underTest = new DynamoDBRepositoryBean(beanManager, amazonDynamoDBBean,
dynamoDBMapperConfigBean, null, qualifiers, repositoryType);

assertNotNull(underTest);
Expand All @@ -80,13 +80,13 @@ public void testNullOperationsOk() {
public void testNullOperationFail() {
expectedException.expectMessage("amazonDynamoDBBean must not be null!");

DynamoDBRepositoryBean underTest = new DynamoDBRepositoryBean(beanManager, null,
DynamoDBRepositoryBean<SampleRepository> underTest = new DynamoDBRepositoryBean(beanManager, null,
dynamoDBMapperConfigBean, null, qualifiers, repositoryType);
}

@Test
public void testSetOperationOk1() {
DynamoDBRepositoryBean underTest = new DynamoDBRepositoryBean(beanManager, null,
DynamoDBRepositoryBean<SampleRepository> underTest = new DynamoDBRepositoryBean(beanManager, null,
null, dynamoDBOperationsBean, qualifiers, repositoryType);

assertNotNull(underTest);
Expand All @@ -96,15 +96,15 @@ public void testSetOperationOk1() {
public void testSetOperationFail1() {
expectedException.expectMessage("Cannot specify both dynamoDBMapperConfigBean bean and dynamoDBOperationsBean in repository configuration");

DynamoDBRepositoryBean underTest = new DynamoDBRepositoryBean(beanManager, null,
DynamoDBRepositoryBean<SampleRepository> underTest = new DynamoDBRepositoryBean(beanManager, null,
dynamoDBMapperConfigBean, dynamoDBOperationsBean, qualifiers, repositoryType);
}

@Test
public void testSetOperationFail2() {
expectedException.expectMessage("Cannot specify both amazonDynamoDB bean and dynamoDBOperationsBean in repository configuration");

DynamoDBRepositoryBean underTest = new DynamoDBRepositoryBean(beanManager, amazonDynamoDBBean,
DynamoDBRepositoryBean<SampleRepository> underTest = new DynamoDBRepositoryBean(beanManager, amazonDynamoDBBean,
null, dynamoDBOperationsBean, qualifiers, repositoryType);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,25 +59,25 @@ public static <T> CreateTableResult createTable(AmazonDynamoDB ddb, Class<T> dom
hashKeyAttribute = hashKeyProperty;
}

Optional<String> rangeKey = Optional.empty();
String rangeKey = null;
if (entityInfo instanceof DynamoDBIdIsHashAndRangeKeyEntityInformation) {
rangeKey = Optional.of(((DynamoDBIdIsHashAndRangeKeyEntityInformation)entityInfo).getRangeKeyPropertyName());
rangeKey = ((DynamoDBIdIsHashAndRangeKeyEntityInformation)entityInfo).getRangeKeyPropertyName();
}

return createTable(ddb, tableName, hashKeyAttribute, rangeKey);
}

private static CreateTableResult createTable(AmazonDynamoDB ddb, String tableName, String hashKeyName, Optional<String> rangeKeyName) {
private static CreateTableResult createTable(AmazonDynamoDB ddb, String tableName, String hashKeyName, String rangeKeyName) {
List<AttributeDefinition> attributeDefinitions = new ArrayList<>();
attributeDefinitions.add(new AttributeDefinition(hashKeyName, ScalarAttributeType.S));

List<KeySchemaElement> ks = new ArrayList<>();
ks.add(new KeySchemaElement(hashKeyName, KeyType.HASH));

if (rangeKeyName.isPresent()) {
attributeDefinitions.add(new AttributeDefinition(rangeKeyName.get(), ScalarAttributeType.S));
if (rangeKeyName != null) {
attributeDefinitions.add(new AttributeDefinition(rangeKeyName, ScalarAttributeType.S));

ks.add(new KeySchemaElement(rangeKeyName.get(), KeyType.RANGE));
ks.add(new KeySchemaElement(rangeKeyName, KeyType.RANGE));
}

ProvisionedThroughput provisionedthroughput = new ProvisionedThroughput(10L, 10L);
Expand Down

0 comments on commit 0056f92

Please sign in to comment.