public class QueryBuilder extends Object
Examples are presented below.
QueryBuilder.queryFor(User.class, EntityDescriptor.user()).returningAtMost(100);This is the minimum required structure for a query.
QueryBuilder.queryFor(User.class, EntityDescriptor.user()).with(
Restriction.on(UserTermKeys.USERNAME).startingWith("b")
).startingAt(100).returningAtMost(10);
QueryBuilder.queryFor(User.class, EntityDescriptor.user()).with(
Combine.anyOf(
Restriction.on(PropertyUtils.ofTypeString("color")).startingWith("red"),
Restriction.on(PropertyUtils.ofTypeString("color")).exactlyMatching("scarlet"),
Restriction.on(PropertyUtils.ofTypeString("color")).exactlyMatching("crimson")
)
).returningAtMost(50);
QueryBuilder.queryFor(String.class, EntityDescriptor.user()).with(
Combine.allOf(
Restriction.on(PropertyUtils.ofTypeString("color")).exactlyMatching("red"),
Restriction.on(PropertyUtils.ofTypeString("color")).exactlyMatching("blue")
)
).returningAtMost(50);
QueryBuilder.queryFor(User.class, EntityDescriptor.user()).with(
Combine.anyOf(
Combine.allOf(
Restriction.on(PropertyUtils.ofTypeString("color")).exactlyMatching("red"),
Restriction.on(UserTermKeys.USERNAME).startingWith("r")
),
Combine.allOf(
Restriction.on(PropertyUtils.ofTypeString("color")).exactlyMatching("blue"),
Restriction.on(UserTermKeys.USERNAME).startingWith("b")
)
)
).returningAtMost(10);
This is equivalent to verbosely constructing the same query as so:
TermRestriction colorRed = new TermRestriction<String>(PropertyUtils.ofTypeString("color"), MatchMode.EXACTLY_MATCHES, "red");
TermRestriction colorBlue = new TermRestriction<String>(PropertyUtils.ofTypeString("color"), MatchMode.EXACTLY_MATCHES, "blue");
TermRestriction userNameR = new TermRestriction<String>(UserTermKeys.USERNAME, MatchMode.STARTS_WITH, "r");
TermRestriction userNameB = new TermRestriction<String>(UserTermKeys.USERNAME, MatchMode.STARTS_WITH, "b");
BooleanRestriction conjuction1 = new BooleanRestrictionImpl(BooleanRestriction.BooleanLogic.AND, colorRed, userNameR);
BooleanRestriction conjuction2 = new BooleanRestrictionImpl(BooleanRestriction.BooleanLogic.AND, colorBlue, userNameB);
BooleanRestriction disjunction = new BooleanRestrictionImpl(BooleanRestriction.BooleanLogic.OR, conjuction1, conjuction2);
UserQuery query = new UserQuery(User.class, disjunction, 0, 10);
QueryBuilder.queryFor(User.class, EntityDescriptor.user()).childrenOf(EntityDescriptor.group()).withName("group-name").returningAtMost(10);
QueryBuilder.queryFor(String.class, EntityDescriptor.user()).childrenOf(EntityDescriptor.group()).withName("group-name").returningAtMost(10);
QueryBuilder.queryFor(Group.class, EntityDescriptor.group()).childrenOf(EntityDescriptor.group()).withName("group-name").returningAtMost(10);
QueryBuilder.queryFor(Group.class, EntityDescriptor.group()).parentsOf(EntityDescriptor.user()).withName("user-name").returningAtMost(10);
QueryBuilder.queryFor(String.class, EntityDescriptor.group()).parentsOf(EntityDescriptor.user()).withName("user-name").returningAtMost(10);
| Modifier and Type | Class and Description |
|---|---|
static class |
QueryBuilder.PartialEntityQuery<T> |
static class |
QueryBuilder.PartialEntityQueryWithRestriction<T> |
static class |
QueryBuilder.PartialEntityQueryWithStartIndex<T> |
static class |
QueryBuilder.PartialMembershipQueryWithEntityToMatch<T> |
static class |
QueryBuilder.PartialMembershipQueryWithNameToMatch<T> |
static class |
QueryBuilder.PartialMembershipQueryWithStartIndex<T> |
| Modifier and Type | Field and Description |
|---|---|
static SearchRestriction |
NULL_RESTRICTION |
| Constructor and Description |
|---|
QueryBuilder() |
| Modifier and Type | Method and Description |
|---|---|
static <T> MembershipQuery<T> |
createMembershipQuery(int maxResults,
int startIndex,
boolean findMembers,
EntityDescriptor entityToReturn,
Class<T> returnType,
EntityDescriptor entityToMatch,
SearchRestriction searchRestriction,
String... namesToMatch) |
static <T> MembershipQuery<T> |
createMembershipQuery(int maxResults,
int startIndex,
boolean findMembers,
EntityDescriptor entityToReturn,
Class<T> returnType,
EntityDescriptor entityToMatch,
String... namesToMatch)
Deprecated.
Use
createMembershipQuery(int, int, boolean, EntityDescriptor, Class, EntityDescriptor, String...) instead. Since v2.9. |
static <T> MembershipQuery<T> |
createMembershipQuery(int maxResults,
int startIndex,
boolean findMembers,
EntityDescriptor entityToReturn,
Class<T> returnType,
EntityDescriptor entityToMatch,
String nameToMatch)
Deprecated.
Use
createMembershipQuery(int, int, boolean, EntityDescriptor, Class, EntityDescriptor, String...) instead. Since v2.9. |
static <T> QueryBuilder.PartialEntityQuery<T> |
queryFor(Class<T> returnType,
EntityDescriptor entity) |
static <T> EntityQuery<T> |
queryFor(Class<T> returnType,
EntityDescriptor entity,
SearchRestriction searchRestriction,
int startIndex,
int maxResults) |
public static final SearchRestriction NULL_RESTRICTION
public static <T> QueryBuilder.PartialEntityQuery<T> queryFor(Class<T> returnType, EntityDescriptor entity)
public static <T> EntityQuery<T> queryFor(Class<T> returnType, EntityDescriptor entity, SearchRestriction searchRestriction, int startIndex, int maxResults)
@Deprecated public static <T> MembershipQuery<T> createMembershipQuery(int maxResults, int startIndex, boolean findMembers, EntityDescriptor entityToReturn, Class<T> returnType, EntityDescriptor entityToMatch, String nameToMatch)
createMembershipQuery(int, int, boolean, EntityDescriptor, Class, EntityDescriptor, String...) instead. Since v2.9.@Deprecated public static <T> MembershipQuery<T> createMembershipQuery(int maxResults, int startIndex, boolean findMembers, EntityDescriptor entityToReturn, Class<T> returnType, EntityDescriptor entityToMatch, String... namesToMatch)
createMembershipQuery(int, int, boolean, EntityDescriptor, Class, EntityDescriptor, String...) instead. Since v2.9.public static <T> MembershipQuery<T> createMembershipQuery(int maxResults, int startIndex, boolean findMembers, EntityDescriptor entityToReturn, Class<T> returnType, EntityDescriptor entityToMatch, SearchRestriction searchRestriction, String... namesToMatch)
Copyright © 2017 Atlassian. All rights reserved.