Skip to content

ClassTypeInformation is now deprecated. #1735

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.springframework.data.couchbase.core.mapping.CouchbasePersistentProperty;
import org.springframework.data.mapping.model.ConvertingPropertyAccessor;
import org.springframework.data.mapping.model.EntityInstantiators;
import org.springframework.data.util.ClassTypeInformation;
import org.springframework.data.util.TypeInformation;

/**
Expand Down Expand Up @@ -163,12 +162,12 @@ public Object convertForWriteIfNeeded(Object inValue) {
// superseded by EnumCvtrs value = Enum.class.isAssignableFrom(value.getClass()) ? ((Enum<?>) value).name() :
// value;
} else if (value instanceof Collection || elementType.isArray()) {
TypeInformation<?> type = ClassTypeInformation.from(value.getClass());
TypeInformation<?> type = TypeInformation.of(value.getClass());
value = ((MappingCouchbaseConverter) this).writeCollectionInternal(MappingCouchbaseConverter.asCollection(value),
new CouchbaseList(conversions.getSimpleTypeHolder()), type, null, null);
} else {
CouchbaseDocument embeddedDoc = new CouchbaseDocument();
TypeInformation<?> type = ClassTypeInformation.from(value.getClass());
TypeInformation<?> type = TypeInformation.of(value.getClass());
((MappingCouchbaseConverter) this).writeInternalRoot(value, embeddedDoc, type, false, null, true);
value = embeddedDoc;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
import org.springframework.data.mapping.model.SpELContext;
import org.springframework.data.mapping.model.SpELExpressionEvaluator;
import org.springframework.data.mapping.model.SpELExpressionParameterValueProvider;
import org.springframework.data.util.ClassTypeInformation;
import org.springframework.data.util.TypeInformation;
import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
Expand Down Expand Up @@ -206,7 +205,7 @@ public Alias getTypeAlias(TypeInformation<?> info) {

@Override
public <R> R read(final Class<R> clazz, final CouchbaseDocument source) {
return read(ClassTypeInformation.from(clazz), source, null);
return read(TypeInformation.of(clazz), source, null);
}

/**
Expand Down Expand Up @@ -438,7 +437,7 @@ public void write(final Object source, final CouchbaseDocument target) {
}

boolean isCustom = conversions.getCustomWriteTarget(source.getClass(), CouchbaseDocument.class).isPresent();
TypeInformation<?> type = ClassTypeInformation.from(source.getClass());
TypeInformation<?> type = TypeInformation.of(source.getClass());

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

if (Map.class.isAssignableFrom(source.getClass())) {
writeMapInternal((Map<Object, Object>) source, target, ClassTypeInformation.MAP, property);
writeMapInternal((Map<Object, Object>) source, target, TypeInformation.MAP, property);
return;
}

Expand Down Expand Up @@ -639,7 +638,7 @@ protected void writePropertyInternal(final Object source, final CouchbaseDocumen
}

String name = prop.getFieldName();
TypeInformation<?> valueType = ClassTypeInformation.from(source.getClass());
TypeInformation<?> valueType = TypeInformation.of(source.getClass());
TypeInformation<?> type = prop.getTypeInformation();
if (valueType.isCollectionLike()) {
CouchbaseList collectionDoc = createCollection(asCollection(source), valueType, prop, accessor);
Expand Down Expand Up @@ -968,7 +967,7 @@ public <R> R readValue(Object value, CouchbasePersistentProperty prop, Object pa
}
}
if (conversions.hasCustomReadTarget(value.getClass(), rawType)) {
TypeInformation ti = ClassTypeInformation.from(value.getClass());
TypeInformation ti = TypeInformation.of(value.getClass());
return (R) conversionService.convert(value, ti.toTypeDescriptor(), new TypeDescriptor(prop.getField()));
}
if (value instanceof CouchbaseDocument) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import org.springframework.data.couchbase.core.mapping.CouchbasePersistentEntity;
import org.springframework.data.couchbase.core.mapping.CouchbasePersistentProperty;
import org.springframework.data.mapping.context.MappingContext;
import org.springframework.data.util.ClassTypeInformation;
import org.springframework.data.util.TypeInformation;
import org.springframework.util.Assert;

Expand Down Expand Up @@ -66,7 +65,7 @@ static QueryIndexResolver create(
* @see 2.2
*/
default Iterable<? extends IndexDefinition> resolveIndexFor(Class<?> entityType) {
return resolveIndexFor(ClassTypeInformation.from(entityType));
return resolveIndexFor(TypeInformation.of(entityType));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.mapping.Alias;
import org.springframework.data.util.ClassTypeInformation;
import org.springframework.data.util.TypeInformation;
import org.springframework.util.Assert;

Expand Down Expand Up @@ -383,7 +382,7 @@ public static StringBasedN1qlQueryParser.N1qlSpelValues getN1qlSpelValues(Couchb
.getRequiredPersistentEntity(domainClass);
MappingCouchbaseEntityInformation<?, Object> info = new MappingCouchbaseEntityInformation<>(persistentEntity);
String typeValue = info.getJavaType().getName();
TypeInformation<?> typeInfo = ClassTypeInformation.from(info.getJavaType());
TypeInformation<?> typeInfo = TypeInformation.of(info.getJavaType());
Alias alias = converter.getTypeAlias(typeInfo);
if (alias != null && alias.isPresent()) {
typeValue = alias.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.springframework.data.mapping.Alias;
import org.springframework.data.repository.query.ParameterAccessor;
import org.springframework.data.repository.query.QueryMethodEvaluationContextProvider;
import org.springframework.data.util.ClassTypeInformation;
import org.springframework.data.util.TypeInformation;
import org.springframework.expression.spel.standard.SpelExpressionParser;

Expand Down Expand Up @@ -118,7 +117,7 @@ private StringBasedN1qlQueryParser getStringN1qlQueryParser(CouchbaseConverter c
.getRequiredPersistentEntity(domainClass);
MappingCouchbaseEntityInformation<?, Object> info = new MappingCouchbaseEntityInformation<>(persistentEntity);
String typeValue = info.getJavaType().getName();
TypeInformation<?> typeInfo = ClassTypeInformation.from(info.getJavaType());
TypeInformation<?> typeInfo = TypeInformation.of(info.getJavaType());
Alias alias = converter.getTypeAlias(typeInfo);
if (alias != null && alias.isPresent()) {
typeValue = alias.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.springframework.data.repository.query.QueryMethodEvaluationContextProvider;
import org.springframework.data.repository.query.RepositoryQuery;
import org.springframework.data.repository.query.ResultProcessor;
import org.springframework.data.util.ClassTypeInformation;
import org.springframework.data.util.TypeInformation;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.lang.Nullable;
Expand Down Expand Up @@ -122,8 +121,8 @@ private Publisher<Object> executeDeferred(ReactiveCouchbaseParameterAccessor par
}

private Object execute(ParametersParameterAccessor parameterAccessor) {
TypeInformation<?> returnType = ClassTypeInformation
.from(method.getResultProcessor().getReturnedType().getReturnedType());
TypeInformation<?> returnType = TypeInformation
.of(method.getResultProcessor().getReturnedType().getReturnedType());
ResultProcessor processor = method.getResultProcessor().withDynamicProjection(parameterAccessor);
Class<?> typeToRead = processor.getReturnedType().getTypeToRead();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.data.util.ClassTypeInformation;
import org.springframework.data.util.TypeInformation;
import org.springframework.mock.env.MockPropertySource;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
Expand All @@ -43,30 +43,30 @@ public class BasicCouchbasePersistentEntityTests {
@Test
void testNoExpiryByDefault() {
CouchbasePersistentEntity<DefaultExpiry> entity = new BasicCouchbasePersistentEntity<>(
ClassTypeInformation.from(DefaultExpiry.class));
TypeInformation.of(DefaultExpiry.class));

assertThat(entity.getExpiryDuration().getSeconds()).isEqualTo(0);
}

@Test
void testDefaultExpiryUnitIsSeconds() {
CouchbasePersistentEntity<DefaultExpiryUnit> entity = new BasicCouchbasePersistentEntity<>(
ClassTypeInformation.from(DefaultExpiryUnit.class));
TypeInformation.of(DefaultExpiryUnit.class));

assertThat(entity.getExpiryDuration().getSeconds()).isEqualTo(78);
}

@Test
void testLargeExpiry30DaysStillInSeconds() {
CouchbasePersistentEntity<LimitDaysExpiry> entityUnder = new BasicCouchbasePersistentEntity<>(
ClassTypeInformation.from(LimitDaysExpiry.class));
TypeInformation.of(LimitDaysExpiry.class));
assertThat(entityUnder.getExpiryDuration().getSeconds()).isEqualTo(30 * 24 * 60 * 60);
}

@Test
void testLargeExpiry31DaysIsConvertedToUnixUtcTime() {
CouchbasePersistentEntity<OverLimitDaysExpiry> entityOver = new BasicCouchbasePersistentEntity<>(
ClassTypeInformation.from(OverLimitDaysExpiry.class));
TypeInformation.of(OverLimitDaysExpiry.class));

int expiryOver = (int) entityOver.getExpiry();
Calendar expected = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
Expand All @@ -86,7 +86,7 @@ void testLargeExpiry31DaysIsConvertedToUnixUtcTime() {
@Test
void testLargeExpiryExpression31DaysIsConvertedToUnixUtcTime() {
BasicCouchbasePersistentEntity<OverLimitDaysExpiryExpression> entityOver = new BasicCouchbasePersistentEntity<>(
ClassTypeInformation.from(OverLimitDaysExpiryExpression.class));
TypeInformation.of(OverLimitDaysExpiryExpression.class));
entityOver.setEnvironment(environment);

int expiryOver = (int) entityOver.getExpiry();
Expand All @@ -107,7 +107,7 @@ void testLargeExpiryExpression31DaysIsConvertedToUnixUtcTime() {
@Test
void testLargeExpiry31DaysInSecondsIsConvertedToUnixUtcTime() {
CouchbasePersistentEntity<OverLimitSecondsExpiry> entityOver = new BasicCouchbasePersistentEntity<>(
ClassTypeInformation.from(OverLimitSecondsExpiry.class));
TypeInformation.of(OverLimitSecondsExpiry.class));

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

private BasicCouchbasePersistentEntity getBasicCouchbasePersistentEntity(Class<?> clazz) {
BasicCouchbasePersistentEntity basicCouchbasePersistentEntity = new BasicCouchbasePersistentEntity(
ClassTypeInformation.from(clazz));
TypeInformation.of(clazz));
basicCouchbasePersistentEntity.setEnvironment(environment);
return basicCouchbasePersistentEntity;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import org.springframework.data.mapping.model.Property;
import org.springframework.data.mapping.model.PropertyNameFieldNamingStrategy;
import org.springframework.data.mapping.model.SimpleTypeHolder;
import org.springframework.data.util.ClassTypeInformation;
import org.springframework.data.util.TypeInformation;
import org.springframework.util.ReflectionUtils;

/**
Expand All @@ -48,7 +48,7 @@ public class BasicCouchbasePersistentPropertyTests {
*/
@BeforeEach
void beforeEach() {
entity = new BasicCouchbasePersistentEntity<>(ClassTypeInformation.from(Beer.class));
entity = new BasicCouchbasePersistentEntity<>(TypeInformation.of(Beer.class));
}

/**
Expand All @@ -72,7 +72,7 @@ void usesAnnotatedFieldName() {
@Test
void testSdkIdAnnotationEvaluatedAfterSpringIdAnnotationIsIgnored() {
BasicCouchbasePersistentEntity<Beer> test = new BasicCouchbasePersistentEntity<>(
ClassTypeInformation.from(Beer.class));
TypeInformation.of(Beer.class));
Field springIdField = ReflectionUtils.findField(Beer.class, "springId");
CouchbasePersistentProperty springIdProperty = getPropertyFor(springIdField);

Expand All @@ -91,7 +91,7 @@ class TestIdField {
@Id private String springId;
}
BasicCouchbasePersistentEntity<TestIdField> test = new BasicCouchbasePersistentEntity<>(
ClassTypeInformation.from(TestIdField.class));
TypeInformation.of(TestIdField.class));
Field springIdField = ReflectionUtils.findField(TestIdField.class, "springId");
CouchbasePersistentProperty springIdProperty = getPropertyFor(springIdField);
test.addPersistentProperty(springIdProperty);
Expand All @@ -108,7 +108,7 @@ class TestIdField {
Field idField = ReflectionUtils.findField(TestIdField.class, "id");
CouchbasePersistentProperty idProperty = getPropertyFor(idField);
BasicCouchbasePersistentEntity<TestIdField> test = new BasicCouchbasePersistentEntity<>(
ClassTypeInformation.from(TestIdField.class));
TypeInformation.of(TestIdField.class));
test.addPersistentProperty(idProperty);
assertThat(test.getIdProperty()).isEqualTo(idProperty);
}
Expand All @@ -122,7 +122,7 @@ class TestIdField {
private String id;
}
BasicCouchbasePersistentEntity<TestIdField> test = new BasicCouchbasePersistentEntity<>(
ClassTypeInformation.from(TestIdField.class));
TypeInformation.of(TestIdField.class));
Field springIdField = ReflectionUtils.findField(TestIdField.class, "springId");
Field idField = ReflectionUtils.findField(TestIdField.class, "id");
CouchbasePersistentProperty idProperty = getPropertyFor(idField);
Expand All @@ -148,7 +148,7 @@ class TestIdField {
CouchbasePersistentProperty idProperty = getPropertyFor(idField);
CouchbasePersistentProperty springIdProperty = getPropertyFor(springIdField);
BasicCouchbasePersistentEntity<TestIdField> test = new BasicCouchbasePersistentEntity<>(
ClassTypeInformation.from(TestIdField.class));
TypeInformation.of(TestIdField.class));
test.addPersistentProperty(springIdProperty);
assertThatExceptionOfType(MappingException.class).isThrownBy(() -> {
test.addPersistentProperty(idProperty);
Expand All @@ -168,7 +168,7 @@ class TestIdField {
CouchbasePersistentProperty idProperty = getPropertyFor(idField);
CouchbasePersistentProperty springIdProperty = getPropertyFor(springIdField);
BasicCouchbasePersistentEntity<TestIdField> test = new BasicCouchbasePersistentEntity<>(
ClassTypeInformation.from(TestIdField.class));
TypeInformation.of(TestIdField.class));
test.addPersistentProperty(springIdProperty);
assertThatExceptionOfType(MappingException.class).isThrownBy(() -> {
test.addPersistentProperty(idProperty);
Expand All @@ -183,7 +183,7 @@ class TestIdField {
*/
private CouchbasePersistentProperty getPropertyFor(Field field) {

ClassTypeInformation<?> type = ClassTypeInformation.from(field.getDeclaringClass());
TypeInformation<?> type = TypeInformation.of(field.getDeclaringClass());

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