Skip to content

Commit 76df242

Browse files
committed
ClassTypeInformation is now deprecated.
Closes #1456.
1 parent e126bff commit 76df242

File tree

8 files changed

+29
-35
lines changed

8 files changed

+29
-35
lines changed

src/main/java/org/springframework/data/couchbase/core/convert/AbstractCouchbaseConverter.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import org.springframework.data.couchbase.core.mapping.CouchbasePersistentProperty;
3030
import org.springframework.data.mapping.model.ConvertingPropertyAccessor;
3131
import org.springframework.data.mapping.model.EntityInstantiators;
32-
import org.springframework.data.util.ClassTypeInformation;
3332
import org.springframework.data.util.TypeInformation;
3433

3534
/**
@@ -163,12 +162,12 @@ public Object convertForWriteIfNeeded(Object inValue) {
163162
// superseded by EnumCvtrs value = Enum.class.isAssignableFrom(value.getClass()) ? ((Enum<?>) value).name() :
164163
// value;
165164
} else if (value instanceof Collection || elementType.isArray()) {
166-
TypeInformation<?> type = ClassTypeInformation.from(value.getClass());
165+
TypeInformation<?> type = TypeInformation.of(value.getClass());
167166
value = ((MappingCouchbaseConverter) this).writeCollectionInternal(MappingCouchbaseConverter.asCollection(value),
168167
new CouchbaseList(conversions.getSimpleTypeHolder()), type, null, null);
169168
} else {
170169
CouchbaseDocument embeddedDoc = new CouchbaseDocument();
171-
TypeInformation<?> type = ClassTypeInformation.from(value.getClass());
170+
TypeInformation<?> type = TypeInformation.of(value.getClass());
172171
((MappingCouchbaseConverter) this).writeInternalRoot(value, embeddedDoc, type, false, null, true);
173172
value = embeddedDoc;
174173
}

src/main/java/org/springframework/data/couchbase/core/convert/MappingCouchbaseConverter.java

+5-6
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070
import org.springframework.data.mapping.model.SpELContext;
7171
import org.springframework.data.mapping.model.SpELExpressionEvaluator;
7272
import org.springframework.data.mapping.model.SpELExpressionParameterValueProvider;
73-
import org.springframework.data.util.ClassTypeInformation;
7473
import org.springframework.data.util.TypeInformation;
7574
import org.springframework.lang.Nullable;
7675
import org.springframework.util.Assert;
@@ -206,7 +205,7 @@ public Alias getTypeAlias(TypeInformation<?> info) {
206205

207206
@Override
208207
public <R> R read(final Class<R> clazz, final CouchbaseDocument source) {
209-
return read(ClassTypeInformation.from(clazz), source, null);
208+
return read(TypeInformation.of(clazz), source, null);
210209
}
211210

212211
/**
@@ -438,7 +437,7 @@ public void write(final Object source, final CouchbaseDocument target) {
438437
}
439438

440439
boolean isCustom = conversions.getCustomWriteTarget(source.getClass(), CouchbaseDocument.class).isPresent();
441-
TypeInformation<?> type = ClassTypeInformation.from(source.getClass());
440+
TypeInformation<?> type = TypeInformation.of(source.getClass());
442441

443442
if (!isCustom) {
444443
typeMapper.writeType(type, target);
@@ -472,7 +471,7 @@ public void writeInternalRoot(final Object source, CouchbaseDocument target, Typ
472471
}
473472

474473
if (Map.class.isAssignableFrom(source.getClass())) {
475-
writeMapInternal((Map<Object, Object>) source, target, ClassTypeInformation.MAP, property);
474+
writeMapInternal((Map<Object, Object>) source, target, TypeInformation.MAP, property);
476475
return;
477476
}
478477

@@ -639,7 +638,7 @@ protected void writePropertyInternal(final Object source, final CouchbaseDocumen
639638
}
640639

641640
String name = prop.getFieldName();
642-
TypeInformation<?> valueType = ClassTypeInformation.from(source.getClass());
641+
TypeInformation<?> valueType = TypeInformation.of(source.getClass());
643642
TypeInformation<?> type = prop.getTypeInformation();
644643
if (valueType.isCollectionLike()) {
645644
CouchbaseList collectionDoc = createCollection(asCollection(source), valueType, prop, accessor);
@@ -968,7 +967,7 @@ public <R> R readValue(Object value, CouchbasePersistentProperty prop, Object pa
968967
}
969968
}
970969
if (conversions.hasCustomReadTarget(value.getClass(), rawType)) {
971-
TypeInformation ti = ClassTypeInformation.from(value.getClass());
970+
TypeInformation ti = TypeInformation.of(value.getClass());
972971
return (R) conversionService.convert(value, ti.toTypeDescriptor(), new TypeDescriptor(prop.getField()));
973972
}
974973
if (value instanceof CouchbaseDocument) {

src/main/java/org/springframework/data/couchbase/core/index/QueryIndexResolver.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import org.springframework.data.couchbase.core.mapping.CouchbasePersistentEntity;
2121
import org.springframework.data.couchbase.core.mapping.CouchbasePersistentProperty;
2222
import org.springframework.data.mapping.context.MappingContext;
23-
import org.springframework.data.util.ClassTypeInformation;
2423
import org.springframework.data.util.TypeInformation;
2524
import org.springframework.util.Assert;
2625

@@ -66,7 +65,7 @@ static QueryIndexResolver create(
6665
* @see 2.2
6766
*/
6867
default Iterable<? extends IndexDefinition> resolveIndexFor(Class<?> entityType) {
69-
return resolveIndexFor(ClassTypeInformation.from(entityType));
68+
return resolveIndexFor(TypeInformation.of(entityType));
7069
}
7170

