DATACMNS-867 - Further fixes.

This commit is contained in:
Oliver Gierke
2016-11-15 13:05:34 +01:00
parent 615b6548e8
commit d7340e391c
7 changed files with 73 additions and 38 deletions

View File

@@ -15,6 +15,7 @@
*/
package org.springframework.data.mapping.context;
import lombok.AccessLevel;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
@@ -498,12 +499,16 @@ public abstract class AbstractMappingContext<E extends MutablePersistentEntity<?
*
* @author Oliver Gierke
*/
@RequiredArgsConstructor
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
private final class PersistentPropertyCreator implements FieldCallback {
private final @NonNull E entity;
private final @NonNull Map<String, PropertyDescriptor> descriptors;
private final Map<String, PropertyDescriptor> remainingDescriptors = new HashMap<>();
private final @NonNull Map<String, PropertyDescriptor> remainingDescriptors;
public PersistentPropertyCreator(E entity, Map<String, PropertyDescriptor> descriptors) {
this(entity, descriptors, descriptors);
}
/*
* (non-Javadoc)

View File

@@ -115,7 +115,7 @@ class CrudRepositoryInvoker extends ReflectionRepositoryInvoker {
}
}
protected boolean isRedeclaredMethod(Optional<Method> method) {
private static boolean isRedeclaredMethod(Optional<Method> method) {
return method.map(it -> !it.getDeclaringClass().equals(CrudRepository.class)).orElse(false);
}
}

View File

@@ -17,6 +17,7 @@ package org.springframework.data.repository.support;
import java.io.Serializable;
import java.lang.reflect.Method;
import java.util.Optional;
import org.springframework.core.convert.ConversionService;
import org.springframework.data.domain.Pageable;
@@ -35,7 +36,6 @@ import org.springframework.data.repository.core.RepositoryMetadata;
class PagingAndSortingRepositoryInvoker extends CrudRepositoryInvoker {
private final PagingAndSortingRepository<Object, Serializable> repository;
private final boolean customFindAll;
/**
@@ -63,7 +63,7 @@ class PagingAndSortingRepositoryInvoker extends CrudRepositoryInvoker {
*/
@Override
public Iterable<Object> invokeFindAll(Sort sort) {
return customFindAll ? invokeSortedFindAllReflectively(sort) : repository.findAll(sort);
return customFindAll ? invokeFindAllReflectively(sort) : repository.findAll(sort);
}
/*
@@ -72,10 +72,10 @@ class PagingAndSortingRepositoryInvoker extends CrudRepositoryInvoker {
*/
@Override
public Iterable<Object> invokeFindAll(Pageable pageable) {
return customFindAll ? invokePagedFindAllReflectively(pageable) : repository.findAll(pageable);
return customFindAll ? invokeFindAllReflectively(pageable) : repository.findAll(pageable);
}
private boolean isRedeclaredMethod(Method method) {
return !method.getDeclaringClass().equals(PagingAndSortingRepository.class);
private static boolean isRedeclaredMethod(Optional<Method> method) {
return method.map(it -> !it.getDeclaringClass().equals(PagingAndSortingRepository.class)).orElse(false);
}
}

View File

@@ -88,7 +88,7 @@ class ReflectionRepositoryInvoker implements RepositoryInvoker {
*/
@Override
public Iterable<Object> invokeFindAll(Sort sort) {
return invokeSortedFindAllReflectively(sort);
return invokeFindAllReflectively(sort);
}
/*
@@ -97,7 +97,7 @@ class ReflectionRepositoryInvoker implements RepositoryInvoker {
*/
@Override
public Iterable<Object> invokeFindAll(Pageable pageable) {
return invokePagedFindAllReflectively(pageable);
return invokeFindAllReflectively(pageable);
}
/*
@@ -113,12 +113,12 @@ class ReflectionRepositoryInvoker implements RepositoryInvoker {
* @see org.springframework.data.rest.core.invoke.RepositoryInvoker#invokeSave(java.lang.Object)
*/
@Override
@SuppressWarnings("unchecked")
public <T> T invokeSave(T object) {
return methods.getSaveMethod()//
.map(it -> (T) invoke(it, object))//
Method method = methods.getSaveMethod()//
.orElseThrow(() -> new IllegalStateException("Repository doesn't have a save-method declared!"));
return invoke(method, object);
}
/*
@@ -138,9 +138,10 @@ class ReflectionRepositoryInvoker implements RepositoryInvoker {
@SuppressWarnings("unchecked")
public <T> T invokeFindOne(Serializable id) {
return methods.getFindOneMethod()//
.map(it -> (T) invoke(it, convertId(id)))//
Method method = methods.getFindOneMethod()//
.orElseThrow(() -> new IllegalStateException("Repository doesn't have a find-one-method declared!"));
return invoke(method, convertId(id));
}
/*
@@ -262,7 +263,7 @@ class ReflectionRepositoryInvoker implements RepositoryInvoker {
return conversionService.convert(id, idType);
}
protected Iterable<Object> invokePagedFindAllReflectively(Pageable pageable) {
protected Iterable<Object> invokeFindAllReflectively(Pageable pageable) {
Method method = methods.getFindAllMethod()
.orElseThrow(() -> new IllegalStateException("Repository doesn't have a find-all-method declared!"));
@@ -279,7 +280,7 @@ class ReflectionRepositoryInvoker implements RepositoryInvoker {
return invokeFindAll(pageable.getSort());
}
protected Iterable<Object> invokeSortedFindAllReflectively(Sort sort) {
protected Iterable<Object> invokeFindAllReflectively(Sort sort) {
Method method = methods.getFindAllMethod()
.orElseThrow(() -> new IllegalStateException("Repository doesn't have a find-all-method declared!"));