Skip to content

Commit

Permalink
DATACMNS-1762 - Polishing.
Browse files Browse the repository at this point in the history
Update JavaDoc, remove unused imports and reduce method visibility.

Original Pull Request: #459
  • Loading branch information
christophstrobl committed Sep 25, 2020
1 parent 97df0fa commit f261220
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.springframework.data.mapping.PreferredConstructor.Parameter;
import org.springframework.data.util.ClassTypeInformation;
import org.springframework.data.util.KotlinReflectionUtils;
import org.springframework.data.util.ReflectionUtils;
import org.springframework.data.util.TypeInformation;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ private boolean conversionRequiredAndPossible(Object source, Class<?> targetType
* a single-element collection.
*
* @param source must not be {@literal null}.
* @return
* @return never {@literal null}.
*/
private static Collection<?> asCollection(Object source) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.core.Ordered;
import org.springframework.data.repository.Repository;
import org.springframework.data.repository.cdi.CdiRepositoryExtensionSupport;

/**
* {@link ApplicationListener} to trigger the initialization of Spring Data repositories right before the application
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;

import org.springframework.beans.factory.config.DependencyDescriptor;
import org.springframework.beans.factory.parsing.BeanComponentDefinition;
Expand All @@ -41,7 +40,6 @@
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.io.support.SpringFactoriesLoader;
import org.springframework.core.log.LogMessage;
import org.springframework.data.repository.cdi.CdiRepositoryExtensionSupport;
import org.springframework.data.repository.core.support.RepositoryFactorySupport;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
*/
package org.springframework.data.repository.core.support;

import static org.springframework.core.GenericTypeResolver.*;

import java.lang.reflect.GenericDeclaration;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
Expand Down Expand Up @@ -322,8 +320,8 @@ private static boolean usesParametersWithReactiveWrappers(Method method) {
* Returns a candidate method from the base class for the given one or the method given in the first place if none
* one the base class matches.
*
* @param method must not be {@literal null}.
* @param baseClass must not be {@literal null}.
* @param invokedMethod must not be {@literal null}.
* @param candidate must not be {@literal null}.
* @param predicate must not be {@literal null}.
* @return
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class QueryExecutionResultHandler {
/**
* Creates a new {@link QueryExecutionResultHandler}.
*/
public QueryExecutionResultHandler(GenericConversionService conversionService) {
QueryExecutionResultHandler(GenericConversionService conversionService) {
this.conversionService = conversionService;
}

Expand All @@ -66,7 +66,7 @@ public QueryExecutionResultHandler(GenericConversionService conversionService) {
* @return
*/
@Nullable
public Object postProcessInvocationResult(@Nullable Object result, Method method) {
Object postProcessInvocationResult(@Nullable Object result, Method method) {

if (!processingRequired(result, method.getReturnType())) {
return result;
Expand Down Expand Up @@ -172,6 +172,7 @@ Object postProcessInvocationResult(@Nullable Object result, int nestingLevel, Re
: null;

}

private boolean requiresConversion(Collection<?> collection, Class<?> expectedReturnType,
@Nullable TypeDescriptor elementDescriptor) {

Expand Down Expand Up @@ -276,7 +277,7 @@ public static ReturnTypeDescriptor of(Method method) {
* @see TypeDescriptor#nested(MethodParameter, int)
*/
@Nullable
public TypeDescriptor getReturnTypeDescriptor(int nestingLevel) {
TypeDescriptor getReturnTypeDescriptor(int nestingLevel) {

// optimizing for nesting level 0 and 1 (Optional<T>, List<T>)
// nesting level 2 (Optional<List<T>>) uses the slow path.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public static TypeInformation<?> unwrapWrapperTypes(TypeInformation<?> type) {
* Returns the {@link ExecutionAdapter} to be used for the given return type.
*
* @param returnType must not be {@literal null}.
* @return
* @return can be {@literal null}.
*/
@Nullable
public static ExecutionAdapter getExecutionAdapter(Class<?> returnType) {
Expand Down Expand Up @@ -289,18 +289,17 @@ private static abstract class AbstractWrapperTypeConverter implements GenericCon
/**
* Creates a new {@link AbstractWrapperTypeConverter} using the given {@link ConversionService} and wrapper type.
*
* @param conversionService must not be {@literal null}.
* @param nullValue must not be {@literal null}.
*/
protected AbstractWrapperTypeConverter(Object nullValue) {
AbstractWrapperTypeConverter(Object nullValue) {

Assert.notNull(nullValue, "Null value must not be null!");

this.nullValue = nullValue;
this.wrapperTypes = Collections.singleton(nullValue.getClass());
}

public AbstractWrapperTypeConverter(Object nullValue,
AbstractWrapperTypeConverter(Object nullValue,
Iterable<Class<?>> wrapperTypes) {
this.nullValue = nullValue;
this.wrapperTypes = wrapperTypes;
Expand Down Expand Up @@ -356,10 +355,8 @@ private static class NullableWrapperToFutureConverter extends AbstractWrapperTyp

/**
* Creates a new {@link NullableWrapperToFutureConverter} using the given {@link ConversionService}.
*
* @param conversionService must not be {@literal null}.
*/
public NullableWrapperToFutureConverter() {
NullableWrapperToFutureConverter() {
super(new AsyncResult<>(null), Arrays.asList(Future.class, ListenableFuture.class));
}

Expand All @@ -382,10 +379,8 @@ private static class NullableWrapperToCompletableFutureConverter extends Abstrac

/**
* Creates a new {@link NullableWrapperToCompletableFutureConverter} using the given {@link ConversionService}.
*
* @param conversionService must not be {@literal null}.
*/
public NullableWrapperToCompletableFutureConverter() {
NullableWrapperToCompletableFutureConverter() {
super(CompletableFuture.completedFuture(null));
}

Expand All @@ -398,7 +393,7 @@ protected Object wrap(Object source) {
return source instanceof CompletableFuture ? source : CompletableFuture.completedFuture(source);
}

public static WrapperType getWrapperType() {
static WrapperType getWrapperType() {
return WrapperType.singleValue(CompletableFuture.class);
}
}
Expand Down Expand Up @@ -438,7 +433,7 @@ private static class IterableToStreamableConverter implements ConditionalGeneric
private final Map<TypeDescriptor, Boolean> targetTypeCache = new ConcurrentHashMap<>();
private final ConversionService conversionService = DefaultConversionService.getSharedInstance();

public IterableToStreamableConverter() {}
IterableToStreamableConverter() {}

/*
* (non-Javadoc)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014-2020 the original author or authors.
* Copyright 2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -41,7 +41,7 @@ public NullableWrapper(@Nullable Object value) {
}

/**
* Returns the type of the contained value. WIll fall back to {@link Object} in case the value is {@literal null}.
* Returns the type of the contained value. Will fall back to {@link Object} in case the value is {@literal null}.
*
* @return will never be {@literal null}.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2014-2020 the original author or authors.
* Copyright 2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -228,7 +228,6 @@ private static abstract class AbstractWrapperTypeConverter implements GenericCon
/**
* Creates a new {@link AbstractWrapperTypeConverter} using the given wrapper type.
*
* @param conversionService must not be {@literal null}.
* @param nullValue must not be {@literal null}.
*/
protected AbstractWrapperTypeConverter(Object nullValue) {
Expand Down Expand Up @@ -501,11 +500,11 @@ private WrapperType(Class<?> type, Cardinality cardinality) {
this.cardinality = cardinality;
}

public Class<?> getType() {
Class<?> getType() {
return this.type;
}

public Cardinality getCardinality() {
Cardinality getCardinality() {
return cardinality;
}

Expand Down Expand Up @@ -560,19 +559,19 @@ enum Cardinality {
private final Class<?> type;
private final Cardinality cardinality;

public static WrapperType singleValue(Class<?> type) {
static WrapperType singleValue(Class<?> type) {
return new WrapperType(type, Cardinality.SINGLE);
}

public static WrapperType multiValue(Class<?> type) {
static WrapperType multiValue(Class<?> type) {
return new WrapperType(type, Cardinality.MULTI);
}

public static WrapperType noValue(Class<?> type) {
static WrapperType noValue(Class<?> type) {
return new WrapperType(type, Cardinality.NONE);
}

public boolean isSingleValue() {
boolean isSingleValue() {
return cardinality.equals(Cardinality.SINGLE);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.core.MethodParameter;
import org.springframework.core.log.LogMessage;
Expand Down

0 comments on commit f261220

Please sign in to comment.