DATACMNS-651 - Introduced a Range value type.
Primarily intended to be used with Distance instances, we introduce a Range value type. Distance now has factory methods to create Range instances between two distances. To support this, Distance now implements comparable based on the normalized value of it. Tiny refactoring in TypeDiscoverer to avoid code duplication between the lookup of parameter type information for constructors and methods.
This commit is contained in:
@@ -17,6 +17,7 @@ package org.springframework.data.util;
|
||||
|
||||
import java.beans.PropertyDescriptor;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Executable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.GenericArrayType;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -156,14 +157,8 @@ class TypeDiscoverer<S> implements TypeInformation<S> {
|
||||
*/
|
||||
public List<TypeInformation<?>> getParameterTypes(Constructor<?> constructor) {
|
||||
|
||||
Assert.notNull(constructor);
|
||||
List<TypeInformation<?>> result = new ArrayList<TypeInformation<?>>();
|
||||
|
||||
for (Type parameterType : constructor.getGenericParameterTypes()) {
|
||||
result.add(createInfo(parameterType));
|
||||
}
|
||||
|
||||
return result;
|
||||
Assert.notNull(constructor, "Constructor must not be null!");
|
||||
return getParameterTypes((Executable) constructor);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -412,16 +407,8 @@ class TypeDiscoverer<S> implements TypeInformation<S> {
|
||||
*/
|
||||
public List<TypeInformation<?>> getParameterTypes(Method method) {
|
||||
|
||||
Assert.notNull(method);
|
||||
|
||||
Type[] parameterTypes = method.getGenericParameterTypes();
|
||||
List<TypeInformation<?>> result = new ArrayList<TypeInformation<?>>(parameterTypes.length);
|
||||
|
||||
for (Type parameterType : parameterTypes) {
|
||||
result.add(createInfo(parameterType));
|
||||
}
|
||||
|
||||
return result;
|
||||
Assert.notNull(method, "Method most not be null!");
|
||||
return getParameterTypes((Executable) method);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -492,6 +479,18 @@ class TypeDiscoverer<S> implements TypeInformation<S> {
|
||||
return createInfo(arguments[index]);
|
||||
}
|
||||
|
||||
private List<TypeInformation<?>> getParameterTypes(Executable executable) {
|
||||
|
||||
Type[] types = executable.getGenericParameterTypes();
|
||||
List<TypeInformation<?>> result = new ArrayList<TypeInformation<?>>(types.length);
|
||||
|
||||
for (Type parameterType : types) {
|
||||
result.add(createInfo(parameterType));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
|
||||
Reference in New Issue
Block a user