DATACMNS-697 - TypeDiscoverer now considers field-local generics information.

In case we create a ParameterizedTypeInformation for a property we now also analyze the field-local generics information and add the discovered type mappings to the type variable map.
This commit is contained in:
Oliver Gierke
2015-05-16 18:55:47 +02:00
parent 89f3be473c
commit 65104a4a3a
2 changed files with 42 additions and 2 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2011-2014 the original author or authors.
* Copyright 2011-2015 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.
@@ -25,6 +25,7 @@ import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -125,6 +126,17 @@ public class ParameterizedTypeUnitTests {
assertThat(type.getActualType(), is(type));
}
/**
* @see DATACMNS-697
*/
@Test
public void usesLocalGenericInformationOfFields() {
TypeInformation<NormalizedProfile> information = ClassTypeInformation.from(NormalizedProfile.class);
TypeInformation<?> valueType = information.getProperty("education2.data").getComponentType();
assertThat(valueType.getProperty("value").getType(), is(typeCompatibleWith(Education.class)));
}
@SuppressWarnings("serial")
class Localized<S> extends HashMap<Locale, S> {
S value;
@@ -151,4 +163,21 @@ public class ParameterizedTypeUnitTests {
class Second {
Parameterized<String> property;
}
// see DATACMNS-697
class NormalizedProfile {
ListField<Education> education2;
}
class ListField<L> {
List<Value<L>> data;
}
class Value<T> {
T value;
}
class Education {}
}