37
37
import org .springframework .core .convert .ConversionService ;
38
38
import org .springframework .core .convert .support .DefaultConversionService ;
39
39
import org .springframework .dao .InvalidDataAccessApiUsageException ;
40
- import org .springframework .data .cassandra .core .mapping .BasicCassandraPersistentEntity ;
41
- import org .springframework .data .cassandra .core .mapping .BasicMapId ;
42
- import org .springframework .data .cassandra .core .mapping .CassandraMappingContext ;
43
- import org .springframework .data .cassandra .core .mapping .CassandraPersistentEntity ;
44
- import org .springframework .data .cassandra .core .mapping .CassandraPersistentProperty ;
45
- import org .springframework .data .cassandra .core .mapping .Column ;
46
- import org .springframework .data .cassandra .core .mapping .Element ;
47
- import org .springframework .data .cassandra .core .mapping .Embedded ;
40
+ import org .springframework .data .cassandra .core .mapping .*;
48
41
import org .springframework .data .cassandra .core .mapping .Embedded .OnEmpty ;
49
- import org .springframework .data .cassandra .core .mapping .EmbeddedEntityOperations ;
50
- import org .springframework .data .cassandra .core .mapping .MapId ;
51
- import org .springframework .data .cassandra .core .mapping .MapIdentifiable ;
52
- import org .springframework .data .cassandra .core .mapping .UserTypeResolver ;
53
42
import org .springframework .data .convert .CustomConversions ;
54
43
import org .springframework .data .mapping .AccessOptions ;
55
44
import org .springframework .data .mapping .MappingException ;
@@ -143,22 +132,22 @@ public MappingCassandraConverter(CassandraMappingContext mappingContext) {
143
132
this .mappingContext = mappingContext ;
144
133
this .setCodecRegistry (mappingContext .getCodecRegistry ());
145
134
this .setCustomConversions (mappingContext .getCustomConversions ());
146
- this .cassandraTypeResolver = new DefaultColumnTypeResolver (mappingContext , userTypeResolver ,
147
- this :: getCodecRegistry , this ::getCustomConversions );
135
+ this .cassandraTypeResolver = new DefaultColumnTypeResolver (mappingContext , userTypeResolver , this :: getCodecRegistry ,
136
+ this ::getCustomConversions );
148
137
this .embeddedEntityOperations = new EmbeddedEntityOperations (mappingContext );
149
138
this .spELContext = new SpELContext (RowReaderPropertyAccessor .INSTANCE );
150
139
}
151
140
152
141
/**
153
- * Constructs a new instance of {@link ConversionContext} with various converters to convert different Cassandra
154
- * value types.
142
+ * Constructs a new instance of {@link ConversionContext} with various converters to convert different Cassandra value
143
+ * types.
155
144
*
156
145
* @return the {@link ConversionContext}.
157
146
* @see ConversionContext
158
147
*/
159
148
protected ConversionContext getConversionContext () {
160
149
161
- return new ConversionContext (this ::doReadRow , this ::doReadTupleValue , this ::doReadUdtValue ,
150
+ return new ConversionContext (getCustomConversions (), this ::doReadRow , this ::doReadTupleValue , this ::doReadUdtValue ,
162
151
this ::readCollectionOrArray , this ::readMap , this ::getPotentiallyConvertedSimpleRead );
163
152
}
164
153
@@ -184,7 +173,6 @@ private static CassandraMappingContext newDefaultMappingContext(CassandraCustomC
184
173
return mappingContext ;
185
174
}
186
175
187
-
188
176
/* (non-Javadoc)
189
177
* @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
190
178
*/
@@ -501,8 +489,8 @@ protected <S> S doReadEntity(ConversionContext context, CassandraValueProvider v
501
489
return (S ) getConversionService ().convert (valueProvider .getSource (), rawType );
502
490
}
503
491
504
- CassandraPersistentEntity <S > entity =
505
- ( CassandraPersistentEntity < S >) getMappingContext () .getPersistentEntity (typeHint );
492
+ CassandraPersistentEntity <S > entity = ( CassandraPersistentEntity < S >) getMappingContext ()
493
+ .getPersistentEntity (typeHint );
506
494
507
495
if (entity == null ) {
508
496
throw new MappingException (
@@ -527,8 +515,8 @@ private static Class<?> getRawSourceType(CassandraValueProvider valueProvider) {
527
515
return UdtValue .class ;
528
516
}
529
517
530
- throw new InvalidDataAccessApiUsageException (String . format ( "Unsupported source type: %s" ,
531
- ClassUtils .getDescriptiveType (valueProvider .getSource ())));
518
+ throw new InvalidDataAccessApiUsageException (
519
+ String . format ( "Unsupported source type: %s" , ClassUtils .getDescriptiveType (valueProvider .getSource ())));
532
520
}
533
521
534
522
private <S > S doReadEntity (ConversionContext context , CassandraValueProvider valueProvider ,
@@ -539,8 +527,8 @@ private <S> S doReadEntity(ConversionContext context, CassandraValueProvider val
539
527
540
528
if (persistenceConstructor != null && persistenceConstructor .hasParameters ()) {
541
529
SpELExpressionEvaluator evaluator = new DefaultSpELExpressionEvaluator (valueProvider .getSource (), spELContext );
542
- ParameterValueProvider <CassandraPersistentProperty > parameterValueProvider =
543
- newParameterValueProvider ( context , entity , valueProvider );
530
+ ParameterValueProvider <CassandraPersistentProperty > parameterValueProvider = newParameterValueProvider ( context ,
531
+ entity , valueProvider );
544
532
provider = new ConverterAwareSpELExpressionParameterValueProvider (evaluator , getConversionService (),
545
533
parameterValueProvider , context );
546
534
} else {
@@ -927,20 +915,17 @@ private Object getWriteValue(@Nullable Object value, ColumnType columnType) {
927
915
928
916
if (getCustomConversions ().hasCustomWriteTarget (value .getClass (), requestedTargetType )) {
929
917
930
- Class <?> resolvedTargetType = getCustomConversions ()
931
- .getCustomWriteTarget (value .getClass (), requestedTargetType )
918
+ Class <?> resolvedTargetType = getCustomConversions ().getCustomWriteTarget (value .getClass (), requestedTargetType )
932
919
.orElse (requestedTargetType );
933
920
934
921
return getConversionService ().convert (value , resolvedTargetType );
935
922
}
936
923
937
924
if (getCustomConversions ().hasCustomWriteTarget (value .getClass ())) {
938
925
939
- Class <?> resolvedTargetType = getCustomConversions ()
940
- .getCustomWriteTarget (value .getClass ())
941
- .orElseThrow (() -> new IllegalStateException (
942
- String .format ("Unable to determined custom write target for value type [%s]" ,
943
- value .getClass ().getName ())));
926
+ Class <?> resolvedTargetType = getCustomConversions ().getCustomWriteTarget (value .getClass ())
927
+ .orElseThrow (() -> new IllegalStateException (String
928
+ .format ("Unable to determined custom write target for value type [%s]" , value .getClass ().getName ())));
944
929
945
930
return getConversionService ().convert (value , resolvedTargetType );
946
931
}
@@ -1318,10 +1303,9 @@ protected static class ConversionContext {
1318
1303
final ValueConverter <Object > elementConverter ;
1319
1304
1320
1305
public ConversionContext (org .springframework .data .convert .CustomConversions conversions ,
1321
- ContainerValueConverter <Row > rowConverter ,
1322
- ContainerValueConverter <TupleValue > tupleConverter , ContainerValueConverter <UdtValue > udtConverter ,
1323
- ContainerValueConverter <Collection <?>> collectionConverter , ContainerValueConverter <Map <?, ?>> mapConverter ,
1324
- ValueConverter <Object > elementConverter ) {
1306
+ ContainerValueConverter <Row > rowConverter , ContainerValueConverter <TupleValue > tupleConverter ,
1307
+ ContainerValueConverter <UdtValue > udtConverter , ContainerValueConverter <Collection <?>> collectionConverter ,
1308
+ ContainerValueConverter <Map <?, ?>> mapConverter , ValueConverter <Object > elementConverter ) {
1325
1309
this .conversions = conversions ;
1326
1310
this .rowConverter = rowConverter ;
1327
1311
this .tupleConverter = tupleConverter ;
0 commit comments