Polishing.
Add assertions, refine Javadoc. Original pull request: #2635. See #2634.
This commit is contained in:
@@ -23,14 +23,14 @@ import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.springframework.data.util.Lazy;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Types managed by a Spring Data implementation. Used to predefine a set of know entities that might need processing
|
||||
* during the Spring container, Spring Data Repository initialization phase.
|
||||
* Types managed by a Spring Data implementation. Used to predefine a set of known entities that might need processing
|
||||
* during the initialization phase.
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @author John Blum
|
||||
* @see java.lang.FunctionalInterface
|
||||
* @since 3.0
|
||||
*/
|
||||
@FunctionalInterface
|
||||
@@ -60,6 +60,8 @@ public interface ManagedTypes {
|
||||
* @see #fromSupplier(Supplier)
|
||||
*/
|
||||
static ManagedTypes fromIterable(Iterable<? extends Class<?>> types) {
|
||||
|
||||
Assert.notNull(types, "Types must not be null");
|
||||
return types::forEach;
|
||||
}
|
||||
|
||||
@@ -75,6 +77,8 @@ public interface ManagedTypes {
|
||||
* @see #fromSupplier(Supplier)
|
||||
*/
|
||||
static ManagedTypes fromStream(Stream<? extends Class<?>> types) {
|
||||
|
||||
Assert.notNull(types, "Types must not be null");
|
||||
return types::forEach;
|
||||
}
|
||||
|
||||
@@ -88,11 +92,13 @@ public interface ManagedTypes {
|
||||
* {@link Iterable} of {@link Class types}.
|
||||
* @see java.util.function.Supplier
|
||||
* @see java.lang.Iterable
|
||||
* @see #fromIterable(Iterable)
|
||||
* @see #fromStream(Stream)
|
||||
* @see #fromIterable(Iterable)
|
||||
* @see #fromStream(Stream)
|
||||
*/
|
||||
static ManagedTypes fromSupplier(Supplier<Iterable<Class<?>>> dataProvider) {
|
||||
|
||||
Assert.notNull(dataProvider, "Supplier must not be null");
|
||||
|
||||
return new ManagedTypes() {
|
||||
|
||||
final Lazy<Iterable<Class<?>>> lazyProvider = Lazy.of(dataProvider);
|
||||
|
||||
@@ -33,6 +33,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
@@ -59,7 +60,6 @@ import org.springframework.data.mapping.model.Property;
|
||||
import org.springframework.data.mapping.model.SimpleTypeHolder;
|
||||
import org.springframework.data.spel.EvaluationContextProvider;
|
||||
import org.springframework.data.spel.ExtensionAwareEvaluationContextProvider;
|
||||
import org.springframework.data.util.ClassTypeInformation;
|
||||
import org.springframework.data.util.KotlinReflectionUtils;
|
||||
import org.springframework.data.util.NullableWrapperConverters;
|
||||
import org.springframework.data.util.Optionals;
|
||||
@@ -153,7 +153,7 @@ public abstract class AbstractMappingContext<E extends MutablePersistentEntity<?
|
||||
/**
|
||||
* Sets the types to populate the context initially.
|
||||
*
|
||||
* @param managedTypes must not be {@literal null}. Use {@link ManagedTypes#empty()} instead;
|
||||
* @param managedTypes must not be {@literal null}. Use {@link ManagedTypes#empty()} instead.
|
||||
* @since 3.0
|
||||
*/
|
||||
public void setManagedTypes(ManagedTypes managedTypes) {
|
||||
|
||||
Reference in New Issue
Block a user