-
Notifications
You must be signed in to change notification settings - Fork 29
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
Conversation
…eturn immutable map in BaseQualifierBuilder
.setQualifiers(qbIs1, qbIs2) | ||
)), | ||
Person.class | ||
new Query(new AerospikeCriteria(forMultipleQualifiers(AND, qbIs1, qbIs2))), Person.class |
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
?
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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)); | ||
|
There was a problem hiding this comment.
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 ; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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; |
@@ -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) { |
There was a problem hiding this comment.
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
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.