@@ -59,8 +59,7 @@ abstract class SerializableTypeWrapper {
59
59
private static final Class <?>[] SUPPORTED_SERIALIZABLE_TYPES = {
60
60
GenericArrayType .class , ParameterizedType .class , TypeVariable .class , WildcardType .class };
61
61
62
- private static final ConcurrentReferenceHashMap <Type , Type > cache =
63
- new ConcurrentReferenceHashMap <>(256 );
62
+ static final ConcurrentReferenceHashMap <Type , Type > cache = new ConcurrentReferenceHashMap <>(256 );
64
63
65
64
66
65
/**
@@ -84,12 +83,7 @@ public static Type forMethodParameter(MethodParameter methodParameter) {
84
83
*/
85
84
@ SuppressWarnings ("serial" )
86
85
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 );
93
87
}
94
88
95
89
/**
@@ -100,12 +94,7 @@ public static Type[] forGenericInterfaces(final Class<?> type) {
100
94
Type [] result = new Type [type .getGenericInterfaces ().length ];
101
95
for (int i = 0 ; i < result .length ; i ++) {
102
96
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 ]);
109
98
}
110
99
return result ;
111
100
}
@@ -118,12 +107,7 @@ public static Type[] forTypeParameters(final Class<?> type) {
118
107
Type [] result = new Type [type .getTypeParameters ().length ];
119
108
for (int i = 0 ; i < result .length ; i ++) {
120
109
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 ]);
127
111
}
128
112
return result ;
129
113
}
@@ -183,6 +167,7 @@ interface SerializableTypeProxy {
183
167
/**
184
168
* A {@link Serializable} interface providing access to a {@link Type}.
185
169
*/
170
+ @ SuppressWarnings ("serial" )
186
171
interface TypeProvider extends Serializable {
187
172
188
173
/**
@@ -191,20 +176,10 @@ interface TypeProvider extends Serializable {
191
176
Type getType ();
192
177
193
178
/**
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}.
195
181
*/
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 () {
208
183
return null ;
209
184
}
210
185
}
0 commit comments