Skip to content

Commit f8e5607

Browse files
committed
Remove references to ClassTypeInformation from TypeInformation.
Closes #1314
1 parent b8bd4f1 commit f8e5607

16 files changed

+66
-69
lines changed

spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/convert/ColumnType.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616
package org.springframework.data.cassandra.core.convert;
1717

18-
import org.springframework.data.util.ClassTypeInformation;
1918
import org.springframework.data.util.TypeInformation;
2019
import org.springframework.lang.Nullable;
2120

@@ -42,7 +41,7 @@ public interface ColumnType {
4241
* @return
4342
*/
4443
static ColumnType create(Class<?> type) {
45-
return create(ClassTypeInformation.from(type));
44+
return create(TypeInformation.of(type));
4645
}
4746

4847
/**
@@ -63,7 +62,7 @@ static ColumnType create(TypeInformation<?> type) {
6362
* @return
6463
*/
6564
static CassandraColumnType create(Class<?> type, DataType dataType) {
66-
return new DefaultCassandraColumnType(ClassTypeInformation.from(type), dataType);
65+
return new DefaultCassandraColumnType(TypeInformation.of(type), dataType);
6766
}
6867

6968
/**
@@ -78,7 +77,7 @@ static ColumnType listOf(ColumnType componentType) {
7877
return listOf((CassandraColumnType) componentType);
7978
}
8079

81-
return new DefaultColumnType(ClassTypeInformation.LIST, componentType);
80+
return new DefaultColumnType(TypeInformation.LIST, componentType);
8281
}
8382

8483
/**
@@ -99,7 +98,7 @@ static CassandraColumnType listOf(CassandraColumnType componentType) {
9998
* @return
10099
*/
101100
static CassandraColumnType listOf(CassandraColumnType componentType, boolean frozen) {
102-
return new DefaultCassandraColumnType(ClassTypeInformation.LIST,
101+
return new DefaultCassandraColumnType(TypeInformation.LIST,
103102
() -> DataTypes.listOf(componentType.getDataType(), frozen), componentType);
104103
}
105104

@@ -115,7 +114,7 @@ static ColumnType setOf(ColumnType componentType) {
115114
return setOf((CassandraColumnType) componentType);
116115
}
117116

118-
return new DefaultColumnType(ClassTypeInformation.SET, componentType);
117+
return new DefaultColumnType(TypeInformation.SET, componentType);
119118
}
120119

121120
/**
@@ -136,7 +135,7 @@ static CassandraColumnType setOf(CassandraColumnType componentType) {
136135
* @return
137136
*/
138137
static CassandraColumnType setOf(CassandraColumnType componentType, boolean frozen) {
139-
return new DefaultCassandraColumnType(ClassTypeInformation.SET,
138+
return new DefaultCassandraColumnType(TypeInformation.SET,
140139
() -> DataTypes.setOf(componentType.getDataType(), frozen), componentType);
141140
}
142141

@@ -148,7 +147,7 @@ static CassandraColumnType setOf(CassandraColumnType componentType, boolean froz
148147
* @return
149148
*/
150149
static ColumnType mapOf(ColumnType keyType, ColumnType valueType) {
151-
return new DefaultColumnType(ClassTypeInformation.MAP, keyType, valueType);
150+
return new DefaultColumnType(TypeInformation.MAP, keyType, valueType);
152151
}
153152

154153
/**
@@ -172,7 +171,7 @@ static CassandraColumnType mapOf(CassandraColumnType keyType, CassandraColumnTyp
172171
* @since 3.2.4
173172
*/
174173
static CassandraColumnType mapOf(CassandraColumnType keyType, CassandraColumnType valueType, boolean frozen) {
175-
return new DefaultCassandraColumnType(ClassTypeInformation.MAP,
174+
return new DefaultCassandraColumnType(TypeInformation.MAP,
176175
() -> DataTypes.mapOf(keyType.getDataType(), valueType.getDataType(), frozen), keyType, valueType);
177176
}
178177

spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/convert/DefaultCassandraColumnType.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import java.util.function.Supplier;
1919
import java.util.stream.Collectors;
2020

21-
import org.springframework.data.util.ClassTypeInformation;
2221
import org.springframework.data.util.Lazy;
2322
import org.springframework.data.util.TypeInformation;
2423

@@ -36,7 +35,7 @@ class DefaultCassandraColumnType extends DefaultColumnType implements CassandraC
3635
private final Lazy<DataType> dataType;
3736

3837
DefaultCassandraColumnType(Class<?> type, DataType dataType, ColumnType... parameters) {
39-
this(ClassTypeInformation.from(type), dataType, parameters);
38+
this(TypeInformation.of(type), dataType, parameters);
4039
}
4140

4241
DefaultCassandraColumnType(TypeInformation<?> typeInformation, Supplier<DataType> dataType,

spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/convert/DefaultColumnType.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import java.util.Set;
2121
import java.util.stream.Collectors;
2222

23-
import org.springframework.data.util.ClassTypeInformation;
2423
import org.springframework.data.util.TypeInformation;
2524
import org.springframework.lang.Nullable;
2625

@@ -32,7 +31,7 @@
3231
*/
3332
class DefaultColumnType implements ColumnType {
3433

35-
public static final DefaultColumnType OBJECT = new DefaultColumnType(ClassTypeInformation.OBJECT);
34+
public static final DefaultColumnType OBJECT = new DefaultColumnType(TypeInformation.OBJECT);
3635

3736
private final TypeInformation<?> typeInformation;
3837
private final List<ColumnType> parameters;

spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/convert/DefaultColumnTypeResolver.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
import org.springframework.data.convert.CustomConversions;
4242
import org.springframework.data.mapping.MappingException;
4343
import org.springframework.data.mapping.context.MappingContext;
44-
import org.springframework.data.util.ClassTypeInformation;
4544
import org.springframework.data.util.Lazy;
4645
import org.springframework.data.util.TypeInformation;
4746
import org.springframework.lang.Nullable;
@@ -196,7 +195,7 @@ public CassandraColumnType resolve(TypeInformation<?> typeInformation) {
196195
private CassandraColumnType resolve(TypeInformation<?> typeInformation, FrozenIndicator frozen) {
197196

198197
return getCustomWriteTarget(typeInformation)
199-
.map(it -> createCassandraTypeDescriptor(tryResolve(it), ClassTypeInformation.from(it)))
198+
.map(it -> createCassandraTypeDescriptor(tryResolve(it), TypeInformation.of(it)))
200199
.orElseGet(() -> typeInformation.getType().isEnum()
201200
? ColumnType.create(String.class, DataTypes.TEXT)
202201
: createCassandraTypeDescriptor(typeInformation, frozen));
@@ -279,7 +278,7 @@ public ColumnType resolve(@Nullable Object value) {
279278

280279
if (value != null) {
281280

282-
ClassTypeInformation<?> typeInformation = ClassTypeInformation.from(value.getClass());
281+
TypeInformation<?> typeInformation = TypeInformation.of(value.getClass());
283282

284283
return getCustomWriteTarget(typeInformation).map(it -> {
285284
return (ColumnType) createCassandraTypeDescriptor(tryResolve(it), typeInformation);

spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/convert/MappingCassandraConverter.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
import org.springframework.data.projection.EntityProjection;
6161
import org.springframework.data.projection.ProjectionFactory;
6262
import org.springframework.data.projection.SpelAwareProxyProjectionFactory;
63-
import org.springframework.data.util.ClassTypeInformation;
6463
import org.springframework.data.util.Predicates;
6564
import org.springframework.data.util.TypeInformation;
6665
import org.springframework.lang.Nullable;
@@ -420,7 +419,7 @@ public <R> R read(Class<R> type, Object row) {
420419
public <R> R readRow(Class<R> type, Row row) {
421420

422421
Class<R> beanClassLoaderClass = transformClassToBeanClassLoaderClass(type);
423-
TypeInformation<? extends R> typeInfo = ClassTypeInformation.from(beanClassLoaderClass);
422+
TypeInformation<? extends R> typeInfo = TypeInformation.of(beanClassLoaderClass);
424423

425424
return doReadRow(getConversionContext(), row, typeInfo);
426425
}
@@ -553,7 +552,7 @@ private void readProperties(ConversionContext context, CassandraPersistentEntity
553552

554553
@Override
555554
public Object convertToColumnType(Object obj) {
556-
return convertToColumnType(obj, ClassTypeInformation.from(obj.getClass()));
555+
return convertToColumnType(obj, TypeInformation.of(obj.getClass()));
557556
}
558557

559558
@Override
@@ -924,7 +923,7 @@ private Object getWriteValue(@Nullable Object value, ColumnType columnType) {
924923
return writeMapInternal((Map<Object, Object>) value, columnType);
925924
}
926925

927-
TypeInformation<?> type = ClassTypeInformation.from((Class) value.getClass());
926+
TypeInformation<?> type = TypeInformation.of((Class) value.getClass());
928927
TypeInformation<?> actualType = type.getRequiredActualType();
929928
BasicCassandraPersistentEntity<?> entity = getMappingContext().getPersistentEntity(actualType.getType());
930929

@@ -1144,7 +1143,7 @@ protected Object readCollectionOrArray(ConversionContext context, Collection<?>
11441143
}
11451144

11461145
TypeInformation<?> componentType = targetType.getComponentType();
1147-
componentType = componentType == null ? ClassTypeInformation.from(elementType) : componentType;
1146+
componentType = componentType == null ? TypeInformation.of(elementType) : componentType;
11481147

11491148
for (Object element : source) {
11501149
collection.add(context.convert(element, componentType));
@@ -1200,7 +1199,7 @@ protected Object readMap(ConversionContext context, Map<?, ?> source, TypeInform
12001199

12011200
Object value = entry.getValue();
12021201

1203-
map.put(key, context.convert(value, valueType == null ? ClassTypeInformation.OBJECT : valueType));
1202+
map.put(key, context.convert(value, valueType == null ? TypeInformation.OBJECT : valueType));
12041203
}
12051204

12061205
return map;

spring-data-cassandra/src/main/java/org/springframework/data/cassandra/repository/query/CassandraQueryMethod.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import org.springframework.data.projection.ProjectionFactory;
3131
import org.springframework.data.repository.core.RepositoryMetadata;
3232
import org.springframework.data.repository.query.QueryMethod;
33-
import org.springframework.data.util.ClassTypeInformation;
3433
import org.springframework.data.util.TypeInformation;
3534
import org.springframework.lang.Nullable;
3635
import org.springframework.util.Assert;
@@ -201,7 +200,7 @@ protected Class<?> getDomainClass() {
201200
* @return the return type for this {@link QueryMethod}.
202201
*/
203202
public TypeInformation<?> getReturnType() {
204-
return ClassTypeInformation.fromReturnTypeOf(this.method);
203+
return TypeInformation.fromReturnTypeOf(this.method);
205204
}
206205

207206
/**

spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/convert/ColumnTypeResolverUnitTests.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@
2525

2626
import org.assertj.core.api.SoftAssertions;
2727
import org.junit.jupiter.api.Test;
28+
2829
import org.springframework.data.cassandra.core.mapping.BasicCassandraPersistentEntity;
2930
import org.springframework.data.cassandra.core.mapping.CassandraMappingContext;
3031
import org.springframework.data.cassandra.core.mapping.CassandraPersistentProperty;
3132
import org.springframework.data.cassandra.core.mapping.CassandraType;
3233
import org.springframework.data.cassandra.core.mapping.Frozen;
3334
import org.springframework.data.cassandra.core.mapping.UserDefinedType;
3435
import org.springframework.data.mapping.MappingException;
35-
import org.springframework.data.util.ClassTypeInformation;
36+
import org.springframework.data.util.TypeInformation;
3637

3738
import com.datastax.oss.driver.api.core.data.TupleValue;
3839
import com.datastax.oss.driver.api.core.type.DataType;
@@ -59,8 +60,8 @@ public class ColumnTypeResolverUnitTests {
5960
void shouldResolveSimpleType() {
6061

6162
assertThat(resolver.resolve("foo").getType()).isEqualTo(String.class);
62-
assertThat(resolver.resolve(ClassTypeInformation.from(String.class)).getType()).isEqualTo(String.class);
63-
assertThat(resolver.resolve(ClassTypeInformation.from(String.class)).getDataType()).isEqualTo(DataTypes.TEXT);
63+
assertThat(resolver.resolve(TypeInformation.of(String.class)).getType()).isEqualTo(String.class);
64+
assertThat(resolver.resolve(TypeInformation.of(String.class)).getDataType()).isEqualTo(DataTypes.TEXT);
6465

6566
BasicCassandraPersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(Person.class);
6667

@@ -72,8 +73,8 @@ void shouldResolveSimpleType() {
7273
void shouldResolveEnumType() {
7374

7475
assertThat(resolver.resolve(MyEnum.INSTANCE).getType()).isEqualTo(String.class);
75-
assertThat(resolver.resolve(ClassTypeInformation.from(MyEnum.class)).getType()).isEqualTo(String.class);
76-
assertThat(resolver.resolve(ClassTypeInformation.from(MyEnum.class)).getDataType()).isEqualTo(DataTypes.TEXT);
76+
assertThat(resolver.resolve(TypeInformation.of(MyEnum.class)).getType()).isEqualTo(String.class);
77+
assertThat(resolver.resolve(TypeInformation.of(MyEnum.class)).getDataType()).isEqualTo(DataTypes.TEXT);
7778

7879
BasicCassandraPersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(Person.class);
7980

spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/mapping/BasicCassandraPersistentEntityUnitTests.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
import org.springframework.core.annotation.AliasFor;
3535
import org.springframework.data.mapping.Association;
3636
import org.springframework.data.mapping.AssociationHandler;
37-
import org.springframework.data.util.ClassTypeInformation;
37+
import org.springframework.data.util.TypeInformation;
3838

3939
import com.datastax.oss.driver.api.core.CqlIdentifier;
4040

@@ -55,7 +55,7 @@ class BasicCassandraPersistentEntityUnitTests {
5555
void subclassInheritsAtTableAnnotation() {
5656

5757
BasicCassandraPersistentEntity<Notification> entity = new BasicCassandraPersistentEntity<>(
58-
ClassTypeInformation.from(Notification.class));
58+
TypeInformation.of(Notification.class));
5959

6060
assertThat(entity.getTableName().asCql(true)).isEqualTo("messages");
6161
}
@@ -64,7 +64,7 @@ void subclassInheritsAtTableAnnotation() {
6464
void evaluatesSpELExpression() {
6565

6666
BasicCassandraPersistentEntity<Area> entity = new BasicCassandraPersistentEntity<>(
67-
ClassTypeInformation.from(Area.class));
67+
TypeInformation.of(Area.class));
6868

6969
entity.setApplicationContext(this.context);
7070

@@ -81,7 +81,7 @@ void tableAllowsReferencingSpringBean() {
8181
when(this.context.containsBean("tableNameHolderThingy")).thenReturn(true);
8282

8383
BasicCassandraPersistentEntity<UserLine> entity = new BasicCassandraPersistentEntity<>(
84-
ClassTypeInformation.from(UserLine.class));
84+
TypeInformation.of(UserLine.class));
8585
entity.setApplicationContext(context);
8686

8787
assertThat(entity.getTableName()).hasToString(bean.tableName);
@@ -91,7 +91,7 @@ void tableAllowsReferencingSpringBean() {
9191
void setForceQuoteCallsSetTableName() {
9292

9393
BasicCassandraPersistentEntity<Message> entitySpy = spy(
94-
new BasicCassandraPersistentEntity<>(ClassTypeInformation.from(Message.class)));
94+
new BasicCassandraPersistentEntity<>(TypeInformation.of(Message.class)));
9595

9696
DirectFieldAccessor directFieldAccessor = new DirectFieldAccessor(entitySpy);
9797

@@ -110,7 +110,7 @@ void setForceQuoteCallsSetTableName() {
110110
void setForceQuoteDoesNothing() {
111111

112112
BasicCassandraPersistentEntity<Message> entitySpy = spy(
113-
new BasicCassandraPersistentEntity<>(ClassTypeInformation.from(Message.class)));
113+
new BasicCassandraPersistentEntity<>(TypeInformation.of(Message.class)));
114114

115115
DirectFieldAccessor directFieldAccessor = new DirectFieldAccessor(entitySpy);
116116

@@ -126,7 +126,7 @@ void setForceQuoteDoesNothing() {
126126
void isUserDefinedTypeShouldReturnFalse() {
127127

128128
BasicCassandraPersistentEntity<UserLine> entity = new BasicCassandraPersistentEntity<>(
129-
ClassTypeInformation.from(UserLine.class));
129+
TypeInformation.of(UserLine.class));
130130

131131
assertThat(entity.isUserDefinedType()).isFalse();
132132
}
@@ -135,7 +135,7 @@ void isUserDefinedTypeShouldReturnFalse() {
135135
void shouldConsiderComposedTableAnnotation() {
136136

137137
BasicCassandraPersistentEntity<TableWithComposedAnnotation> entity = new BasicCassandraPersistentEntity<>(
138-
ClassTypeInformation.from(TableWithComposedAnnotation.class));
138+
TypeInformation.of(TableWithComposedAnnotation.class));
139139

140140
assertThat(entity.getTableName()).isEqualTo(CqlIdentifier.fromCql("mytable"));
141141
}
@@ -144,7 +144,7 @@ void shouldConsiderComposedTableAnnotation() {
144144
void shouldConsiderComposedPrimaryKeyClassAnnotation() {
145145

146146
BasicCassandraPersistentEntity<PrimaryKeyClassWithComposedAnnotation> entity = new BasicCassandraPersistentEntity<>(
147-
ClassTypeInformation.from(PrimaryKeyClassWithComposedAnnotation.class));
147+
TypeInformation.of(PrimaryKeyClassWithComposedAnnotation.class));
148148

149149
assertThat(entity.isCompositePrimaryKey()).isTrue();
150150
}
@@ -154,7 +154,7 @@ void shouldConsiderComposedPrimaryKeyClassAnnotation() {
154154
void shouldRejectAssociationCreation() {
155155

156156
BasicCassandraPersistentEntity<PrimaryKeyClassWithComposedAnnotation> entity = new BasicCassandraPersistentEntity<>(
157-
ClassTypeInformation.from(PrimaryKeyClassWithComposedAnnotation.class));
157+
TypeInformation.of(PrimaryKeyClassWithComposedAnnotation.class));
158158

159159
assertThatThrownBy(() -> entity.addAssociation(mock(Association.class)))
160160
.isInstanceOf(UnsupportedCassandraOperationException.class);
@@ -165,7 +165,7 @@ void shouldRejectAssociationCreation() {
165165
void shouldNoOpOnDoWithAssociations() {
166166

167167
BasicCassandraPersistentEntity<PrimaryKeyClassWithComposedAnnotation> entity = new BasicCassandraPersistentEntity<>(
168-
ClassTypeInformation.from(PrimaryKeyClassWithComposedAnnotation.class));
168+
TypeInformation.of(PrimaryKeyClassWithComposedAnnotation.class));
169169

170170
AssociationHandler<CassandraPersistentProperty> handlerMock = mock(AssociationHandler.class);
171171
entity.doWithAssociations(handlerMock);

spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/mapping/BasicCassandraPersistentPropertyUnitTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
import org.springframework.core.annotation.AliasFor;
3535
import org.springframework.data.mapping.model.Property;
36-
import org.springframework.data.util.ClassTypeInformation;
36+
import org.springframework.data.util.TypeInformation;
3737
import org.springframework.util.ReflectionUtils;
3838

3939
import com.datastax.oss.driver.api.core.CqlIdentifier;
@@ -162,12 +162,12 @@ private CassandraPersistentProperty getPropertyFor(Class<?> type, String fieldNa
162162

163163
Field field = ReflectionUtils.findField(type, fieldName);
164164

165-
return new BasicCassandraPersistentProperty(Property.of(ClassTypeInformation.from(type), field), getEntity(type),
165+
return new BasicCassandraPersistentProperty(Property.of(TypeInformation.of(type), field), getEntity(type),
166166
CassandraSimpleTypeHolder.HOLDER);
167167
}
168168

169169
private <T> BasicCassandraPersistentEntity<T> getEntity(Class<T> type) {
170-
return new BasicCassandraPersistentEntity<>(ClassTypeInformation.from(type));
170+
return new BasicCassandraPersistentEntity<>(TypeInformation.of(type));
171171
}
172172

173173
private static class Timeline {

spring-data-cassandra/src/test/java/org/springframework/data/cassandra/core/mapping/BasicCassandraPersistentTuplePropertyUnitTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import org.mockito.junit.jupiter.MockitoExtension;
2626

2727
import org.springframework.data.mapping.model.Property;
28-
import org.springframework.data.util.ClassTypeInformation;
28+
import org.springframework.data.util.TypeInformation;
2929
import org.springframework.util.ReflectionUtils;
3030

3131
/**
@@ -56,12 +56,12 @@ private CassandraPersistentProperty getPropertyFor(Class<?> type, String fieldNa
5656

5757
Field field = ReflectionUtils.findField(type, fieldName);
5858

59-
return new BasicCassandraPersistentTupleProperty(Property.of(ClassTypeInformation.from(type), field),
59+
return new BasicCassandraPersistentTupleProperty(Property.of(TypeInformation.of(type), field),
6060
getEntity(type), CassandraSimpleTypeHolder.HOLDER);
6161
}
6262

6363
private <T> BasicCassandraPersistentEntity<T> getEntity(Class<T> type) {
64-
return new BasicCassandraPersistentTupleEntity<>(ClassTypeInformation.from(type));
64+
return new BasicCassandraPersistentTupleEntity<>(TypeInformation.of(type));
6565
}
6666

6767
@Tuple

0 commit comments

Comments
 (0)