7271
}

src/main/java/org/springframework/data/couchbase/core/query/Query.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import org.springframework.data.domain.Pageable;
3535
import org.springframework.data.domain.Sort;
3636
import org.springframework.data.mapping.Alias;
37-
import org.springframework.data.util.ClassTypeInformation;
3837
import org.springframework.data.util.TypeInformation;
3938
import org.springframework.util.Assert;
4039

@@ -383,7 +382,7 @@ public static StringBasedN1qlQueryParser.N1qlSpelValues getN1qlSpelValues(Couchb
383382
.getRequiredPersistentEntity(domainClass);
384383
MappingCouchbaseEntityInformation<?, Object> info = new MappingCouchbaseEntityInformation<>(persistentEntity);
385384
String typeValue = info.getJavaType().getName();
386-
TypeInformation<?> typeInfo = ClassTypeInformation.from(info.getJavaType());
385+
TypeInformation<?> typeInfo = TypeInformation.of(info.getJavaType());
387386
Alias alias = converter.getTypeAlias(typeInfo);
388387
if (alias != null && alias.isPresent()) {
389388
typeValue = alias.toString();

src/main/java/org/springframework/data/couchbase/core/query/StringQuery.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import org.springframework.data.mapping.Alias;
2727
import org.springframework.data.repository.query.ParameterAccessor;
2828
import org.springframework.data.repository.query.QueryMethodEvaluationContextProvider;
29-
import org.springframework.data.util.ClassTypeInformation;
3029
import org.springframework.data.util.TypeInformation;
3130
import org.springframework.expression.spel.standard.SpelExpressionParser;
3231

@@ -118,7 +117,7 @@ private StringBasedN1qlQueryParser getStringN1qlQueryParser(CouchbaseConverter c
118117
.getRequiredPersistentEntity(domainClass);
119118
MappingCouchbaseEntityInformation<?, Object> info = new MappingCouchbaseEntityInformation<>(persistentEntity);
120119
String typeValue = info.getJavaType().getName();
121-
TypeInformation<?> typeInfo = ClassTypeInformation.from(info.getJavaType());
120+
TypeInformation<?> typeInfo = TypeInformation.of(info.getJavaType());
122121
Alias alias = converter.getTypeAlias(typeInfo);
123122
if (alias != null && alias.isPresent()) {
124123
typeValue = alias.toString();

src/main/java/org/springframework/data/couchbase/repository/query/AbstractCouchbaseQueryBase.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import org.springframework.data.repository.query.QueryMethodEvaluationContextProvider;
3030
import org.springframework.data.repository.query.RepositoryQuery;
3131
import org.springframework.data.repository.query.ResultProcessor;
32-
import org.springframework.data.util.ClassTypeInformation;
3332
import org.springframework.data.util.TypeInformation;
3433
import org.springframework.expression.spel.standard.SpelExpressionParser;
3534
import org.springframework.lang.Nullable;
@@ -122,8 +121,8 @@ private Publisher<Object> executeDeferred(ReactiveCouchbaseParameterAccessor par
122121
}
123122

124123
private Object execute(ParametersParameterAccessor parameterAccessor) {
125-
TypeInformation<?> returnType = ClassTypeInformation
126-
.from(method.getResultProcessor().getReturnedType().getReturnedType());
124+
TypeInformation<?> returnType = TypeInformation
125+
.of(method.getResultProcessor().getReturnedType().getReturnedType());
127126
ResultProcessor processor = method.getResultProcessor().withDynamicProjection(parameterAccessor);
128127
Class<?> typeToRead = processor.getReturnedType().getTypeToRead();
129128

src/test/java/org/springframework/data/couchbase/core/mapping/BasicCouchbasePersistentEntityTests.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import org.springframework.beans.factory.annotation.Autowired;
2929
import org.springframework.context.annotation.Configuration;
3030
import org.springframework.core.env.ConfigurableEnvironment;
31-
import org.springframework.data.util.ClassTypeInformation;
31+
import org.springframework.data.util.TypeInformation;
3232
import org.springframework.mock.env.MockPropertySource;
3333
import org.springframework.test.context.TestPropertySource;
3434
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
@@ -43,30 +43,30 @@ public class BasicCouchbasePersistentEntityTests {
4343
@Test
4444
void testNoExpiryByDefault() {
4545
CouchbasePersistentEntity<DefaultExpiry> entity = new BasicCouchbasePersistentEntity<>(
46-
ClassTypeInformation.from(DefaultExpiry.class));
46+
TypeInformation.of(DefaultExpiry.class));
4747

4848
assertThat(entity.getExpiryDuration().getSeconds()).isEqualTo(0);
4949
}
5050

5151
@Test
5252
void testDefaultExpiryUnitIsSeconds() {
5353
CouchbasePersistentEntity<DefaultExpiryUnit> entity = new BasicCouchbasePersistentEntity<>(
54-
ClassTypeInformation.from(DefaultExpiryUnit.class));
54+
TypeInformation.of(DefaultExpiryUnit.class));
5555

5656
assertThat(entity.getExpiryDuration().getSeconds()).isEqualTo(78);
5757
}
5858

5959
@Test
6060
void testLargeExpiry30DaysStillInSeconds() {
6161
CouchbasePersistentEntity<LimitDaysExpiry> entityUnder = new BasicCouchbasePersistentEntity<>(
62-
ClassTypeInformation.from(LimitDaysExpiry.class));
62+
TypeInformation.of(LimitDaysExpiry.class));
6363
assertThat(entityUnder.getExpiryDuration().getSeconds()).isEqualTo(30 * 24 * 60 * 60);
6464
}
6565

6666
@Test
6767
void testLargeExpiry31DaysIsConvertedToUnixUtcTime() {
6868
CouchbasePersistentEntity<OverLimitDaysExpiry> entityOver = new BasicCouchbasePersistentEntity<>(
69-
ClassTypeInformation.from(OverLimitDaysExpiry.class));
69+
TypeInformation.of(OverLimitDaysExpiry.class));
7070

7171
int expiryOver = (int) entityOver.getExpiry();
7272
Calendar expected = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
@@ -86,7 +86,7 @@ void testLargeExpiry31DaysIsConvertedToUnixUtcTime() {
8686
@Test
8787
void testLargeExpiryExpression31DaysIsConvertedToUnixUtcTime() {
8888
BasicCouchbasePersistentEntity<OverLimitDaysExpiryExpression> entityOver = new BasicCouchbasePersistentEntity<>(
89-
ClassTypeInformation.from(OverLimitDaysExpiryExpression.class));
89+
TypeInformation.of(OverLimitDaysExpiryExpression.class));
9090
entityOver.setEnvironment(environment);
9191

9292
int expiryOver = (int) entityOver.getExpiry();
@@ -107,7 +107,7 @@ void testLargeExpiryExpression31DaysIsConvertedToUnixUtcTime() {
107107
@Test
108108
void testLargeExpiry31DaysInSecondsIsConvertedToUnixUtcTime() {
109109
CouchbasePersistentEntity<OverLimitSecondsExpiry> entityOver = new BasicCouchbasePersistentEntity<>(
110-
ClassTypeInformation.from(OverLimitSecondsExpiry.class));
110+
TypeInformation.of(OverLimitSecondsExpiry.class));
111111

112112
int expiryOver = (int) entityOver.getExpiry();
113113
Calendar expected = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
@@ -212,7 +212,7 @@ void usesGetDurabilityFromValidExpression() {
212212

213213
private BasicCouchbasePersistentEntity getBasicCouchbasePersistentEntity(Class<?> clazz) {
214214
BasicCouchbasePersistentEntity basicCouchbasePersistentEntity = new BasicCouchbasePersistentEntity(
215-
ClassTypeInformation.from(clazz));
215+
TypeInformation.of(clazz));
216216
basicCouchbasePersistentEntity.setEnvironment(environment);
217217
return basicCouchbasePersistentEntity;
218218
}

src/test/java/org/springframework/data/couchbase/core/mapping/BasicCouchbasePersistentPropertyTests.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
import org.springframework.data.mapping.model.Property;
2828
import org.springframework.data.mapping.model.PropertyNameFieldNamingStrategy;
2929
import org.springframework.data.mapping.model.SimpleTypeHolder;
30-
import org.springframework.data.util.ClassTypeInformation;
30+
import org.springframework.data.util.TypeInformation;
3131
import org.springframework.util.ReflectionUtils;
3232

3333
/**
@@ -48,7 +48,7 @@ public class BasicCouchbasePersistentPropertyTests {
4848
*/
4949
@BeforeEach
5050
void beforeEach() {
51-
entity = new BasicCouchbasePersistentEntity<>(ClassTypeInformation.from(Beer.class));
51+
entity = new BasicCouchbasePersistentEntity<>(TypeInformation.of(Beer.class));
5252
}
5353

5454
/**
@@ -72,7 +72,7 @@ void usesAnnotatedFieldName() {
7272
@Test
7373
void testSdkIdAnnotationEvaluatedAfterSpringIdAnnotationIsIgnored() {
7474
BasicCouchbasePersistentEntity<Beer> test = new BasicCouchbasePersistentEntity<>(
75-
ClassTypeInformation.from(Beer.class));
75+
TypeInformation.of(Beer.class));
7676
Field springIdField = ReflectionUtils.findField(Beer.class, "springId");
7777
CouchbasePersistentProperty springIdProperty = getPropertyFor(springIdField);
7878

@@ -91,7 +91,7 @@ class TestIdField {
9191
@Id private String springId;
9292
}
9393
BasicCouchbasePersistentEntity<TestIdField> test = new BasicCouchbasePersistentEntity<>(
94-
ClassTypeInformation.from(TestIdField.class));
94+
TypeInformation.of(TestIdField.class));
9595
Field springIdField = ReflectionUtils.findField(TestIdField.class, "springId");
9696
CouchbasePersistentProperty springIdProperty = getPropertyFor(springIdField);
9797
test.addPersistentProperty(springIdProperty);
@@ -108,7 +108,7 @@ class TestIdField {
108108
Field idField = ReflectionUtils.findField(TestIdField.class, "id");
109109
CouchbasePersistentProperty idProperty = getPropertyFor(idField);
110110
BasicCouchbasePersistentEntity<TestIdField> test = new BasicCouchbasePersistentEntity<>(
111-
ClassTypeInformation.from(TestIdField.class));
111+
TypeInformation.of(TestIdField.class));
112112
test.addPersistentProperty(idProperty);
113113
assertThat(test.getIdProperty()).isEqualTo(idProperty);
114114
}
@@ -122,7 +122,7 @@ class TestIdField {
122122
private String id;
123123
}
124124
BasicCouchbasePersistentEntity<TestIdField> test = new BasicCouchbasePersistentEntity<>(
125-
ClassTypeInformation.from(TestIdField.class));
125+
TypeInformation.of(TestIdField.class));
126126
Field springIdField = ReflectionUtils.findField(TestIdField.class, "springId");
127127
Field idField = ReflectionUtils.findField(TestIdField.class, "id");
128128
CouchbasePersistentProperty idProperty = getPropertyFor(idField);
@@ -148,7 +148,7 @@ class TestIdField {
148148
CouchbasePersistentProperty idProperty = getPropertyFor(idField);
149149
CouchbasePersistentProperty springIdProperty = getPropertyFor(springIdField);
150150
BasicCouchbasePersistentEntity<TestIdField> test = new BasicCouchbasePersistentEntity<>(
151-
ClassTypeInformation.from(TestIdField.class));
151+
TypeInformation.of(TestIdField.class));
152152
test.addPersistentProperty(springIdProperty);
153153
assertThatExceptionOfType(MappingException.class).isThrownBy(() -> {
154154
test.addPersistentProperty(idProperty);
@@ -168,7 +168,7 @@ class TestIdField {
168168
CouchbasePersistentProperty idProperty = getPropertyFor(idField);
169169
CouchbasePersistentProperty springIdProperty = getPropertyFor(springIdField);
170170
BasicCouchbasePersistentEntity<TestIdField> test = new BasicCouchbasePersistentEntity<>(
171-
ClassTypeInformation.from(TestIdField.class));
171+
TypeInformation.of(TestIdField.class));
172172
test.addPersistentProperty(springIdProperty);
173173
assertThatExceptionOfType(MappingException.class).isThrownBy(() -> {
174174
test.addPersistentProperty(idProperty);
@@ -183,7 +183,7 @@ class TestIdField {
183183
*/
184184
private CouchbasePersistentProperty getPropertyFor(Field field) {
185185

186-
ClassTypeInformation<?> type = ClassTypeInformation.from(field.getDeclaringClass());
186+
TypeInformation<?> type = TypeInformation.of(field.getDeclaringClass());
187187

188188
return new BasicCouchbasePersistentProperty(Property.of(type, field), entity, SimpleTypeHolder.DEFAULT,
189189
PropertyNameFieldNamingStrategy.INSTANCE);

0 commit comments

Comments
 (0)