26
26
import org .springframework .beans .factory .BeanFactory ;
27
27
import org .springframework .beans .factory .NoSuchBeanDefinitionException ;
28
28
import org .springframework .beans .factory .config .AutowireCapableBeanFactory ;
29
+ import org .springframework .data .convert .PropertyValueConverter .ValueConversionContext ;
29
30
import org .springframework .data .mapping .PersistentProperty ;
30
31
import org .springframework .lang .Nullable ;
31
32
import org .springframework .util .Assert ;
@@ -59,14 +60,14 @@ static class CompositePropertyValueConverterFactory implements PropertyValueConv
59
60
60
61
@ Nullable
61
62
@ Override
62
- public <A , B , C extends PropertyValueConverter . ValueConversionContext > PropertyValueConverter <A , B , C > getConverter (
63
+ public <A , B , C extends ValueConversionContext <?> > PropertyValueConverter <A , B , C > getConverter (
63
64
PersistentProperty <?> property ) {
64
65
return delegates .stream ().map (it -> (PropertyValueConverter <A , B , C >) it .getConverter (property ))
65
66
.filter (Objects ::nonNull ).findFirst ().orElse (null );
66
67
}
67
68
68
69
@ Override
69
- public <S , T , C extends PropertyValueConverter . ValueConversionContext > PropertyValueConverter <S , T , C > getConverter (
70
+ public <S , T , C extends ValueConversionContext <?> > PropertyValueConverter <S , T , C > getConverter (
70
71
Class <? extends PropertyValueConverter <S , T , C >> converterType ) {
71
72
return delegates .stream ().filter (it -> it .getConverter (converterType ) != null ).findFirst ()
72
73
.map (it -> it .getConverter (converterType )).orElse (null );
@@ -82,7 +83,7 @@ public <S, T, C extends PropertyValueConverter.ValueConversionContext> PropertyV
82
83
static class SimplePropertyConverterFactory implements PropertyValueConverterFactory {
83
84
84
85
@ Override
85
- public <S , T , C extends PropertyValueConverter . ValueConversionContext > PropertyValueConverter <S , T , C > getConverter (
86
+ public <S , T , C extends ValueConversionContext <?> > PropertyValueConverter <S , T , C > getConverter (
86
87
Class <? extends PropertyValueConverter <S , T , C >> converterType ) {
87
88
88
89
Assert .notNull (converterType , "ConverterType must not be null!" );
@@ -110,7 +111,7 @@ public BeanFactoryAwarePropertyValueConverterFactory(BeanFactory beanFactory) {
110
111
}
111
112
112
113
@ Override
113
- public <S , T , C extends PropertyValueConverter . ValueConversionContext > PropertyValueConverter <S , T , C > getConverter (
114
+ public <S , T , C extends ValueConversionContext <?> > PropertyValueConverter <S , T , C > getConverter (
114
115
Class <? extends PropertyValueConverter <S , T , C >> converterType ) {
115
116
116
117
Assert .state (beanFactory != null , "BeanFactory must not be null. Did you forget to set it!" );
@@ -145,14 +146,14 @@ public ConfiguredInstanceServingValueConverterFactory(PropertyValueConverterRegi
145
146
146
147
@ Nullable
147
148
@ Override
148
- public <A , B , C extends PropertyValueConverter . ValueConversionContext > PropertyValueConverter <A , B , C > getConverter (
149
+ public <A , B , C extends ValueConversionContext <?> > PropertyValueConverter <A , B , C > getConverter (
149
150
PersistentProperty <?> property ) {
150
151
return (PropertyValueConverter <A , B , C >) conversionsRegistrar .getConverter (property .getOwner ().getType (),
151
152
property .getName ());
152
153
}
153
154
154
155
@ Override
155
- public <S , T , C extends PropertyValueConverter . ValueConversionContext > PropertyValueConverter <S , T , C > getConverter (
156
+ public <S , T , C extends ValueConversionContext <?> > PropertyValueConverter <S , T , C > getConverter (
156
157
Class <? extends PropertyValueConverter <S , T , C >> converterType ) {
157
158
return null ;
158
159
}
@@ -170,55 +171,55 @@ static class CachingPropertyValueConverterFactory implements PropertyValueConver
170
171
private final Cache cache = new Cache ();
171
172
172
173
public CachingPropertyValueConverterFactory (PropertyValueConverterFactory delegate ) {
173
-
174
+
174
175
Assert .notNull (delegate , "Delegate must not be null!" );
175
176
this .delegate = delegate ;
176
177
}
177
178
178
179
@ Nullable
179
180
@ Override
180
- public <S , T , C extends PropertyValueConverter . ValueConversionContext > PropertyValueConverter <S , T , C > getConverter (
181
+ public <S , T , C extends ValueConversionContext <?> > PropertyValueConverter <S , T , C > getConverter (
181
182
PersistentProperty <?> property ) {
182
183
183
184
PropertyValueConverter converter = cache .get (property );
184
- if ( converter != null ) {
185
- return converter ;
186
- }
187
- return cache .cache (property , delegate .getConverter (property ));
185
+
186
+ return converter != null
187
+ ? converter
188
+ : cache .cache (property , delegate .getConverter (property ));
188
189
}
189
190
190
191
@ Override
191
- public <S , T , C extends PropertyValueConverter . ValueConversionContext > PropertyValueConverter <S , T , C > getConverter (
192
+ public <S , T , C extends ValueConversionContext <?> > PropertyValueConverter <S , T , C > getConverter (
192
193
Class <? extends PropertyValueConverter <S , T , C >> converterType ) {
193
194
194
195
PropertyValueConverter converter = cache .get (converterType );
195
- if ( converter != null ) {
196
- return converter ;
197
- }
198
- return cache .cache (converterType , delegate .getConverter (converterType ));
196
+
197
+ return converter != null
198
+ ? converter
199
+ : cache .cache (converterType , delegate .getConverter (converterType ));
199
200
}
200
201
201
202
static class Cache {
202
203
203
- Map <PersistentProperty <?>, PropertyValueConverter <?, ?, ? extends PropertyValueConverter . ValueConversionContext >> perPropertyCache = new HashMap <>();
204
- Map <Class <?>, PropertyValueConverter <?, ?, ? extends PropertyValueConverter . ValueConversionContext >> typeCache = new HashMap <>();
204
+ Map <PersistentProperty <?>, PropertyValueConverter <?, ?, ? extends ValueConversionContext <?> >> perPropertyCache = new HashMap <>();
205
+ Map <Class <?>, PropertyValueConverter <?, ?, ? extends ValueConversionContext <?> >> typeCache = new HashMap <>();
205
206
206
- PropertyValueConverter <?, ?, ? extends PropertyValueConverter . ValueConversionContext > get (PersistentProperty <?> property ) {
207
+ PropertyValueConverter <?, ?, ? extends ValueConversionContext <?> > get (PersistentProperty <?> property ) {
207
208
return perPropertyCache .get (property );
208
209
}
209
210
210
- PropertyValueConverter <?, ?, ? extends PropertyValueConverter . ValueConversionContext > get (Class <?> type ) {
211
+ PropertyValueConverter <?, ?, ? extends ValueConversionContext <?> > get (Class <?> type ) {
211
212
return typeCache .get (type );
212
213
}
213
214
214
- <S , T , C extends PropertyValueConverter . ValueConversionContext > PropertyValueConverter <S , T , C > cache (PersistentProperty <?> property ,
215
+ <S , T , C extends ValueConversionContext <?> > PropertyValueConverter <S , T , C > cache (PersistentProperty <?> property ,
215
216
PropertyValueConverter <S , T , C > converter ) {
216
217
perPropertyCache .putIfAbsent (property , converter );
217
218
cache (property .getValueConverterType (), converter );
218
219
return converter ;
219
220
}
220
221
221
- <S , T , C extends PropertyValueConverter . ValueConversionContext > PropertyValueConverter <S , T , C > cache (Class <?> type ,
222
+ <S , T , C extends ValueConversionContext <?> > PropertyValueConverter <S , T , C > cache (Class <?> type ,
222
223
PropertyValueConverter <S , T , C > converter ) {
223
224
typeCache .putIfAbsent (type , converter );
224
225
return converter ;
0 commit comments