Skip to content

Commit

Permalink
Refactor the ExpirationConfiguration class.
Browse files Browse the repository at this point in the history
Apply Spring @nonnull and @nullable annotations appropriately.

Cleanup compiler warnings.

Format source code.

Remove use of static import on ArrayUtils.nullSafeArray(..) method.
  • Loading branch information
jxblum committed Jul 14, 2021
1 parent 53f3250 commit 49d0cea
Showing 1 changed file with 11 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@
import org.springframework.data.gemfire.expiration.AnnotationBasedExpiration;
import org.springframework.data.gemfire.expiration.ExpirationActionType;
import org.springframework.data.gemfire.expiration.ExpiringRegionFactoryBean;
import org.springframework.data.gemfire.util.ArrayUtils;
import org.springframework.data.gemfire.util.CollectionUtils;
import org.springframework.lang.NonNull;
import org.springframework.util.Assert;

/**
Expand Down Expand Up @@ -83,15 +85,15 @@ public class ExpirationConfiguration extends AbstractAnnotationConfigSupport imp
* @see java.lang.annotation.Annotation
* @see java.lang.Class
*/
protected Class<? extends Annotation> getAnnotationType() {
protected @NonNull Class<? extends Annotation> getAnnotationType() {
return EnableExpiration.class;
}

/**
* @inheritDoc
*/
@Override
public void setImportMetadata(AnnotationMetadata importMetadata) {
public void setImportMetadata(@NonNull AnnotationMetadata importMetadata) {

if (isAnnotationPresent(importMetadata)) {

Expand Down Expand Up @@ -182,7 +184,7 @@ protected static class ComposableExpirationPolicyConfigurer implements Expiratio
* @see #compose(Iterable)
*/
protected static ExpirationPolicyConfigurer compose(ExpirationPolicyConfigurer[] array) {
return compose(Arrays.asList(nullSafeArray(array, ExpirationPolicyConfigurer.class)));
return compose(Arrays.asList(ArrayUtils.nullSafeArray(array, ExpirationPolicyConfigurer.class)));
}

/**
Expand Down Expand Up @@ -217,8 +219,8 @@ protected static ExpirationPolicyConfigurer compose(ExpirationPolicyConfigurer o
ExpirationPolicyConfigurer two) {

return one == null ? two
: (two == null ? one
: new ComposableExpirationPolicyConfigurer(one, two));
: two == null ? one
: new ComposableExpirationPolicyConfigurer(one, two);
}

/**
Expand All @@ -229,7 +231,8 @@ protected static ExpirationPolicyConfigurer compose(ExpirationPolicyConfigurer o
* @param two second {@link ComposableExpirationPolicyConfigurer} to compose.
* @see org.springframework.data.gemfire.config.annotation.ExpirationConfiguration.ExpirationPolicyConfigurer
*/
private ComposableExpirationPolicyConfigurer(ExpirationPolicyConfigurer one, ExpirationPolicyConfigurer two) {
private ComposableExpirationPolicyConfigurer(@NonNull ExpirationPolicyConfigurer one,
@NonNull ExpirationPolicyConfigurer two) {

this.one = one;
this.two = two;
Expand Down Expand Up @@ -490,7 +493,7 @@ protected boolean isTimeToLive() {
protected String resolveRegionName(Object regionFactoryBean) {

return regionFactoryBean instanceof ResolvableRegionFactoryBean
? ((ResolvableRegionFactoryBean) regionFactoryBean).resolveRegionName()
? ((ResolvableRegionFactoryBean<?, ?>) regionFactoryBean).resolveRegionName()
: null;
}

Expand Down Expand Up @@ -530,7 +533,7 @@ protected String resolveRegionName(Object regionFactoryBean) {
public Object configure(Object regionFactoryBean) {

return accepts(regionFactoryBean)
? setExpirationAttributes((ExpiringRegionFactoryBean) regionFactoryBean)
? setExpirationAttributes((ExpiringRegionFactoryBean<?, ?>) regionFactoryBean)
: regionFactoryBean;
}

Expand Down

0 comments on commit 49d0cea

Please sign in to comment.