Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FMWK-255 Add qualifier builders #644

Merged
merged 4 commits into from
Oct 23, 2023
Merged

Conversation

agrgr
Copy link

@agrgr agrgr commented Oct 23, 2023

Add builder for parent qualifier containing other qualifiers, add builder for id qualifier (to have a dedicated map key), return immutable map in BaseQualifierBuilder, add some refactoring and cleanup.

@agrgr agrgr requested review from roimenashe and reugn October 23, 2023 11:09
.setQualifiers(qbIs1, qbIs2)
)),
Person.class
new Query(new AerospikeCriteria(forMultipleQualifiers(AND, qbIs1, qbIs2))), Person.class
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't import static, I would use Qualifier.forMultipleQualifiers and FilterOperation.AND just for better readability

* @param qualifiers 2 or more qualifiers to be connected
* @return Parent qualifier
*/
public static Qualifier forMultipleQualifiers(FilterOperation logicalOp, Qualifier... qualifiers) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the "for" prefix? why not just multipleQualifiers?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public static Qualifier or(Qualifier qualifier, Qualifier... qualifiers)
public static Qualifier and(Qualifier qualifier, Qualifier... qualifiers)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initially it was the idea, then combined the two methods because in some places we get OR/AND as a parameter.
Agree that it looks better overall, updating

* @param qualifiers 2 or more qualifiers to be connected
* @return Parent qualifier
*/
public static Qualifier forMultipleQualifiers(FilterOperation logicalOp, Qualifier... qualifiers) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

public static Qualifier or(Qualifier qualifier, Qualifier... qualifiers)
public static Qualifier and(Qualifier qualifier, Qualifier... qualifiers)

if (property.isIdProperty()) {
if (value1 instanceof Collection<?>) {
return new AerospikeCriteria(forIds(((Collection<?>) value1).toArray(String[]::new)));
} else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove else

.setQualifiers(base, criteria)
);
return new AerospikeCriteria(forMultipleQualifiers(OR, base, criteria));

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove line

@@ -108,7 +117,15 @@ public boolean hasQualifiers() {
}

public boolean hasId() {
return internalMap.get(FIELD) != null && internalMap.get(FIELD).equals(ID_VALUE);
return internalMap.get(SINGLE_ID_FIELD) != null || internalMap.get(MULTIPLE_IDS_FIELD) != null ;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return internalMap.get(SINGLE_ID_FIELD) != null || internalMap.get(MULTIPLE_IDS_FIELD) != null ;
return internalMap.get(SINGLE_ID_FIELD) != null || internalMap.get(MULTIPLE_IDS_FIELD) != null;

@agrgr agrgr marked this pull request as ready for review October 23, 2023 14:16
@@ -381,28 +431,50 @@ protected void validate() {
}

/**
* Create qualifier "ID is equal to the given string"
* Create a qualifier "ID is equal to the given string"
*
* @param id String value
* @return Single id qualifier
*/
public static Qualifier forId(String id) {
Copy link
Member

@roimenashe roimenashe Oct 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here I think, not sure about the "for" prefix maybe IdEquals for single id comparison and IdIn() for multiple ids comparison? lets talk about it tomorrow

@agrgr agrgr merged commit f5ba6e4 into main Oct 23, 2023
5 checks passed
@agrgr agrgr deleted the FMWK-255-add-qualifier-builders branch October 23, 2023 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants