Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
agrgr committed Nov 8, 2023
1 parent dd1e1bd commit 9a283aa
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -712,11 +712,10 @@ public interface AerospikeOperations {
* @param id The id of the document to find. Must not be {@literal null}.
* @param entityClass The class to extract the Aerospike set from. Must not be {@literal null}.
* @param targetClass The class to map the document to.
* @param query {@link Query} provided to build a filter expression. Optional argument.
* @param query The {@link Query} to filter results. Optional argument.
* @return The document from Aerospike, returned document will be mapped to targetClass's type.
*/
<T, S> Object findByIdUsingQuery(Object id, Class<T> entityClass, Class<S> targetClass,
Query query);
<T, S> Object findByIdUsingQuery(Object id, Class<T> entityClass, Class<S> targetClass, Query query);

/**
* Find document by providing id with a given set name.
Expand All @@ -728,7 +727,7 @@ <T, S> Object findByIdUsingQuery(Object id, Class<T> entityClass, Class<S> targe
* {@literal null}.
* @param targetClass The class to map the document to.
* @param setName Set name to find the document from.
* @param query {@link Query} provided to build a filter expression. Optional argument.
* @param query The {@link Query} to filter results. Optional argument.
* @return The document from Aerospike, returned document will be mapped to targetClass's type.
*/
<T, S> Object findByIdUsingQuery(Object id, Class<T> entityClass, Class<S> targetClass, String setName,
Expand All @@ -742,7 +741,7 @@ <T, S> Object findByIdUsingQuery(Object id, Class<T> entityClass, Class<S> targe
* @param ids The ids of the documents to find. Must not be {@literal null}.
* @param entityClass The class to extract the Aerospike set from. Must not be {@literal null}.
* @param targetClass The class to map the document to.
* @param query {@link Query} provided to build a filter expression. Optional argument.
* @param query The {@link Query} to filter results. Optional argument.
* @return The documents from Aerospike, returned documents will be mapped to targetClass's type, if no document
* exists, an empty list is returned.
*/
Expand All @@ -758,7 +757,7 @@ <T, S> Object findByIdUsingQuery(Object id, Class<T> entityClass, Class<S> targe
* {@literal null}.
* @param targetClass The class to map the document to.
* @param setName Set name to find the document from.
* @param query {@link Query} provided to build a filter expression. Optional argument.
* @param query The {@link Query} to filter results. Optional argument.
* @return The documents from Aerospike, returned documents will be mapped to targetClass's type, if no document
* exists, an empty list is returned.
*/
Expand All @@ -768,7 +767,7 @@ <T, S> List<?> findByIdsUsingQuery(Collection<?> ids, Class<T> entityClass, Clas
/**
* Find documents in the given entityClass's set using a query and map them to the given class type.
*
* @param query The query to filter results. Must not be {@literal null}.
* @param query The {@link Query} to filter results. Must not be {@literal null}.
* @param entityClass The class to extract the Aerospike set from and to map the documents to. Must not be
* {@literal null}.
* @return A Stream of matching documents, returned documents will be mapped to entityClass's type.
Expand All @@ -778,7 +777,7 @@ <T, S> List<?> findByIdsUsingQuery(Collection<?> ids, Class<T> entityClass, Clas
/**
* Find documents in the given entityClass's set using a query and map them to the given target class type.
*
* @param query The query to filter results. Must not be {@literal null}.
* @param query The {@link Query} to filter results. Must not be {@literal null}.
* @param entityClass The class to extract the Aerospike set from. Must not be {@literal null}.
* @param targetClass The class to map the document to. Must not be {@literal null}.
* @return A Stream of matching documents, returned documents will be mapped to targetClass's type.
Expand All @@ -788,7 +787,7 @@ <T, S> List<?> findByIdsUsingQuery(Collection<?> ids, Class<T> entityClass, Clas
/**
* Find documents in the given set using a query and map them to the given target class type.
*
* @param query The query to filter results. Must not be {@literal null}.
* @param query The {@link Query} to filter results. Must not be {@literal null}.
* @param setName Set name to find the documents in.
* @param targetClass The class to map the document to. Must not be {@literal null}.
* @return A Stream of matching documents, returned documents will be mapped to targetClass's type.
Expand All @@ -798,7 +797,7 @@ <T, S> List<?> findByIdsUsingQuery(Collection<?> ids, Class<T> entityClass, Clas
/**
* Find all documents in the given entityClass's set using provided {@link Query}.
*
* @param query Query to build filter expression from. Constructed using a {@link Qualifier} that can contain
* @param query The {@link Query} to filter results. Constructed using a {@link Qualifier} that can contain
* other qualifiers. Must not be {@literal null}. If filter param is null and qualifier has
* {@link Qualifier#getExcludeFilter()} == false, secondary index filter is built based on the
* first processed qualifier.
Expand All @@ -812,7 +811,7 @@ <T, S> List<?> findByIdsUsingQuery(Collection<?> ids, Class<T> entityClass, Clas
/**
* Find all documents in the given entityClass's set using provided {@link Query}.
*
* @param query Query to build filter expression from. Constructed using a {@link Qualifier} that can contain
* @param query The {@link Query} to filter results. Constructed using a {@link Qualifier} that can contain
* other qualifiers. Must not be {@literal null}. If filter param is null and qualifier has
* {@link Qualifier#getExcludeFilter()} == false, secondary index filter is built based on the
* first processed qualifier.
Expand All @@ -822,12 +821,12 @@ <T, S> List<?> findByIdsUsingQuery(Collection<?> ids, Class<T> entityClass, Clas
* @param filter Secondary index filter.
* @return Stream of entities.
*/
<T, S> Stream<?> find(Query query, Class<T> entityClass, Class<S> targetClass, @Nullable Filter filter);
<T, S> Stream<S> find(Query query, Class<T> entityClass, Class<S> targetClass, @Nullable Filter filter);

/**
* Find all documents in the given set using provided {@link Query}.
*
* @param query Query to build filter expression from. Constructed using a {@link Qualifier} that can contain
* @param query The {@link Query} to filter results. Constructed using a {@link Qualifier} that can contain
* other qualifiers. Must not be {@literal null}. If filter param is null and qualifier has
* {@link Qualifier#getExcludeFilter()} == false, secondary index filter is built based on the
* first processed qualifier.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -668,13 +668,13 @@ public <T, S> S findById(Object id, Class<T> entityClass, Class<S> targetClass,
return (S) findByIdUsingQuery(id, entityClass, targetClass, setName, null);
}

private Record getRecord(AerospikePersistentEntity<?> entity, Key key, Qualifier... qualifiers) {
private Record getRecord(AerospikePersistentEntity<?> entity, Key key, Qualifier criteria) {
Record aeroRecord;
if (entity.isTouchOnRead()) {
Assert.state(!entity.hasExpirationProperty(), "Touch on read is not supported for expiration property");
aeroRecord = getAndTouch(key, entity.getExpiration(), null);
} else {
Policy policy = getPolicyFilterExp(qualifiers);
Policy policy = getPolicyFilterExp(criteria);
aeroRecord = getAerospikeClient().get(policy, key);
}
return aeroRecord;
Expand All @@ -696,14 +696,14 @@ private Key[] getKeys(Collection<?> ids, String setName) {
}

private <S> Object getRecordMapToTargetClass(AerospikePersistentEntity<?> entity, Key key, Class<S> targetClass,
Qualifier... qualifiers) {
Qualifier criteria) {
Record aeroRecord;
String[] binNames = getBinNamesFromTargetClass(targetClass);
if (entity.isTouchOnRead()) {
Assert.state(!entity.hasExpirationProperty(), "Touch on read is not supported for expiration property");
aeroRecord = getAndTouch(key, entity.getExpiration(), binNames, qualifiers);
aeroRecord = getAndTouch(key, entity.getExpiration(), binNames, criteria);
} else {
Policy policy = getPolicyFilterExp(qualifiers);
Policy policy = getPolicyFilterExp(criteria);
aeroRecord = getAerospikeClient().get(policy, key, binNames);
}
return mapToEntity(key, targetClass, aeroRecord);
Expand All @@ -720,7 +720,7 @@ private String[] getBinNamesFromTargetClass(Class<?> targetClass) {
return binNamesList.toArray(new String[0]);
}

private Policy getPolicyFilterExp(Qualifier[] qualifiers) {
private Policy getPolicyFilterExp(Qualifier... qualifiers) {
if (qualifiers != null && qualifiers.length > 0) {
Policy policy = new Policy(getAerospikeClient().getReadPolicyDefault());
policy.filterExp = queryEngine.getFilterExpressionsBuilder().build(qualifiers);
Expand Down Expand Up @@ -901,7 +901,7 @@ public <T> Stream<T> find(Query query, Class<T> entityClass, Filter filter) {
}

@Override
public <T, S> Stream<?> find(Query query, Class<T> entityClass, Class<S> targetClass, Filter filter) {
public <T, S> Stream<S> find(Query query, Class<T> entityClass, Class<S> targetClass, Filter filter) {
return findRecordsUsingQualifiers(getSetName(entityClass), targetClass, filter)
.map(keyRecord -> mapToEntity(keyRecord, targetClass));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ public interface ReactiveAerospikeOperations {
* @param id The id of the document to find. Must not be {@literal null}.
* @param entityClass The class to extract the Aerospike set from. Must not be {@literal null}.
* @param targetClass The class to map the document to.
* @param query {@link Query} provided to build a filter expression. Optional argument.
* @param query The {@link Query} to filter results. Optional argument.
* @return The document from Aerospike, returned document will be mapped to targetClass's type.
*/
<T, S> Mono<?> findByIdUsingQuery(Object id, Class<T> entityClass, Class<S> targetClass,
Expand All @@ -697,7 +697,7 @@ <T, S> Mono<?> findByIdUsingQuery(Object id, Class<T> entityClass, Class<S> targ
* {@literal null}.
* @param targetClass The class to map the document to.
* @param setName Set name to find the document from.
* @param query {@link Query} provided to build a filter expression. Optional argument.
* @param query The {@link Query} to filter results. Optional argument.
* @return The document from Aerospike, returned document will be mapped to targetClass's type.
*/
<T, S> Mono<?> findByIdUsingQuery(Object id, Class<T> entityClass, Class<S> targetClass, String setName,
Expand All @@ -711,7 +711,7 @@ <T, S> Mono<?> findByIdUsingQuery(Object id, Class<T> entityClass, Class<S> targ
* @param ids The ids of the documents to find. Must not be {@literal null}.
* @param entityClass The class to extract the Aerospike set from. Must not be {@literal null}.
* @param targetClass The class to map the document to.
* @param query {@link Query} provided to build a filter expression. Optional argument.
* @param query The {@link Query} to filter results. Optional argument.
* @return The documents from Aerospike, returned documents will be mapped to targetClass's type, if no document
* exists, an empty list is returned.
*/
Expand All @@ -727,7 +727,7 @@ <T, S> Mono<?> findByIdUsingQuery(Object id, Class<T> entityClass, Class<S> targ
* {@literal null}.
* @param targetClass The class to map the document to.
* @param setName Set name to find the document from.
* @param query {@link Query} provided to build a filter expression. Optional argument.
* @param query The {@link Query} to filter results. Optional argument.
* @return The documents from Aerospike, returned documents will be mapped to targetClass's type, if no document
* exists, an empty list is returned.
*/
Expand All @@ -737,7 +737,7 @@ <T, S> Flux<?> findByIdsUsingQuery(Collection<?> ids, Class<T> entityClass, Clas
/**
* Reactively find documents in the given entityClass's set using a query and map them to the given class type.
*
* @param query The query to filter results. Must not be {@literal null}.
* @param query The {@link Query} to filter results. Must not be {@literal null}.
* @param entityClass The class to extract the Aerospike set from and to map the documents to. Must not be
* {@literal null}.
* @return A Flux of matching documents, returned documents will be mapped to entityClass's type.
Expand All @@ -748,7 +748,7 @@ <T, S> Flux<?> findByIdsUsingQuery(Collection<?> ids, Class<T> entityClass, Clas
* Reactively find documents in the given entityClass's set using a query and map them to the given target class
* type.
*
* @param query The query to filter results. Must not be {@literal null}.
* @param query The {@link Query} to filter results. Must not be {@literal null}.
* @param entityClass The class to extract the Aerospike set from. Must not be {@literal null}.
* @param targetClass The class to map the document to. Must not be {@literal null}.
* @return A Flux of matching documents, returned documents will be mapped to targetClass's type.
Expand All @@ -758,7 +758,7 @@ <T, S> Flux<?> findByIdsUsingQuery(Collection<?> ids, Class<T> entityClass, Clas
/**
* Reactively find documents in the given set using a query and map them to the given target class type.
*
* @param query The query to filter results. Must not be {@literal null}.
* @param query The {@link Query} to filter results. Must not be {@literal null}.
* @param targetClass The class to map the document to. Must not be {@literal null}.
* @param setName Set name to find the documents from.
* @return A Flux of matching documents, returned documents will be mapped to targetClass's type.
Expand All @@ -768,7 +768,7 @@ <T, S> Flux<?> findByIdsUsingQuery(Collection<?> ids, Class<T> entityClass, Clas
/**
* Find all documents in the given entityClass's set using provided {@link Query}.
*
* @param query Query to build filter expression from. Constructed using a {@link Qualifier} that can contain
* @param query The {@link Query} to filter results. Constructed using a {@link Qualifier} that can contain
* other qualifiers. Must not be {@literal null}. If filter param is null and qualifier has
* {@link Qualifier#getExcludeFilter()} == false, secondary index filter is built based on the
* first processed qualifier.
Expand All @@ -782,7 +782,7 @@ <T, S> Flux<?> findByIdsUsingQuery(Collection<?> ids, Class<T> entityClass, Clas
/**
* Find all documents in the given entityClass's set using provided {@link Query}.
*
* @param query Query to build filter expression from. Constructed using a {@link Qualifier} that can contain
* @param query The {@link Query} to filter results. Constructed using a {@link Qualifier} that can contain
* other qualifiers. Must not be {@literal null}. If filter param is null and qualifier has
* {@link Qualifier#getExcludeFilter()} == false, secondary index filter is built based on the
* first processed qualifier.
Expand All @@ -792,12 +792,12 @@ <T, S> Flux<?> findByIdsUsingQuery(Collection<?> ids, Class<T> entityClass, Clas
* @param filter Secondary index filter.
* @return Stream of entities.
*/
<T, S> Flux<?> find(Query query, Class<T> entityClass, Class<S> targetClass, @Nullable Filter filter);
<T, S> Flux<S> find(Query query, Class<T> entityClass, Class<S> targetClass, @Nullable Filter filter);

/**
* Find all documents in the given set using provided {@link Query}.
*
* @param query Query to build filter expression from. Constructed using a {@link Qualifier} that can contain
* @param query The {@link Query} to filter results. Constructed using a {@link Qualifier} that can contain
* other qualifiers. Must not be {@literal null}. If filter param is null and qualifier has
* {@link Qualifier#getExcludeFilter()} == false, secondary index filter is built based on the
* first processed qualifier.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@ public <T> Flux<T> find(Query query, Class<T> entityClass, Filter filter) {
}

@Override
public <T, S> Flux<?> find(Query query, Class<T> entityClass, Class<S> targetClass, Filter filter) {
public <T, S> Flux<S> find(Query query, Class<T> entityClass, Class<S> targetClass, Filter filter) {
return findRecordsUsingQualifiers(getSetName(entityClass), targetClass, filter)
.map(keyRecord -> mapToEntity(keyRecord, targetClass));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static Qualifier[] getQualifiers(Qualifier criteria) {
if (criteria == null) {
return null;
} else if (criteria.getQualifiers() == null) {
return new Qualifier[]{(criteria)};
return new Qualifier[]{criteria};
}
return criteria.getQualifiers();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public Object execute(Object[] parameters) {
List<Object> ids;
if (criteria.hasSingleId()) {
ids = getIdValue(criteria);
return operations.findByIdsUsingQuery(ids, entityClass, targetClass, (Query) null);
return operations.findByIdsUsingQuery(ids, entityClass, targetClass, null);
} else {
Qualifier idQualifier;
if ((idQualifier = getIdQualifier(criteria)) != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ protected Query prepareQuery(Object[] parameters, ParametersParameterAccessor ac
PartTree tree = new PartTree(queryMethod.getName(), entityClass);
Query baseQuery = createQuery(accessor, tree);

Qualifier qualifiers = baseQuery.getCriteria().getCriteriaObject();
Query query = new Query(qualifiers);
Qualifier criteria = baseQuery.getCriteria().getCriteriaObject();
Query query = new Query(criteria);

if (accessor.getPageable().isPaged()) {
query.setOffset(accessor.getPageable().getOffset());
Expand Down

0 comments on commit 9a283aa

Please sign in to comment.