Skip to content

Commit 51aebc6

Browse files
Adapt to changes of TypeInformation in Spring Data Commons.
See spring-projects/spring-data-commons@1d6331c
1 parent 7c9a1fe commit 51aebc6

File tree

12 files changed

+35
-39
lines changed

12 files changed

+35
-39
lines changed

src/main/java/org/springframework/data/neo4j/core/Neo4jTemplate.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@
9090
import org.springframework.data.projection.ProjectionFactory;
9191
import org.springframework.data.projection.ProjectionInformation;
9292
import org.springframework.data.projection.SpelAwareProxyProjectionFactory;
93-
import org.springframework.data.util.ClassTypeInformation;
93+
import org.springframework.data.util.TypeInformation;
9494
import org.springframework.lang.NonNull;
9595
import org.springframework.lang.Nullable;
9696
import org.springframework.util.Assert;
@@ -307,8 +307,7 @@ private Object convertIdValues(@Nullable Neo4jPersistentProperty idProperty, Obj
307307
return idValues;
308308
}
309309

310-
return neo4jMappingContext.getConversionService().writeValue(idValues,
311-
ClassTypeInformation.from(idValues.getClass()),
310+
return neo4jMappingContext.getConversionService().writeValue(idValues, TypeInformation.of(idValues.getClass()),
312311
idProperty == null ? null : idProperty.getOptionalConverter());
313312
}
314313

src/main/java/org/springframework/data/neo4j/core/ReactiveNeo4jTemplate.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
import org.springframework.data.projection.ProjectionFactory;
9494
import org.springframework.data.projection.ProjectionInformation;
9595
import org.springframework.data.projection.SpelAwareProxyProjectionFactory;
96-
import org.springframework.data.util.ClassTypeInformation;
96+
import org.springframework.data.util.TypeInformation;
9797
import org.springframework.lang.NonNull;
9898
import org.springframework.lang.Nullable;
9999
import org.springframework.util.Assert;
@@ -307,7 +307,7 @@ private Object convertIdValues(@Nullable Neo4jPersistentProperty idProperty, Obj
307307
}
308308

309309
return neo4jMappingContext.getConversionService().writeValue(idValues,
310-
ClassTypeInformation.from(idValues.getClass()), idProperty == null ? null : idProperty.getOptionalConverter());
310+
TypeInformation.of(idValues.getClass()), idProperty == null ? null : idProperty.getOptionalConverter());
311311
}
312312

313313
@Override

