Browse Source

DATACMNS-1097 - Polishing.

Updated Sonargraph architecture description. Polished imports in domain package to avoid unnecessary imports (mostly due to Javadoc references).

Removed manually declared constructor in ExampleMatcherAccessor in favor of Lombok's @RequiredArgsConstructor. Removed deprecations in type information subsystem. Moved to different way of class loading to avoid null pointer warnings in ReflectionUtils.
pull/231/head
Oliver Gierke 9 years ago
parent
commit
24704fc4de
  1. 82
      Spring Data Commons.sonargraph
  2. 4
      src/main/java/org/springframework/data/domain/DomainEvents.java
  3. 6
      src/main/java/org/springframework/data/domain/Page.java
  4. 20
      src/main/java/org/springframework/data/support/ExampleMatcherAccessor.java
  5. 1
      src/main/java/org/springframework/data/util/ClassTypeInformation.java
  6. 2
      src/main/java/org/springframework/data/util/ReflectionUtils.java
  7. 4
      src/main/java/org/springframework/data/util/TypeDiscoverer.java

82
Spring Data Commons.sonargraph

@ -57,6 +57,7 @@ @@ -57,6 +57,7 @@
<element type="IncludeTypePattern" name="**.core.support.**"/>
</element>
<dependency toName="Project|spring-data-commons::Layer|Application::Subsystem|Domain" type="AllowedDependency"/>
<dependency toName="Project|spring-data-commons::Layer|Application::Subsystem|Support" type="AllowedDependency"/>
<dependency toName="Project|spring-data-commons::Layer|Repositories::Subsystem|Core" type="AllowedDependency"/>
<dependency toName="Project|spring-data-commons::Layer|Repositories::Subsystem|Query" type="AllowedDependency"/>
</element>
@ -84,6 +85,7 @@ @@ -84,6 +85,7 @@
<element type="TypeFilter" name="Assignment">
<element type="IncludeTypePattern" name="**.cdi.**"/>
</element>
<dependency toName="External|External::Subsystem|JRE" type="AllowedDependency"/>
<dependency toName="External|External::Subsystem|JavaEE" type="AllowedDependency"/>
<dependency toName="External|External::Subsystem|Logging" type="AllowedDependency"/>
<dependency toName="External|External::Subsystem|Reflection" type="AllowedDependency"/>
@ -142,80 +144,92 @@ @@ -142,80 +144,92 @@
<element type="TypeFilter" name="Assignment">
<element type="IncludeTypePattern" name="**.context.**"/>
</element>
<dependency toName="Project|spring-data-commons::Layer|Application::Subsystem|Support" type="AllowedDependency"/>
<dependency toName="Project|spring-data-commons::Layer|Mapping::Subsystem|Model" type="AllowedDependency"/>
</element>
<dependency toName="Project|spring-data-commons::Layer|Core" type="AllowedDependency"/>
</element>
<element type="Layer" name="Core">
<element type="Layer" name="Application">
<element type="TypeFilter" name="Assignment"/>
<element type="Subsystem" name="Types">
<element type="Subsystem" name="Domain">
<element type="TypeFilter" name="Assignment">
<element type="WeakTypePattern" name="**.util.**"/>
<element type="WeakTypePattern" name="**.domain.**"/>
</element>
<stereotype name="Public"/>
</element>
<element type="Subsystem" name="Annotations">
<element type="Subsystem" name="JAXB">
<element type="TypeFilter" name="Assignment">
<element type="IncludeTypePattern" name="**.annotation.**"/>
<element type="IncludeTypePattern" name="**.domain.jaxb.**"/>
</element>
<stereotype name="Public"/>
<dependency toName="Project|spring-data-commons::Layer|Application::Subsystem|Domain" type="AllowedDependency"/>
<dependency toName="External|External::Subsystem|JAXB" type="AllowedDependency"/>
<dependency toName="External|External::Subsystem|Spring" type="AllowedDependency"/>
</element>
<element type="Subsystem" name="Geo">
<element type="Subsystem" name="Cross store">
<element type="TypeFilter" name="Assignment">
<element type="IncludeTypePattern" name="**.geo.**"/>
<element type="IncludeTypePattern" name="**.crossstore.**"/>
</element>
</element>
<element type="Subsystem" name="Authentication">
<element type="Subsystem" name="Geo">
<element type="TypeFilter" name="Assignment">
<element type="IncludeTypePattern" name="**.authentication.**"/>
<element type="IncludeTypePattern" name="**.geo.**"/>
</element>
<dependency toName="Project|spring-data-commons::Layer|Application::Subsystem|Domain" type="AllowedDependency"/>
</element>
<element type="Subsystem" name="History">
<element type="TypeFilter" name="Assignment">
<element type="WeakTypePattern" name="**.history.**"/>
</element>
<dependency toName="Project|spring-data-commons::Layer|Application::Subsystem|Domain" type="AllowedDependency"/>
</element>
<element type="Subsystem" name="Support">
<element type="TypeFilter" name="Assignment">
<element type="WeakTypePattern" name="**.support.**"/>
</element>
<dependency toName="Project|spring-data-commons::Layer|Application::Subsystem|Domain" type="AllowedDependency"/>
</element>
<element type="Subsystem" name="Transactions">
<dependency toName="Project|spring-data-commons::Layer|Core" type="AllowedDependency"/>
</element>
<element type="Layer" name="Core">
<element type="TypeFilter" name="Assignment"/>
<element type="Subsystem" name="Types">
<element type="TypeFilter" name="Assignment">
<element type="IncludeTypePattern" name="**.transaction.**"/>
<element type="WeakTypePattern" name="**.util.**Information"/>
<element type="IncludeTypePattern" name="**.util.TypeDiscoverer**"/>
</element>
<stereotype name="Public"/>
<dependency toName="Project|spring-data-commons::Layer|Core::Subsystem|Util" type="AllowedDependency"/>
</element>
<element type="Subsystem" name="Configuration">
<element type="Subsystem" name="Util">
<element type="TypeFilter" name="Assignment">
<element type="WeakTypePattern" name="**.config.**"/>
<element type="WeakTypePattern" name="**.util.**"/>
</element>
</element>
<element type="Subsystem" name="Projection">
<element type="Subsystem" name="Annotations">
<element type="TypeFilter" name="Assignment">
<element type="IncludeTypePattern" name="**.projection.**"/>
<element type="IncludeTypePattern" name="**.annotation.**"/>
</element>
<stereotype name="Public"/>
</element>
<dependency toName="Project|spring-data-commons::Layer|Application" type="AllowedDependency"/>
<element type="Subsystem" name="Authentication">
<element type="TypeFilter" name="Assignment">
<element type="IncludeTypePattern" name="**.authentication.**"/>
</element>
<element type="Layer" name="Application">
<element type="TypeFilter" name="Assignment"/>
<element type="Subsystem" name="Domain">
</element>
<element type="Subsystem" name="Transactions">
<element type="TypeFilter" name="Assignment">
<element type="WeakTypePattern" name="**.domain.**"/>
<element type="IncludeTypePattern" name="**.transaction.**"/>
</element>
</element>
<element type="Subsystem" name="JAXB">
<element type="Subsystem" name="Configuration">
<element type="TypeFilter" name="Assignment">
<element type="IncludeTypePattern" name="**.domain.jaxb.**"/>
<element type="WeakTypePattern" name="**.config.**"/>
</element>
<dependency toName="Project|spring-data-commons::Layer|Application::Subsystem|Domain" type="AllowedDependency"/>
<dependency toName="External|External::Subsystem|JAXB" type="AllowedDependency"/>
<dependency toName="External|External::Subsystem|Spring" type="AllowedDependency"/>
</element>
<element type="Subsystem" name="Cross store">
<element type="Subsystem" name="Projection">
<element type="TypeFilter" name="Assignment">
<element type="IncludeTypePattern" name="**.crossstore.**"/>
<element type="IncludeTypePattern" name="**.projection.**"/>
</element>
<dependency toName="Project|spring-data-commons::Layer|Core::Subsystem|Util" type="AllowedDependency"/>
</element>
</element>
</architecture>
@ -348,6 +362,16 @@ @@ -348,6 +362,16 @@
<element type="IncludeTypePattern" name="org.threeten.bp.**"/>
</element>
</element>
<element type="Subsystem" name="Vavr">
<element type="TypeFilter" name="Assignment">
<element type="IncludeTypePattern" name="io.vavr.**"/>
</element>
</element>
<element type="Subsystem" name="Lombok">
<element type="TypeFilter" name="Assignment">
<element type="IncludeTypePattern" name="lombok.**"/>
</element>
</element>
</architecture>
</scope>
<scope type="Global" name="Global">

