Skip to content

Commit 17521a2

Browse files
committed
Move off deprecated ClassTypeInformation.
Closes gh-782
1 parent 747ed7f commit 17521a2

File tree

2 files changed

+14
-18
lines changed

2 files changed

+14
-18
lines changed

spring-vault-core/src/main/java/org/springframework/vault/repository/convert/DefaultVaultTypeMapper.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import org.springframework.data.mapping.Alias;
2727
import org.springframework.data.mapping.PersistentEntity;
2828
import org.springframework.data.mapping.context.MappingContext;
29-
import org.springframework.data.util.ClassTypeInformation;
3029
import org.springframework.data.util.TypeInformation;
3130
import org.springframework.lang.Nullable;
3231

@@ -44,7 +43,7 @@ public class DefaultVaultTypeMapper extends DefaultTypeMapper<Map<String, Object
4443
public static final String DEFAULT_TYPE_KEY = "_class";
4544

4645
@SuppressWarnings("rawtypes")
47-
private static final TypeInformation<Map> MAP_TYPE_INFO = ClassTypeInformation.from(Map.class);
46+
private static final TypeInformation<Map> MAP_TYPE_INFO = TypeInformation.MAP;
4847

4948
private final @Nullable String typeKey;
5049

spring-vault-core/src/main/java/org/springframework/vault/repository/convert/MappingVaultConverter.java

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
import org.springframework.data.mapping.model.ParameterValueProvider;
3636
import org.springframework.data.mapping.model.PersistentEntityParameterValueProvider;
3737
import org.springframework.data.mapping.model.PropertyValueProvider;
38-
import org.springframework.data.util.ClassTypeInformation;
3938
import org.springframework.data.util.TypeInformation;
4039
import org.springframework.lang.Nullable;
4140
import org.springframework.util.Assert;
@@ -92,7 +91,7 @@ public MappingContext<? extends VaultPersistentEntity<?>, VaultPersistentPropert
9291

9392
@Override
9493
public <S> S read(Class<S> type, SecretDocument source) {
95-
return read(ClassTypeInformation.from(type), source);
94+
return read(TypeInformation.of(type), source);
9695
}
9796

