@@ -59,8 +59,7 @@ abstract class SerializableTypeWrapper {
5959 private static final Class <?>[] SUPPORTED_SERIALIZABLE_TYPES = {
6060 GenericArrayType .class , ParameterizedType .class , TypeVariable .class , WildcardType .class };
6161
62- private static final ConcurrentReferenceHashMap <Type , Type > cache =
63- new ConcurrentReferenceHashMap <>(256 );
62+ static final ConcurrentReferenceHashMap <Type , Type > cache = new ConcurrentReferenceHashMap <>(256 );
6463
6564
6665 /**
@@ -84,12 +83,7 @@ public static Type forMethodParameter(MethodParameter methodParameter) {
8483 */
8584 @ SuppressWarnings ("serial" )
8685 public static Type forGenericSuperclass (final Class <?> type ) {
87- return forTypeProvider (new DefaultTypeProvider () {
88- @ Override
89- public Type getType () {
90- return type .getGenericSuperclass ();
91- }
92- });
86+ return forTypeProvider (type ::getGenericSuperclass );
9387 }
9488
9589 /**
@@ -100,12 +94,7 @@ public static Type[] forGenericInterfaces(final Class<?> type) {
10094 Type [] result = new Type [type .getGenericInterfaces ().length ];
10195 for (int i = 0 ; i < result .length ; i ++) {
10296 final int index = i ;
103- result [i ] = forTypeProvider (new DefaultTypeProvider () {
104- @ Override
105- public Type getType () {
106- return type .getGenericInterfaces ()[index ];
107- }
108- });
97+ result [i ] = forTypeProvider (() -> type .getGenericInterfaces ()[index ]);
10998 }
11099 return result ;
111100 }
@@ -118,12 +107,7 @@ public static Type[] forTypeParameters(final Class<?> type) {
118107 Type [] result = new Type [type .getTypeParameters ().length ];
119108 for (int i = 0 ; i < result .length ; i ++) {
120109 final int index = i ;
121- result [i ] = forTypeProvider (new DefaultTypeProvider () {
122- @ Override
123- public Type getType () {
124- return type .getTypeParameters ()[index ];
125- }
126- });
110+ result [i ] = forTypeProvider (() -> type .getTypeParameters ()[index ]);
127111 }
128112 return result ;
129113 }
@@ -183,6 +167,7 @@ interface SerializableTypeProxy {
183167 /**
184168 * A {@link Serializable} interface providing access to a {@link Type}.
185169 */
170+ @ SuppressWarnings ("serial" )
186171 interface TypeProvider extends Serializable {
187172
188173 /**
@@ -191,20 +176,10 @@ interface TypeProvider extends Serializable {
191176 Type getType ();
192177
193178 /**
194- * Return the source of the type or {@code null}.
179+ * Return the source of the type, or {@code null} if not known.
180+ * <p>The default implementations returns {@code null}.
195181 */
196- Object getSource ();
197- }
198-
199-
200- /**
201- * Default implementation of {@link TypeProvider} with a {@code null} source.
202- */
203- @ SuppressWarnings ("serial" )
204- private static abstract class DefaultTypeProvider implements TypeProvider {
205-
206- @ Override
207- public Object getSource () {
182+ default Object getSource () {
208183 return null ;
209184 }
210185 }
0 commit comments