4
src/main/java/org/springframework/data/domain/DomainEvents.java

@ -20,14 +20,12 @@ import java.lang.annotation.Retention; @@ -20,14 +20,12 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.context.ApplicationEventPublisher;
/**
* {@link DomainEvents} can be used on methods of aggregate roots managed by Spring Data repositories to publish the
* events returned by that method as Spring application events.
*
* @author Oliver Gierke
* @see ApplicationEventPublisher
* @see org.springframework.context.ApplicationEventPublisher
* @see AfterDomainEventPublication
* @since 1.13
* @soundtrack Benny Greb - Soulfood (Moving Parts Live)

6
src/main/java/org/springframework/data/domain/Page.java

@ -17,8 +17,6 @@ package org.springframework.data.domain; @@ -17,8 +17,6 @@ package org.springframework.data.domain;
import java.util.function.Function;
import org.springframework.core.convert.converter.Converter;
/**
* A page is a sublist of a list of objects. It allows gain information about the position of it in the containing
* entire list.
@ -43,10 +41,10 @@ public interface Page<T> extends Slice<T> { @@ -43,10 +41,10 @@ public interface Page<T> extends Slice<T> {
long getTotalElements();
/**
* Returns a new {@link Page} with the content of the current one mapped by the given {@link Converter}.
* Returns a new {@link Page} with the content of the current one mapped by the given {@link Function}.
*
* @param converter must not be {@literal null}.
* @return a new {@link Page} with the content of the current one mapped by the given {@link Converter}.
* @return a new {@link Page} with the content of the current one mapped by the given {@link Function}.
* @since 1.10
*/
<U> Page<U> map(Function<? super T, ? extends U> converter);