9897
@SuppressWarnings("unchecked")
@@ -101,8 +100,7 @@ private <S> S read(TypeInformation<S> type, Object source) {
101100
SecretDocument secretDocument = getSecretDocument(source);
102101

103102
TypeInformation<? extends S> typeToUse = secretDocument != null
104-
? this.typeMapper.readType(secretDocument.getBody(), type)
105-
: (TypeInformation) ClassTypeInformation.OBJECT;
103+
? this.typeMapper.readType(secretDocument.getBody(), type) : (TypeInformation) TypeInformation.OBJECT;
106104
Class<? extends S> rawType = typeToUse.getType();
107105

108106
if (this.conversions.hasCustomReadTarget(source.getClass(), rawType)) {
@@ -121,7 +119,7 @@ private <S> S read(TypeInformation<S> type, Object source) {
121119
return (S) readMap(typeToUse, secretDocument.getBody());
122120
}
123121

124-
if (typeToUse.equals(ClassTypeInformation.OBJECT)) {
122+
if (typeToUse.equals(TypeInformation.OBJECT)) {
125123
return (S) source;
126124
}
127125

@@ -256,7 +254,7 @@ private Object readCollectionOrArray(TypeInformation<?> targetType, List sourceV
256254
Class<?> collectionType = targetType.getType();
257255

258256
TypeInformation<?> componentType = targetType.getComponentType() != null ? targetType.getComponentType()
259-
: ClassTypeInformation.OBJECT;
257+
: TypeInformation.OBJECT;
260258
Class<?> rawComponentType = componentType.getType();
261259

262260
collectionType = Collection.class.isAssignableFrom(collectionType) ? collectionType : List.class;
@@ -270,10 +268,10 @@ private Object readCollectionOrArray(TypeInformation<?> targetType, List sourceV
270268
for (Object obj : sourceValue) {
271269

272270
if (obj instanceof Map) {
273-
items.add(read(componentType, (Map) obj));
271+
items.add(read(componentType, obj));
274272
}
275273
else if (obj instanceof List) {
276-
items.add(readCollectionOrArray(ClassTypeInformation.OBJECT, (List) obj));
274+
items.add(readCollectionOrArray(TypeInformation.OBJECT, (List) obj));
277275
}
278276
else {
279277
items.add(getPotentiallyConvertedSimpleRead(obj, rawComponentType));
@@ -318,14 +316,13 @@ protected Map<Object, Object> readMap(TypeInformation<?> type, Map<String, Objec
318316
}
319317

320318
Object value = entry.getValue();
321-
TypeInformation<?> defaultedValueType = valueType != null ? valueType : ClassTypeInformation.OBJECT;
319+
TypeInformation<?> defaultedValueType = valueType != null ? valueType : TypeInformation.OBJECT;
322320

323321
if (value instanceof Map) {
324322
map.put(key, read(defaultedValueType, (Map) value));
325323
}
326324
else if (value instanceof List) {
327-
map.put(key,
328-
readCollectionOrArray(valueType != null ? valueType : ClassTypeInformation.LIST, (List) value));
325+
map.put(key, readCollectionOrArray(valueType != null ? valueType : TypeInformation.LIST, (List) value));
329326
}
330327
else {
331328
map.put(key, getPotentiallyConvertedSimpleRead(value, rawValueType));
@@ -361,7 +358,7 @@ private Object getPotentiallyConvertedSimpleRead(@Nullable Object value, @Nullab
361358
public void write(Object source, SecretDocument sink) {
362359

363360
Class<?> entityType = ClassUtils.getUserClass(source.getClass());
364-
TypeInformation<? extends Object> type = ClassTypeInformation.from(entityType);
361+
TypeInformation<? extends Object> type = TypeInformation.of(entityType);
365362

366363
SecretDocumentAccessor documentAccessor = new SecretDocumentAccessor(sink);
367364

@@ -398,7 +395,7 @@ protected void writeInternal(Object obj, SecretDocumentAccessor sink, @Nullable
398395
}
399396

400397
if (Map.class.isAssignableFrom(entityType)) {
401-
writeMapInternal((Map<Object, Object>) obj, sink.getBody(), ClassTypeInformation.MAP);
398+
writeMapInternal((Map<Object, Object>) obj, sink.getBody(), TypeInformation.MAP);
402399
return;
403400
}
404401

@@ -456,7 +453,7 @@ protected void writePropertyInternal(@Nullable Object obj, SecretDocumentAccesso
456453
return;
457454
}
458455

459-
TypeInformation<?> valueType = ClassTypeInformation.from(obj.getClass());
456+
TypeInformation<?> valueType = TypeInformation.of(obj.getClass());
460457
TypeInformation<?> type = prop.getTypeInformation();
461458

462459
if (valueType.isCollectionLike()) {
@@ -487,7 +484,7 @@ protected void writePropertyInternal(@Nullable Object obj, SecretDocumentAccesso
487484
SecretDocumentAccessor nested = accessor.writeNested(prop);
488485

489486
writeInternal(obj, nested, entity);
490-
addCustomTypeKeyIfNecessary(ClassTypeInformation.from(prop.getRawType()), obj, nested);
487+
addCustomTypeKeyIfNecessary(TypeInformation.of(prop.getRawType()), obj, nested);
491488
}
492489

493490
private static boolean isSubtype(Class<?> left, Class<?> right) {
@@ -588,7 +585,7 @@ else if (val instanceof Collection || val.getClass().isArray()) {
588585
else {
589586
SecretDocumentAccessor nested = new SecretDocumentAccessor(new SecretDocument());
590587
TypeInformation<?> valueTypeInfo = propertyType.isMap() ? propertyType.getMapValueType()
591-
: ClassTypeInformation.OBJECT;
588+
: TypeInformation.OBJECT;
592589
writeInternal(val, nested, valueTypeInfo);
593590
bson.put(simpleKey, nested.getBody());
594591
}

0 commit comments

Comments
 (0)