diff --git a/src/main/java/org/springframework/data/couchbase/core/convert/AbstractCouchbaseConverter.java b/src/main/java/org/springframework/data/couchbase/core/convert/AbstractCouchbaseConverter.java index ff35edc59..373272e8e 100644 --- a/src/main/java/org/springframework/data/couchbase/core/convert/AbstractCouchbaseConverter.java +++ b/src/main/java/org/springframework/data/couchbase/core/convert/AbstractCouchbaseConverter.java @@ -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; /** @@ -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; } diff --git a/src/main/java/org/springframework/data/couchbase/core/convert/MappingCouchbaseConverter.java b/src/main/java/org/springframework/data/couchbase/core/convert/MappingCouchbaseConverter.java index ee1843fcb..819e34a74 100644 --- a/src/main/java/org/springframework/data/couchbase/core/convert/MappingCouchbaseConverter.java +++ b/src/main/java/org/springframework/data/couchbase/core/convert/MappingCouchbaseConverter.java @@ -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; @@ -206,7 +205,7 @@ public Alias getTypeAlias(TypeInformation info) { @Override public R read(final Class clazz, final CouchbaseDocument source) { - return read(ClassTypeInformation.from(clazz), source, null); + return read(TypeInformation.of(clazz), source, null); } /** @@ -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); @@ -472,7 +471,7 @@ public void writeInternalRoot(final Object source, CouchbaseDocument target, Typ } if (Map.class.isAssignableFrom(source.getClass())) { - writeMapInternal((Map) source, target, ClassTypeInformation.MAP, property); + writeMapInternal((Map) source, target, TypeInformation.MAP, property); return; } @@ -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); @@ -968,7 +967,7 @@ public 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) { diff --git a/src/main/java/org/springframework/data/couchbase/core/index/QueryIndexResolver.java b/src/main/java/org/springframework/data/couchbase/core/index/QueryIndexResolver.java index fad6d6efc..f0153ee3b 100644 --- a/src/main/java/org/springframework/data/couchbase/core/index/QueryIndexResolver.java +++ b/src/main/java/org/springframework/data/couchbase/core/index/QueryIndexResolver.java @@ -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; @@ -66,7 +65,7 @@ static QueryIndexResolver create( * @see 2.2 */ default Iterable resolveIndexFor(Class entityType) { - return resolveIndexFor(ClassTypeInformation.from(entityType)); + return resolveIndexFor(TypeInformation.of(entityType)); } } diff --git a/src/main/java/org/springframework/data/couchbase/core/query/Query.java b/src/main/java/org/springframework/data/couchbase/core/query/Query.java index 59da4a487..c916d7ef1 100644 --- a/src/main/java/org/springframework/data/couchbase/core/query/Query.java +++ b/src/main/java/org/springframework/data/couchbase/core/query/Query.java @@ -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; @@ -383,7 +382,7 @@ public static StringBasedN1qlQueryParser.N1qlSpelValues getN1qlSpelValues(Couchb .getRequiredPersistentEntity(domainClass); MappingCouchbaseEntityInformation 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(); diff --git a/src/main/java/org/springframework/data/couchbase/core/query/StringQuery.java b/src/main/java/org/springframework/data/couchbase/core/query/StringQuery.java index b90dc32d6..92ff962e1 100644 --- a/src/main/java/org/springframework/data/couchbase/core/query/StringQuery.java +++ b/src/main/java/org/springframework/data/couchbase/core/query/StringQuery.java @@ -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; @@ -118,7 +117,7 @@ private StringBasedN1qlQueryParser getStringN1qlQueryParser(CouchbaseConverter c .getRequiredPersistentEntity(domainClass); MappingCouchbaseEntityInformation 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(); diff --git a/src/main/java/org/springframework/data/couchbase/repository/query/AbstractCouchbaseQueryBase.java b/src/main/java/org/springframework/data/couchbase/repository/query/AbstractCouchbaseQueryBase.java index f8cfd670b..d418de9ba 100644 --- a/src/main/java/org/springframework/data/couchbase/repository/query/AbstractCouchbaseQueryBase.java +++ b/src/main/java/org/springframework/data/couchbase/repository/query/AbstractCouchbaseQueryBase.java @@ -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; @@ -122,8 +121,8 @@ private Publisher 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(); diff --git a/src/test/java/org/springframework/data/couchbase/core/mapping/BasicCouchbasePersistentEntityTests.java b/src/test/java/org/springframework/data/couchbase/core/mapping/BasicCouchbasePersistentEntityTests.java index ce31e24ef..5433b3d29 100644 --- a/src/test/java/org/springframework/data/couchbase/core/mapping/BasicCouchbasePersistentEntityTests.java +++ b/src/test/java/org/springframework/data/couchbase/core/mapping/BasicCouchbasePersistentEntityTests.java @@ -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; @@ -43,7 +43,7 @@ public class BasicCouchbasePersistentEntityTests { @Test void testNoExpiryByDefault() { CouchbasePersistentEntity entity = new BasicCouchbasePersistentEntity<>( - ClassTypeInformation.from(DefaultExpiry.class)); + TypeInformation.of(DefaultExpiry.class)); assertThat(entity.getExpiryDuration().getSeconds()).isEqualTo(0); } @@ -51,7 +51,7 @@ void testNoExpiryByDefault() { @Test void testDefaultExpiryUnitIsSeconds() { CouchbasePersistentEntity entity = new BasicCouchbasePersistentEntity<>( - ClassTypeInformation.from(DefaultExpiryUnit.class)); + TypeInformation.of(DefaultExpiryUnit.class)); assertThat(entity.getExpiryDuration().getSeconds()).isEqualTo(78); } @@ -59,14 +59,14 @@ void testDefaultExpiryUnitIsSeconds() { @Test void testLargeExpiry30DaysStillInSeconds() { CouchbasePersistentEntity entityUnder = new BasicCouchbasePersistentEntity<>( - ClassTypeInformation.from(LimitDaysExpiry.class)); + TypeInformation.of(LimitDaysExpiry.class)); assertThat(entityUnder.getExpiryDuration().getSeconds()).isEqualTo(30 * 24 * 60 * 60); } @Test void testLargeExpiry31DaysIsConvertedToUnixUtcTime() { CouchbasePersistentEntity entityOver = new BasicCouchbasePersistentEntity<>( - ClassTypeInformation.from(OverLimitDaysExpiry.class)); + TypeInformation.of(OverLimitDaysExpiry.class)); int expiryOver = (int) entityOver.getExpiry(); Calendar expected = Calendar.getInstance(TimeZone.getTimeZone("UTC")); @@ -86,7 +86,7 @@ void testLargeExpiry31DaysIsConvertedToUnixUtcTime() { @Test void testLargeExpiryExpression31DaysIsConvertedToUnixUtcTime() { BasicCouchbasePersistentEntity entityOver = new BasicCouchbasePersistentEntity<>( - ClassTypeInformation.from(OverLimitDaysExpiryExpression.class)); + TypeInformation.of(OverLimitDaysExpiryExpression.class)); entityOver.setEnvironment(environment); int expiryOver = (int) entityOver.getExpiry(); @@ -107,7 +107,7 @@ void testLargeExpiryExpression31DaysIsConvertedToUnixUtcTime() { @Test void testLargeExpiry31DaysInSecondsIsConvertedToUnixUtcTime() { CouchbasePersistentEntity entityOver = new BasicCouchbasePersistentEntity<>( - ClassTypeInformation.from(OverLimitSecondsExpiry.class)); + TypeInformation.of(OverLimitSecondsExpiry.class)); int expiryOver = (int) entityOver.getExpiry(); Calendar expected = Calendar.getInstance(TimeZone.getTimeZone("UTC")); @@ -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; } diff --git a/src/test/java/org/springframework/data/couchbase/core/mapping/BasicCouchbasePersistentPropertyTests.java b/src/test/java/org/springframework/data/couchbase/core/mapping/BasicCouchbasePersistentPropertyTests.java index 787c0a789..b9a692ef1 100644 --- a/src/test/java/org/springframework/data/couchbase/core/mapping/BasicCouchbasePersistentPropertyTests.java +++ b/src/test/java/org/springframework/data/couchbase/core/mapping/BasicCouchbasePersistentPropertyTests.java @@ -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; /** @@ -48,7 +48,7 @@ public class BasicCouchbasePersistentPropertyTests { */ @BeforeEach void beforeEach() { - entity = new BasicCouchbasePersistentEntity<>(ClassTypeInformation.from(Beer.class)); + entity = new BasicCouchbasePersistentEntity<>(TypeInformation.of(Beer.class)); } /** @@ -72,7 +72,7 @@ void usesAnnotatedFieldName() { @Test void testSdkIdAnnotationEvaluatedAfterSpringIdAnnotationIsIgnored() { BasicCouchbasePersistentEntity test = new BasicCouchbasePersistentEntity<>( - ClassTypeInformation.from(Beer.class)); + TypeInformation.of(Beer.class)); Field springIdField = ReflectionUtils.findField(Beer.class, "springId"); CouchbasePersistentProperty springIdProperty = getPropertyFor(springIdField); @@ -91,7 +91,7 @@ class TestIdField { @Id private String springId; } BasicCouchbasePersistentEntity 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); @@ -108,7 +108,7 @@ class TestIdField { Field idField = ReflectionUtils.findField(TestIdField.class, "id"); CouchbasePersistentProperty idProperty = getPropertyFor(idField); BasicCouchbasePersistentEntity test = new BasicCouchbasePersistentEntity<>( - ClassTypeInformation.from(TestIdField.class)); + TypeInformation.of(TestIdField.class)); test.addPersistentProperty(idProperty); assertThat(test.getIdProperty()).isEqualTo(idProperty); } @@ -122,7 +122,7 @@ class TestIdField { private String id; } BasicCouchbasePersistentEntity 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); @@ -148,7 +148,7 @@ class TestIdField { CouchbasePersistentProperty idProperty = getPropertyFor(idField); CouchbasePersistentProperty springIdProperty = getPropertyFor(springIdField); BasicCouchbasePersistentEntity test = new BasicCouchbasePersistentEntity<>( - ClassTypeInformation.from(TestIdField.class)); + TypeInformation.of(TestIdField.class)); test.addPersistentProperty(springIdProperty); assertThatExceptionOfType(MappingException.class).isThrownBy(() -> { test.addPersistentProperty(idProperty); @@ -168,7 +168,7 @@ class TestIdField { CouchbasePersistentProperty idProperty = getPropertyFor(idField); CouchbasePersistentProperty springIdProperty = getPropertyFor(springIdField); BasicCouchbasePersistentEntity test = new BasicCouchbasePersistentEntity<>( - ClassTypeInformation.from(TestIdField.class)); + TypeInformation.of(TestIdField.class)); test.addPersistentProperty(springIdProperty); assertThatExceptionOfType(MappingException.class).isThrownBy(() -> { test.addPersistentProperty(idProperty); @@ -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);