20
src/main/java/org/springframework/data/support/ExampleMatcherAccessor.java

@ -15,12 +15,13 @@ @@ -15,12 +15,13 @@
*/
package org.springframework.data.support;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import java.util.Collection;
import org.springframework.data.domain.ExampleMatcher;
import org.springframework.data.domain.ExampleMatcher.PropertySpecifier;
import org.springframework.data.util.StringMatcher;
import org.springframework.util.Assert;
/**
* Accessor for the {@link ExampleMatcher} to use in modules that support query by example (QBE) querying.
@ -31,21 +32,10 @@ import org.springframework.util.Assert; @@ -31,21 +32,10 @@ import org.springframework.util.Assert;
* @author Jens Schauder
* @since 1.12
*/
@RequiredArgsConstructor
public class ExampleMatcherAccessor {
private final ExampleMatcher matcher;
/**
* Creates a new {@link ExampleMatcherAccessor} for the given {@link ExampleMatcher}.
*
* @param matcher must not be {@literal null}.
*/
public ExampleMatcherAccessor(ExampleMatcher matcher) {
Assert.notNull(matcher, "ExampleMatcher must not be null!");
this.matcher = matcher;
}
private final @NonNull ExampleMatcher matcher;
/**
* Returns the {@link PropertySpecifier}s of the underlying {@link ExampleMatcher}.

1
src/main/java/org/springframework/data/util/ClassTypeInformation.java

@ -117,7 +117,6 @@ public class ClassTypeInformation<S> extends TypeDiscoverer<S> { @@ -117,7 +117,6 @@ public class ClassTypeInformation<S> extends TypeDiscoverer<S> {
return getTypeVariableMap(type, new HashSet<>());
}
@SuppressWarnings("deprecation")
private static Map<TypeVariable<?>, Type> getTypeVariableMap(Class<?> type, Collection<Type> visited) {
if (visited.contains(type)) {

2
src/main/java/org/springframework/data/util/ReflectionUtils.java

@ -60,7 +60,7 @@ public class ReflectionUtils { @@ -60,7 +60,7 @@ public class ReflectionUtils {
public static <T> T createInstanceIfPresent(String classname, T defaultInstance) {
try {
Class<?> type = ClassUtils.getDefaultClassLoader().loadClass(classname);
Class<?> type = ClassUtils.forName(classname, ClassUtils.getDefaultClassLoader());
return (T) BeanUtils.instantiateClass(type);
} catch (Exception e) {
return defaultInstance;

4
src/main/java/org/springframework/data/util/TypeDiscoverer.java

@ -115,7 +115,7 @@ class TypeDiscoverer<S> implements TypeInformation<S> { @@ -115,7 +115,7 @@ class TypeDiscoverer<S> implements TypeInformation<S> {
* @param fieldType must not be {@literal null}.
* @return
*/
@SuppressWarnings({ "rawtypes", "unchecked", "deprecation" })
@SuppressWarnings({ "rawtypes", "unchecked" })
protected TypeInformation<?> createInfo(Type fieldType) {
Assert.notNull(fieldType, "Field type must not be null!");
@ -180,7 +180,7 @@ class TypeDiscoverer<S> implements TypeInformation<S> { @@ -180,7 +180,7 @@ class TypeDiscoverer<S> implements TypeInformation<S> {
* @param type
* @return
*/
@SuppressWarnings({ "unchecked", "rawtypes", "deprecation" })
@SuppressWarnings({ "unchecked", "rawtypes" })
protected Class<S> resolveType(Type type) {
Map<TypeVariable, Type> map = new HashMap<>();

Loading…
Cancel
Save