DATACMNS-387 - Improvements in null handling in PartTree area.

We're now rejecting invalid constructor arguments handed to ClassTypeInformation, Part, PartTree and PropertyPath. Beyond that we skip the creation of a Part for an empty path segment, so that you don't end up with an invalid Part instance for a findAllByOrderByFooAsc.
This commit is contained in:
Oliver Gierke
2013-10-27 16:21:01 +01:00
parent 1624fec11a
commit ae9ee5b428
7 changed files with 79 additions and 19 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011 the original author or authors.
* Copyright 2011-2013 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.
@@ -29,6 +29,7 @@ import java.util.Set;
import java.util.WeakHashMap;
import org.springframework.core.GenericTypeResolver;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
/**
@@ -60,11 +61,13 @@ public class ClassTypeInformation<S> extends TypeDiscoverer<S> {
* Simple factory method to easily create new instances of {@link ClassTypeInformation}.
*
* @param <S>
* @param type
* @param type must not be {@literal null}.
* @return
*/
public static <S> TypeInformation<S> from(Class<S> type) {
Assert.notNull(type, "Type must not be null!");
Reference<TypeInformation<?>> cachedReference = CACHE.get(type);
TypeInformation<?> cachedTypeInfo = cachedReference == null ? null : cachedReference.get();
@@ -80,10 +83,12 @@ public class ClassTypeInformation<S> extends TypeDiscoverer<S> {
/**
* Creates a {@link TypeInformation} from the given method's return type.
*
* @param method
* @param method must not be {@literal null}.
* @return
*/
public static <S> TypeInformation<S> fromReturnTypeOf(Method method) {
Assert.notNull(method, "Method must not be null!");
return new ClassTypeInformation(method.getDeclaringClass()).createInfo(method.getGenericReturnType());
}