src/main/java/org/springframework/data/neo4j/core/mapping/DefaultNeo4jPersistentProperty.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import org.springframework.data.neo4j.core.schema.Relationship;
3232
import org.springframework.data.neo4j.core.schema.RelationshipProperties;
3333
import org.springframework.data.neo4j.core.schema.TargetNode;
34-
import org.springframework.data.util.ClassTypeInformation;
3534
import org.springframework.data.util.Lazy;
3635
import org.springframework.data.util.ReflectionUtils;
3736
import org.springframework.data.util.TypeInformation;
@@ -114,11 +113,11 @@ protected Association<Neo4jPersistentProperty> createAssociation() {
114113

115114
if (this.hasActualTypeAnnotation(RelationshipProperties.class)) {
116115
Class<?> type = getRelationshipPropertiesTargetType(getActualType());
117-
obverseOwner = this.mappingContext.addPersistentEntity(ClassTypeInformation.from(type)).get();
118-
relationshipPropertiesClass = this.mappingContext.addPersistentEntity(ClassTypeInformation.from(getActualType())).get();
116+
obverseOwner = this.mappingContext.addPersistentEntity(TypeInformation.of(type)).get();
117+
relationshipPropertiesClass = this.mappingContext.addPersistentEntity(TypeInformation.of(getActualType())).get();
119118
} else {
120119
Class<?> associationTargetType = this.getAssociationTargetType();
121-
obverseOwner = this.mappingContext.addPersistentEntity(ClassTypeInformation.from(associationTargetType)).orElse(null);
120+
obverseOwner = this.mappingContext.addPersistentEntity(TypeInformation.of(associationTargetType)).orElse(null);
122121
Assert.notNull(obverseOwner, "Obverse owner could not be added.");
123122
if (dynamicAssociation) {
124123

@@ -133,7 +132,7 @@ protected Association<Neo4jPersistentProperty> createAssociation() {
133132

134133
if (relationshipPropertiesCollection) {
135134
Class<?> type = getRelationshipPropertiesTargetType(mapValueType.getActualType().getType());
136-
obverseOwner = this.mappingContext.addPersistentEntity(ClassTypeInformation.from(type)).get();
135+
obverseOwner = this.mappingContext.addPersistentEntity(TypeInformation.of(type)).get();
137136
relationshipPropertiesClass = this.mappingContext
138137
.addPersistentEntity(mapValueType.getComponentType()).get();
139138

@@ -183,7 +182,7 @@ private Class<?> getRelationshipPropertiesTargetType(Class<?> relationshipProper
183182
if (targetNodeField == null) {
184183
throw new MappingException("Missing @TargetNode declaration in " + relationshipPropertiesType);
185184
}
186-
ClassTypeInformation<?> relationshipPropertiesTypeInformation = ClassTypeInformation.from(relationshipPropertiesType);
185+
TypeInformation<?> relationshipPropertiesTypeInformation = TypeInformation.of(relationshipPropertiesType);
187186
return relationshipPropertiesTypeInformation.getProperty(targetNodeField.getName()).getType();
188187
}
189188

src/main/java/org/springframework/data/neo4j/core/mapping/DtoInstantiatingConverter.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import org.springframework.data.mapping.PersistentProperty;
3535
import org.springframework.data.mapping.PersistentPropertyAccessor;
3636
import org.springframework.data.mapping.model.ParameterValueProvider;
37-
import org.springframework.data.util.ClassTypeInformation;
37+
import org.springframework.data.util.TypeInformation;
3838
import org.springframework.lang.Nullable;
3939
import org.springframework.util.Assert;
4040

@@ -73,7 +73,7 @@ public Object convertDirectly(Object entityInstance) {
7373
Neo4jPersistentEntity<?> sourceEntity = context.getRequiredPersistentEntity(entityInstance.getClass());
7474
PersistentPropertyAccessor<Object> sourceAccessor = sourceEntity.getPropertyAccessor(entityInstance);
7575

76-
Neo4jPersistentEntity<?> targetEntity = context.addPersistentEntity(ClassTypeInformation.from(targetType)).orElse(null);
76+
Neo4jPersistentEntity<?> targetEntity = context.addPersistentEntity(TypeInformation.of(targetType)).orElse(null);
7777
Assert.notNull(targetEntity, "Target entity could not be created for a DTO");
7878
InstanceCreatorMetadata<?> creator = targetEntity.getInstanceCreatorMetadata();
7979

@@ -127,7 +127,7 @@ public Object convert(@Nullable EntityInstanceWithSource entityInstanceAndSource
127127
Neo4jPersistentEntity<?> sourceEntity = context.getRequiredPersistentEntity(entityInstance.getClass());
128128
PersistentPropertyAccessor<Object> sourceAccessor = sourceEntity.getPropertyAccessor(entityInstance);
129129

130-
Neo4jPersistentEntity<?> targetEntity = context.addPersistentEntity(ClassTypeInformation.from(targetType))
130+
Neo4jPersistentEntity<?> targetEntity = context.addPersistentEntity(TypeInformation.of(targetType))
131131
.orElseThrow(() -> new MappingException(
132132
"Could not add a persistent entity for the projection target type '" + targetType.getName() + "'."));
133133
InstanceCreatorMetadata<? extends PersistentProperty<?>> creator = targetEntity.getInstanceCreatorMetadata();
@@ -150,7 +150,7 @@ private ParameterValueProvider<Neo4jPersistentProperty> getParameterValueProvide
150150
Neo4jPersistentEntity<?> targetEntity,
151151
Function<Neo4jPersistentProperty, Object> extractFromSource
152152
) {
153-
return new ParameterValueProvider<Neo4jPersistentProperty>() {
153+
return new ParameterValueProvider<>() {
154154
@SuppressWarnings("unchecked") // Needed for the last cast. It's easier that way than using the parameter type info and checking for primitives
155155
@Override
156156
public <T> T getParameterValue(Parameter<T, Neo4jPersistentProperty> parameter) {
@@ -223,7 +223,7 @@ Object getPropertyValueFor(Neo4jPersistentProperty targetProperty, PersistentEnt
223223
if (context.hasPersistentEntityFor(actualType)) {
224224
singleValue = p -> context.getEntityConverter().read(actualType, p);
225225
} else {
226-
ClassTypeInformation<?> actualTargetType = ClassTypeInformation.from(actualType);
226+
TypeInformation<?> actualTargetType = TypeInformation.of(actualType);
227227
singleValue = p -> context.getConversionService().readValue(p, actualTargetType, targetProperty.getOptionalConverter());
228228
}
229229

src/main/java/org/springframework/data/neo4j/core/mapping/EntityFromDtoInstantiatingConverter.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
import org.springframework.data.mapping.model.ParameterValueProvider;
3232
import org.springframework.data.neo4j.core.convert.Neo4jConversionService;
3333
import org.springframework.data.neo4j.core.schema.TargetNode;
34-
import org.springframework.data.util.ClassTypeInformation;
3534
import org.springframework.data.util.ReflectionUtils;
35+
import org.springframework.data.util.TypeInformation;
3636
import org.springframework.lang.Nullable;
3737
import org.springframework.util.Assert;
3838

@@ -71,8 +71,8 @@ public T convert(Object dtoInstance) {
7171
return null;
7272
}
7373

74-
PersistentEntity<?, ?> sourceEntity = context.addPersistentEntity(
75-
ClassTypeInformation.from(dtoInstance.getClass())).get();
74+
PersistentEntity<?, ?> sourceEntity = context.addPersistentEntity(TypeInformation.of(dtoInstance.getClass()))
75+
.get();
7676
PersistentPropertyAccessor<Object> sourceAccessor = sourceEntity.getPropertyAccessor(dtoInstance);
7777

7878
PersistentEntity<?, ?> targetEntity = context.getPersistentEntity(targetEntityType);

src/main/java/org/springframework/data/neo4j/core/schema/CompositeProperty.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
import org.springframework.data.neo4j.core.convert.Neo4jPersistentPropertyToMapConverter;
4545
import org.springframework.data.neo4j.core.mapping.Neo4jPersistentProperty;
4646
import org.springframework.data.neo4j.core.schema.CompositeProperty.Phase;
47-
import org.springframework.data.util.ClassTypeInformation;
4847
import org.springframework.data.util.TypeInformation;
4948
import org.springframework.lang.Nullable;
5049
import org.springframework.util.Assert;
@@ -336,7 +335,7 @@ public Neo4jPersistentPropertyConverter<?> getPropertyConverterFor(Neo4jPersiste
336335

337336
if (delegate == null) {
338337
if (delegateClass == CompositeProperty.DefaultToMapConverter.class) {
339-
delegate = new CompositeProperty.DefaultToMapConverter(ClassTypeInformation.from(persistentProperty.getActualType()));
338+
delegate = new CompositeProperty.DefaultToMapConverter(TypeInformation.of(persistentProperty.getActualType()));
340339
} else {
341340
delegate = BeanUtils.instantiateClass(delegateClass);
342341
}

src/main/java/org/springframework/data/neo4j/repository/query/Neo4jQuerySupport.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
import org.springframework.data.repository.query.QueryMethod;
4949
import org.springframework.data.repository.query.ResultProcessor;
5050
import org.springframework.data.repository.query.ReturnedType;
51-
import org.springframework.data.util.ClassTypeInformation;
51+
import org.springframework.data.util.TypeInformation;
5252
import org.springframework.expression.spel.standard.SpelExpressionParser;
5353
import org.springframework.lang.Nullable;
5454
import org.springframework.util.Assert;
@@ -202,7 +202,7 @@ final Object convertParameter(Object parameter, @Nullable Neo4jPersistentPropert
202202
}
203203

204204
return mappingContext.getConversionService().writeValue(parameter,
205-
ClassTypeInformation.from(parameter.getClass()), conversionOverride);
205+
TypeInformation.of(parameter.getClass()), conversionOverride);
206206
}
207207

208208
static class QueryContext {

src/main/java/org/springframework/data/neo4j/repository/query/PartValidator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import org.springframework.data.neo4j.core.mapping.Neo4jMappingContext;
3535
import org.springframework.data.neo4j.core.mapping.Neo4jPersistentProperty;
3636
import org.springframework.data.repository.query.parser.Part;
37-
import org.springframework.data.util.ClassTypeInformation;
37+
import org.springframework.data.util.TypeInformation;
3838
import org.springframework.util.Assert;
3939

4040
/**
@@ -115,7 +115,7 @@ private void validateCollectionProperty(Part part) {
115115
private void validatePointProperty(Part part) {
116116

117117
Assert.isTrue(
118-
ClassTypeInformation.from(Point.class)
118+
TypeInformation.of(Point.class)
119119
.isAssignableFrom(part.getProperty().getLeafProperty().getTypeInformation()),
120120
() -> String.format("Can not derive query for '%s': %s works only with spatial properties.", queryMethod,
121121
part.getType()));

src/main/java/org/springframework/data/neo4j/repository/query/ReactiveNeo4jQueryMethod.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import org.springframework.data.projection.ProjectionFactory;
2626
import org.springframework.data.repository.core.RepositoryMetadata;
2727
import org.springframework.data.repository.util.ReactiveWrappers;
28-
import org.springframework.data.util.ClassTypeInformation;
2928
import org.springframework.data.util.Lazy;
3029
import org.springframework.data.util.TypeInformation;
3130
import org.springframework.util.ClassUtils;
@@ -42,8 +41,8 @@
4241
*/
4342
final class ReactiveNeo4jQueryMethod extends Neo4jQueryMethod {
4443

45-
private static final ClassTypeInformation<Page> PAGE_TYPE = ClassTypeInformation.from(Page.class);
46-
private static final ClassTypeInformation<Slice> SLICE_TYPE = ClassTypeInformation.from(Slice.class);
44+
private static final TypeInformation<Page> PAGE_TYPE = TypeInformation.of(Page.class);
45+
private static final TypeInformation<Slice> SLICE_TYPE = TypeInformation.of(Slice.class);
4746

4847
private final Lazy<Boolean> isCollectionQuery;
4948

@@ -59,7 +58,7 @@ final class ReactiveNeo4jQueryMethod extends Neo4jQueryMethod {
5958

6059
if (org.springframework.data.repository.util.ClassUtils.hasParameterOfType(method, Pageable.class)) {
6160

62-
TypeInformation<?> returnType = ClassTypeInformation.fromReturnTypeOf(method);
61+
TypeInformation<?> returnType = TypeInformation.fromReturnTypeOf(method);
6362

6463
boolean multiWrapper = ReactiveWrappers.isMultiValueType(returnType.getType());
6564
boolean singleWrapperWithWrappedPageableResult = ReactiveWrappers.isSingleValueType(returnType.getType())

src/test/java/org/springframework/data/neo4j/core/mapping/DefaultNeo4jConversionServiceTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
import org.springframework.dao.TypeMismatchDataAccessException;
3636
import org.springframework.data.neo4j.core.ReactiveNeo4jClient;
3737
import org.springframework.data.neo4j.core.convert.Neo4jConversions;
38-
import org.springframework.data.util.ClassTypeInformation;
38+
import org.springframework.data.util.TypeInformation;
3939

4040
/**
4141
* @author Michael J. Simons
@@ -52,27 +52,27 @@ class Reads {
5252
void shouldDealWith0IsoDurationsAsPeriods() {
5353
Value zeroDuration = Values.isoDuration(0, 0, 0, 0);
5454

55-
Period period = (Period) defaultNeo4jEntityAccessor.readValue(zeroDuration, ClassTypeInformation.from(Period.class), null);
55+
Period period = (Period) defaultNeo4jEntityAccessor.readValue(zeroDuration, TypeInformation.of(Period.class), null);
5656
assertThat(period.isZero()).isTrue();
5757
}
5858

5959
@Test // GH-2324
6060
void shouldDealWith0IsoDurationsAsDurations() {
6161
Value zeroDuration = Values.isoDuration(0, 0, 0, 0);
6262

63-
Duration duration = (Duration) defaultNeo4jEntityAccessor.readValue(zeroDuration, ClassTypeInformation.from(Duration.class), null);
63+
Duration duration = (Duration) defaultNeo4jEntityAccessor.readValue(zeroDuration, TypeInformation.of(Duration.class), null);
6464
assertThat(duration).isZero();
6565
}
6666

6767
@Test // GH-2324
6868
void shouldDealWithNullTemporalValueOnRead() {
69-
Duration duration = (Duration) defaultNeo4jEntityAccessor.readValue(null, ClassTypeInformation.from(Duration.class), null);
69+
Duration duration = (Duration) defaultNeo4jEntityAccessor.readValue(null, TypeInformation.of(Duration.class), null);
7070
assertThat(duration).isNull();
7171
}
7272

7373
@Test // GH-2324
7474
void shouldDealWithNullTemporalValueOnWrite() {
75-
Value value = defaultNeo4jEntityAccessor.writeValue(null, ClassTypeInformation.from(TemporalAmount.class), null);
75+
Value value = defaultNeo4jEntityAccessor.writeValue(null, TypeInformation.of(TemporalAmount.class), null);
7676
assertThat(value).isNull();
7777
}
7878

@@ -81,7 +81,7 @@ void shouldCatchConversionErrors() {
8181
Value value = Values.value("Das funktioniert nicht.");
8282

8383
assertThatExceptionOfType(TypeMismatchDataAccessException.class)
84-
.isThrownBy(() -> defaultNeo4jEntityAccessor.readValue(value, ClassTypeInformation.from(Date.class), null))
84+
.isThrownBy(() -> defaultNeo4jEntityAccessor.readValue(value, TypeInformation.of(Date.class), null))
8585
.withMessageStartingWith("Could not convert \"Das funktioniert nicht.\" into java.util.Date;")
8686
.withCauseInstanceOf(ConversionFailedException.class).withRootCauseInstanceOf(DateTimeParseException.class);
8787
}
@@ -92,7 +92,7 @@ void shouldCatchUncoercibleErrors() {
9292

9393
assertThatExceptionOfType(TypeMismatchDataAccessException.class)
9494
.isThrownBy(
95-
() -> defaultNeo4jEntityAccessor.readValue(value, ClassTypeInformation.from(LocalDate.class), null))
95+
() -> defaultNeo4jEntityAccessor.readValue(value, TypeInformation.of(LocalDate.class), null))
9696
.withMessageStartingWith("Could not convert \"Das funktioniert nicht.\" into java.time.LocalDate;")
9797
.withCauseInstanceOf(ConversionFailedException.class).withRootCauseInstanceOf(Uncoercible.class);
9898
}
@@ -102,7 +102,7 @@ void shouldCatchCoercibleErrors() {
102102
Value value = Values.value("Das funktioniert nicht.");
103103

104104
assertThatExceptionOfType(TypeMismatchDataAccessException.class).isThrownBy(
105-
() -> defaultNeo4jEntityAccessor.readValue(value, ClassTypeInformation.from(ReactiveNeo4jClient.class), null))
105+
() -> defaultNeo4jEntityAccessor.readValue(value, TypeInformation.of(ReactiveNeo4jClient.class), null))
106106
.withMessageStartingWith(
107107
"Could not convert \"Das funktioniert nicht.\" into org.springframework.data.neo4j.core.ReactiveNeo4jClient;")
108108
.withRootCauseInstanceOf(ConverterNotFoundException.class);

0 commit comments

Comments
 (0)