use of org.springframework.data.cassandra.core.query.Filter in project spring-data-cassandra by spring-projects.
the class QueryMapper method getMappedColumnNames.
/**
* Map {@link Columns} with a {@link CassandraPersistentEntity type hint} to column names for included columns.
* Function call selectors or other {@link org.springframework.data.cassandra.core.query.Columns.Selector} types are
* not included.
*
* @param columns must not be {@literal null}.
* @param entity must not be {@literal null}.
* @return the mapped column names.
*/
public List<CqlIdentifier> getMappedColumnNames(Columns columns, CassandraPersistentEntity<?> entity) {
Assert.notNull(columns, "Columns must not be null");
Assert.notNull(entity, "CassandraPersistentEntity must not be null");
if (columns.isEmpty()) {
return Collections.emptyList();
}
List<CqlIdentifier> columnNames = new ArrayList<>();
Set<PersistentProperty<?>> seen = new HashSet<>();
for (ColumnName column : columns) {
Field field = createPropertyField(entity, column);
field.getProperty().ifPresent(seen::add);
columns.getSelector(column).filter(selector -> selector instanceof ColumnSelector).ifPresent(columnSelector -> columnNames.addAll(getCqlIdentifier(column, field)));
}
if (columns.isEmpty()) {
entity.doWithProperties((PropertyHandler<CassandraPersistentProperty>) property -> {
if (property.isCompositePrimaryKey()) {
return;
}
if (seen.add(property)) {
columnNames.add(property.getRequiredColumnName());
}
});
}
return columnNames;
}
Aggregations