E
- The type this property returns.public class Property<E> extends Object
A property in a DataObject
.
Used to construct Expressions quickly and with type-safety, and to construct Orderings.
Instances of this class are immutable.
Must be created via factory methods Property.create(..)
create(String, Class)
,
create(Expression, Class)
,
create(String, Expression, Class)
Modifier and Type | Field and Description |
---|---|
static Property<Long> |
COUNT
Property that can be used in COUNT(*) queries
|
Modifier | Constructor and Description |
---|---|
|
Property(String name)
Deprecated.
use factory method Property.create("propertyName", PropertyType.class)
|
protected |
Property(String name,
Class<? super E> type)
Constructs a new property with the given name and type.
|
protected |
Property(String name,
Expression expression,
Class<? super E> type)
Constructs a new property with the given name and expression
|
Modifier and Type | Method and Description |
---|---|
Property<E> |
abs() |
Property<E> |
alias(String alias)
Creates alias with different name for this property
|
Ordering |
asc() |
Ordering |
ascInsensitive() |
List<Ordering> |
ascInsensitives() |
List<Ordering> |
ascs() |
Property<E> |
avg() |
Expression |
between(E lower,
E upper) |
Property<String> |
concat(Object... args)
Arguments will be converted as follows:
if argument is a
Property than its expression will be used
if argument is a Expression than it will be used as is
all other values will be converted to String
|
Expression |
contains(String substring)
Creates an expression for a database "LIKE" query with the value converted to a pattern matching anywhere in the
String.
|
Expression |
containsIgnoreCase(String value)
Same as
contains(String) , only using case-insensitive
comparison. |
Property<Long> |
count() |
static <T> Property<T> |
create(Expression expression,
Class<? super T> type)
Creates property with expression and type
|
static <T> Property<T> |
create(String name,
Class<? super T> type)
Creates property with name and type
|
static <T> Property<T> |
create(String name,
Expression expression,
Class<? super T> type)
Creates property with name, expression and type
|
static <T extends Persistent> |
createSelf(Class<? super T> type)
Creates "self" Property for persistent class.
|
Ordering |
desc() |
Ordering |
descInsensitive() |
List<Ordering> |
descInsensitives() |
List<Ordering> |
descs() |
PrefetchTreeNode |
disjoint()
Returns a prefetch tree that follows this property path, potentially
spanning a number of phantom nodes, and having a single leaf with
"disjoint" prefetch semantics.
|
PrefetchTreeNode |
disjointById()
Returns a prefetch tree that follows this property path, potentially
spanning a number of phantom nodes, and having a single leaf with
"disjoint by id" prefetch semantics.
|
<T> Property<T> |
dot(Property<T> property)
Constructs a new property path by appending the argument to the existing property separated by a dot.
|
Property<Object> |
dot(String property)
Constructs a property path by appending the argument to the existing property separated by a dot.
|
Expression |
endsWith(String value)
Creates an expression for a database "LIKE" query with the value
converted to a pattern matching the tail of a String.
|
Expression |
endsWithIgnoreCase(String value)
Same as
endsWith(String) , only using case-insensitive
comparison. |
Expression |
eq(E value) |
Expression |
eq(Property<?> value) |
boolean |
equals(Object o) |
<T extends Persistent> |
flat(Class<? super T> tClass)
Create new "flat" property for toMany relationship.
|
String |
getAlias() |
Expression |
getExpression()
This method returns fresh copy of the expression for each call.
|
E |
getFrom(Object bean)
Extracts property value from an object using JavaBean-compatible
introspection with one addition - a property can be a dot-separated
property name path.
|
List<E> |
getFromAll(Collection<?> beans)
Extracts property value from a collection of objects using
JavaBean-compatible introspection with one addition - a property can be a
dot-separated property name path.
|
String |
getName() |
Class<? super E> |
getType() |
Expression |
gt(E value) |
Expression |
gt(Property<?> value) |
Expression |
gte(E value) |
Expression |
gte(Property<?> value) |
int |
hashCode() |
Expression |
in(Collection<E> values) |
Expression |
in(E firstValue,
E... moreValues) |
Expression |
isFalse() |
Expression |
isNotNull() |
Expression |
isNull() |
Expression |
isTrue() |
PrefetchTreeNode |
joint()
Returns a prefetch tree that follows this property path, potentially
spanning a number of phantom nodes, and having a single leaf with "joint"
prefetch semantics.
|
Property<Integer> |
length() |
Expression |
like(String pattern) |
Expression |
like(String pattern,
char escapeChar) |
Expression |
likeIgnoreCase(String pattern) |
Property<Integer> |
locate(Property<? extends String> property) |
Property<Integer> |
locate(String string) |
Property<String> |
lower() |
Expression |
lt(E value) |
Expression |
lt(Property<?> value) |
Expression |
lte(E value) |
Expression |
lte(Property<?> value) |
Property<E> |
max() |
Property<E> |
min() |
Property<E> |
mod(Number number) |
Expression |
ne(E value) |
Expression |
ne(Property<?> value) |
Expression |
nin(Collection<E> values) |
Expression |
nin(E firstValue,
E... moreValues) |
Expression |
nlike(String value) |
Expression |
nlikeIgnoreCase(String value) |
Property<E> |
outer()
Returns a version of this property that represents an OUTER join.
|
Expression |
path()
Converts this property to a path expression.
|
void |
setIn(Object bean,
E value)
Sets a property value in 'obj' using JavaBean-compatible introspection
with one addition - a property can be a dot-separated property name path.
|
void |
setInAll(Collection<?> beans,
E value)
Sets a property value in a collection of objects using
JavaBean-compatible introspection with one addition - a property can be a
dot-separated property name path.
|
Property<E> |
sqrt() |
Expression |
startsWith(String value)
Creates an expression for a database "LIKE" query with the value converted to a pattern matching the beginning of
a String.
|
Expression |
startsWithIgnoreCase(String value)
Same as
startsWith(String) , only using case-insensitive
comparison. |
Property<String> |
substring(int offset,
int length) |
Property<E> |
sum() |
Property<String> |
trim() |
Property<String> |
upper() |
public Property(String name)
name
- name of the property (usually it's obj path)create(String, Class)
protected Property(String name, Class<? super E> type)
name
- of the property (usually it's obj path)type
- of the propertycreate(String, Class)
protected Property(String name, Expression expression, Class<? super E> type)
name
- of the property (will be used as alias for the expression)expression
- expression for propertytype
- of the propertycreate(String, Expression, Class)
public String getName()
public String getAlias()
public Expression getExpression()
public Property<Object> dot(String property)
public <T> Property<T> dot(Property<T> property)
public Property<E> outer()
public Expression path()
getExpression()
public Expression isNull()
public Expression isNotNull()
public Expression isTrue()
public Expression isFalse()
public Expression eq(E value)
public Expression eq(Property<?> value)
public Expression ne(E value)
public Expression ne(Property<?> value)
public Expression like(String pattern)
pattern
- a pattern matching property value. Pattern may include "_" and
"%" wildcard symbols to match any single character or a
sequence of characters. To prevent "_" and "%" from being
treated as wildcards, they need to be escaped and escape char
passed with like(String, char)
method.public Expression like(String pattern, char escapeChar)
pattern
- a properly escaped pattern matching property value. Pattern
may include "_" and "%" wildcard symbols to match any single
character or a sequence of characters.escapeChar
- an escape character used in the pattern to escape "%" and "_".public Expression likeIgnoreCase(String pattern)
public Expression nlike(String value)
public Expression nlikeIgnoreCase(String value)
public Expression contains(String substring)
substring
- a String to match against property value. "_" and "%" symbols
are NOT treated as wildcards and are escaped when converted to
a LIKE expression.public Expression startsWith(String value)
value
- a String to match against property value. "_" and "%" symbols
are NOT treated as wildcards and are escaped when converted to
a LIKE expression.public Expression endsWith(String value)
value
- a String to match against property value. "_" and "%" symbols
are NOT treated as wildcards and are escaped when converted to
a LIKE expression.public Expression containsIgnoreCase(String value)
contains(String)
, only using case-insensitive
comparison.public Expression startsWithIgnoreCase(String value)
startsWith(String)
, only using case-insensitive
comparison.public Expression endsWithIgnoreCase(String value)
endsWith(String)
, only using case-insensitive
comparison.public Expression between(E lower, E upper)
lower
- The lower bound.upper
- The upper bound.public Expression in(E firstValue, E... moreValues)
public Expression nin(E firstValue, E... moreValues)
public Expression in(Collection<E> values)
public Expression nin(Collection<E> values)
public Expression gt(E value)
public Expression gt(Property<?> value)
public Expression gte(E value)
public Expression gte(Property<?> value)
public Expression lt(E value)
public Expression lt(Property<?> value)
public Expression lte(E value)
public Expression lte(Property<?> value)
public Ordering asc()
public Ordering ascInsensitive()
public List<Ordering> ascInsensitives()
public Ordering desc()
public Ordering descInsensitive()
public List<Ordering> descInsensitives()
public PrefetchTreeNode joint()
public PrefetchTreeNode disjoint()
public PrefetchTreeNode disjointById()
public E getFrom(Object bean)
public List<E> getFromAll(Collection<?> beans)
public void setIn(Object bean, E value)
public void setInAll(Collection<?> beans, E value)
public Property<String> concat(Object... args)
Arguments will be converted as follows:
Property
than its expression will be usedExpression
than it will be used as is Usage:
Property<String> fullName = Artist.FIRST_NAME.concat(" ", Artist.SECOND_NAME);
public <T extends Persistent> Property<T> flat(Class<? super T> tClass)
Create new "flat" property for toMany relationship.
Example:
List<Object[]> result = ObjectSelect
.columnQuery(Artist.class, Artist.ARTIST_NAME, Artist.PAINTING_ARRAY.flat(Painting.class))
.select(context);
public static <T> Property<T> create(String name, Class<? super T> type)
public static <T> Property<T> create(Expression expression, Class<? super T> type)
public static <T> Property<T> create(String name, Expression expression, Class<? super T> type)
create(String, Class)
,
create(Expression, Class)
public static <T extends Persistent> Property<T> createSelf(Class<? super T> type)
Creates "self" Property for persistent class. This property can be used to select full object along with some of it properties (or properties that can be resolved against query root)
Here is sample code, that will select all Artists and count of their Paintings:
Property<Artist> artistFull = Property.createSelf(Artist.class);
List<Object[]> result = ObjectSelect
.columnQuery(Artist.class, artistFull, Artist.PAINTING_ARRAY.count())
.select(context);
Copyright © 2001–2018 Apache Cayenne. All rights reserved.