Class PropertyQuery
Query.property(Property)
.
Note: Property values do currently not consider any order defined for the main Query
object
(subject to change in a future version).-
Method Summary
Modifier and TypeMethodDescriptiondouble
avg()
Calculates the average of all values for the given number property over all Objects matching the query.long
avgLong()
Calculates the average of all values for the given integer property over all Objects matching the query.long
count()
The count of non-null values.distinct()
Only distinct values should be returned (e.g.distinct
(QueryBuilder.StringOrder stringOrder) For string properties you can specifyQueryBuilder.StringOrder.CASE_SENSITIVE
if you want to have case sensitive distinct values (e.g.findByte()
byte[]
Find the values for the given byte property for objects matching the query.findChar()
char[]
Find the values for the given int property for objects matching the query.double[]
Find the values for the given int property for objects matching the query.float[]
Find the values for the given int property for objects matching the query.findInt()
int[]
findInts()
Find the values for the given int property for objects matching the query.findLong()
long[]
Find the values for the given long property for objects matching the query.short[]
Find the values for the given int property for objects matching the query.String[]
Find the values for the given string property for objects matching the query.long
max()
Finds the maximum value for the given property over all Objects matching the query.double
Finds the maximum value for the given property over all Objects matching the query.long
min()
Finds the minimum value for the given property over all Objects matching the query.double
Finds the minimum value for the given property over all objects matching the query.By default, null values are not returned by find methods (primitive arrays cannot contains nulls).reset()
Clears all values (e.g.long
sum()
Sums up all values for the given property over all Objects matching the query.double
Sums up all values for the given property over all Objects matching the query.unique()
For find methods returning single values, e.g.
-
Method Details
-
reset
Clears all values (e.g. distinct and null value). -
distinct
Only distinct values should be returned (e.g. 1,2,3 instead of 1,1,2,3,3,3).Note: strings default to case-insensitive comparision; to change that call
distinct(QueryBuilder.StringOrder)
. -
distinct
For string properties you can specifyQueryBuilder.StringOrder.CASE_SENSITIVE
if you want to have case sensitive distinct values (e.g. returning "foo","Foo","FOO" instead of "foo"). -
unique
For find methods returning single values, e.g.findInt()
, this will additional verify that the resulting value is unique. If there is any other resulting value resulting from this query, an exception will be thrown.Can be combined with
distinct()
.Will be ignored for find methods returning multiple values, e.g.
findInts()
. -
nullValue
By default, null values are not returned by find methods (primitive arrays cannot contains nulls). However, using this function, you can define an alternative value that will be returned for null values. E.g. -1 for ins/longs or "NULL" for strings. -
findStrings
Find the values for the given string property for objects matching the query.Note: null values are excluded from results.
Note: results are not guaranteed to be in any particular order.
See also:
distinct()
,distinct(QueryBuilder.StringOrder)
- Returns:
- Found strings
-
findLongs
public long[] findLongs()Find the values for the given long property for objects matching the query.Note: null values are excluded from results.
Note: results are not guaranteed to be in any particular order.
See also:
distinct()
- Returns:
- Found longs
-
findInts
public int[] findInts()Find the values for the given int property for objects matching the query.Note: null values are excluded from results.
Note: results are not guaranteed to be in any particular order.
See also:
distinct()
-
findShorts
public short[] findShorts()Find the values for the given int property for objects matching the query.Note: null values are excluded from results.
Note: results are not guaranteed to be in any particular order.
See also:
distinct()
-
findChars
public char[] findChars()Find the values for the given int property for objects matching the query.Note: null values are excluded from results.
Note: results are not guaranteed to be in any particular order.
See also:
distinct()
-
findBytes
public byte[] findBytes()Find the values for the given byte property for objects matching the query.Note: null values are excluded from results.
Note: results are not guaranteed to be in any particular order.
-
findFloats
public float[] findFloats()Find the values for the given int property for objects matching the query.Note: null values are excluded from results.
Note: results are not guaranteed to be in any particular order.
See also:
distinct()
-
findDoubles
public double[] findDoubles()Find the values for the given int property for objects matching the query.Note: null values are excluded from results.
Note: results are not guaranteed to be in any particular order.
See also:
distinct()
-
findString
-
findLong
-
findInt
-
findShort
-
findChar
-
findByte
-
findBoolean
-
findFloat
-
findDouble
-
sum
public long sum()Sums up all values for the given property over all Objects matching the query.Note: this method is not recommended for properties of type long unless you know the contents of the DB not to overflow. Use
sumDouble()
instead if you cannot guarantee the sum to be in the long value range.- Returns:
- 0 in case no elements matched the query
- Throws:
NumericOverflowException
- if the sum exceeds the numbersLong
can represent. This is different from Java arithmetic where it would "wrap around" (e.g. max. value + 1 = min. value).
-
sumDouble
public double sumDouble()Sums up all values for the given property over all Objects matching the query.Note: for integer types int and smaller,
sum()
is usually preferred for sums.- Returns:
- 0 in case no elements matched the query
-
max
public long max()Finds the maximum value for the given property over all Objects matching the query.- Returns:
- Long.MIN_VALUE in case no elements matched the query
-
maxDouble
public double maxDouble()Finds the maximum value for the given property over all Objects matching the query.- Returns:
- NaN in case no elements matched the query
-
min
public long min()Finds the minimum value for the given property over all Objects matching the query.- Returns:
- Long.MAX_VALUE in case no elements matched the query
-
minDouble
public double minDouble()Finds the minimum value for the given property over all objects matching the query.- Returns:
- NaN in case no elements matched the query
-
avg
public double avg()Calculates the average of all values for the given number property over all Objects matching the query.For integer properties you can also use
avgLong()
.- Returns:
- NaN in case no elements matched the query
-
avgLong
public long avgLong()Calculates the average of all values for the given integer property over all Objects matching the query.For floating-point properties use
avg()
.- Returns:
- 0 in case no elements matched the query
-
count
public long count()The count of non-null values.See also:
distinct()
-