DATACMNS-1673 - Polishing.

Use method references where possible. Cleanup generics. Omit superfluous calls.

Original pull request: #426.
This commit is contained in:
SergiiTsypanov
2020-02-25 09:38:42 +01:00
committed by Mark Paluch
parent 5f3102144c
commit eaaa37d4ff
4 changed files with 6 additions and 8 deletions

View File

@@ -307,7 +307,7 @@ class EntityCallbackDiscoverer {
Collection<Method> methods = new ArrayList<>(1);
ReflectionUtils.doWithMethods(callbackType, mc -> methods.add(mc), method -> {
ReflectionUtils.doWithMethods(callbackType, methods::add, method -> {
if (!Modifier.isPublic(method.getModifiers()) || method.getParameterCount() != args.length + 1
|| method.isBridge() || ReflectionUtils.isObjectMethod(method)) {

View File

@@ -278,9 +278,7 @@ public class BasicPersistentEntity<T, P extends PersistentProperty<P>> implement
Assert.notNull(association, "Association must not be null!");
if (!associations.contains(association)) {
associations.add(association);
}
associations.add(association);
}
/*

View File

@@ -111,13 +111,13 @@ public class MethodInvocationValidator implements MethodInterceptor {
boolean nullableReturn;
boolean[] nullableParameters;
MethodParameter methodParameters[];
MethodParameter[] methodParameters;
static Nullability of(Method method, ParameterNameDiscoverer discoverer) {
boolean nullableReturn = isNullableParameter(new MethodParameter(method, -1));
boolean[] nullableParameters = new boolean[method.getParameterCount()];
MethodParameter methodParameters[] = new MethodParameter[method.getParameterCount()];
MethodParameter[] methodParameters = new MethodParameter[method.getParameterCount()];
for (int i = 0; i < method.getParameterCount(); i++) {

View File

@@ -178,7 +178,7 @@ class ReflectionRepositoryInvoker implements RepositoryInvoker {
* @see org.springframework.data.rest.core.invoke.RepositoryInvoker#invokeQueryMethod(java.lang.reflect.Method, java.util.Map, org.springframework.data.domain.Pageable, org.springframework.data.domain.Sort)
*/
@Override
public Optional<Object> invokeQueryMethod(Method method, MultiValueMap<String, ? extends Object> parameters,
public Optional<Object> invokeQueryMethod(Method method, MultiValueMap<String, ?> parameters,
Pageable pageable, Sort sort) {
Assert.notNull(method, "Method must not be null!");
@@ -191,7 +191,7 @@ class ReflectionRepositoryInvoker implements RepositoryInvoker {
return returnAsOptional(invoke(method, prepareParameters(method, parameters, pageable, sort)));
}
private Object[] prepareParameters(Method method, MultiValueMap<String, ? extends Object> rawParameters,
private Object[] prepareParameters(Method method, MultiValueMap<String, ?> rawParameters,
Pageable pageable, Sort sort) {
List<MethodParameter> parameters = new MethodParameters(method, Optional.of(PARAM_ANNOTATION)).getParameters();