Skip to content

Commit

Permalink
Polishing.
Browse files Browse the repository at this point in the history
Replace duplicated code with method calls.

Closes: #1084
Original pull request: #1085
Related ticket: DATACASS-465
  • Loading branch information
mp911de committed Jan 29, 2021
1 parent ca9895c commit ea56f85
Showing 1 changed file with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -443,17 +443,6 @@ private CassandraColumnType createCassandraTypeDescriptor(TypeInformation<?> typ
return new DefaultCassandraColumnType(typeInformation, dataType);
}

private DataType getUserType(CassandraPersistentEntity<?> persistentEntity, boolean frozen) {
CqlIdentifier identifier = persistentEntity.getTableName();
com.datastax.oss.driver.api.core.type.UserDefinedType userType = userTypeResolver.resolveType(identifier);

if (userType == null) {
throw new MappingException(String.format("User type [%s] not found", identifier));
}

return userType.copy(frozen);
}

private Class<?> resolveToJavaType(DataType dataType) {
TypeCodec<Object> codec = getCodecRegistry().codecFor(dataType);
return codec.getJavaType().getRawType();
Expand All @@ -463,12 +452,20 @@ private CodecRegistry getCodecRegistry() {
return codecRegistry.get();
}

private DataType getUserType(String userTypeName) {
private UserDefinedType getUserType(CassandraPersistentEntity<?> persistentEntity, boolean frozen) {
return getUserType(persistentEntity.getTableName()).copy(frozen);
}

private UserDefinedType getUserType(String userTypeName) {
return getUserType(CqlIdentifier.fromCql(userTypeName));
}

private UserDefinedType getUserType(CqlIdentifier userTypeName) {

UserDefinedType type = userTypeResolver.resolveType(CqlIdentifier.fromCql(userTypeName));
UserDefinedType type = userTypeResolver.resolveType(userTypeName);

if (type == null) {
throw new MappingException(String.format("Cannot resolve UserDefinedType for [%s]", userTypeName));
throw new MappingException(String.format("User type [%s] not found", userTypeName));
}

return type;
Expand Down

0 comments on commit ea56f85

Please sign in to comment.