Package org.apache.cayenne.exp.property
Class BaseProperty<E>
- java.lang.Object
-
- org.apache.cayenne.exp.property.BaseProperty<E>
-
- All Implemented Interfaces:
Property<E>
- Direct Known Subclasses:
BaseIdProperty
,CollectionProperty
,DateProperty
,EmbeddableProperty
,EntityProperty
,MapProperty
,NumericProperty
,Property
,StringProperty
public class BaseProperty<E> extends Object implements Property<E>
Property that represents generic attribute.Provides equality checks and sorting API along with some utility methods.
- Since:
- 4.2
- See Also:
org.apache.cayenne.exp.property
-
-
Field Summary
Fields Modifier and Type Field Description protected Supplier<Expression>
expressionSupplier
Expression provider for the propertyprotected String
name
Name of the property in the objectprotected Class<E>
type
Explicit type of the property
-
Constructor Summary
Constructors Modifier Constructor Description protected
BaseProperty(String name, Expression expression, Class<? super E> type)
Constructs a new property with the given name and expression
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description BaseProperty<E>
alias(String alias)
Creates alias with different name for this propertyOrdering
asc()
Ordering
ascInsensitive()
Orderings
ascInsensitives()
Orderings
ascs()
NumericProperty<Long>
count()
NumericProperty<Long>
countDistinct()
Ordering
desc()
Ordering
descInsensitive()
Orderings
descInsensitives()
Orderings
descs()
BaseProperty<E>
enclosing()
Expression
eq(E value)
Expression
eq(BaseProperty<?> value)
boolean
equals(Object o)
<T> BaseProperty<T>
function(String functionName, Class<T> returnType, Object... arguments)
<T> BaseProperty<T>
function(String functionName, Class<T> returnType, BaseProperty<?>... arguments)
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<E>
getType()
int
hashCode()
Expression
in(E firstValue, E... moreValues)
Expression
in(Collection<E> values)
Expression
in(ColumnSelect<? extends E> subquery)
Expression
isFalse()
Expression
isNotNull()
Expression
isNull()
Expression
isTrue()
Expression
ne(E value)
Expression
ne(BaseProperty<?> value)
Expression
nin(E firstValue, E... moreValues)
Expression
nin(Collection<E> values)
Expression
nin(ColumnSelect<? extends E> subquery)
<T> BaseProperty<T>
operator(String operator, Class<T> returnType, Object... arguments)
<T> BaseProperty<T>
operator(String operator, Class<T> returnType, BaseProperty<?>... arguments)
Expression
path()
Deprecated.since 4.2, usegetExpression()
method insteadvoid
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.
-
-
-
Field Detail
-
name
protected final String name
Name of the property in the object
-
expressionSupplier
protected final Supplier<Expression> expressionSupplier
Expression provider for the property
-
-
Constructor Detail
-
BaseProperty
protected BaseProperty(String name, Expression expression, Class<? super E> type)
Constructs a new property with the given name and expression- Parameters:
name
- of the property (will be used as alias for the expression)expression
- expression for propertytype
- of the property- See Also:
PropertyFactory.createBase(String, Expression, Class)
-
-
Method Detail
-
getName
public String getName()
-
getAlias
public String getAlias()
-
getExpression
public Expression getExpression()
This method returns fresh copy of the expression for each call.- Specified by:
getExpression
in interfaceProperty<E>
- Returns:
- expression that represents this Property
-
path
@Deprecated public Expression path()
Deprecated.since 4.2, usegetExpression()
method insteadConverts this property to a path expression. This method is equivalent of getExpression() which is preferred as more generic.- Returns:
- a newly created expression.
- See Also:
getExpression()
-
isNull
public Expression isNull()
- Returns:
- An expression representing null.
-
isNotNull
public Expression isNotNull()
- Returns:
- An expression representing a non-null value.
-
asc
public Ordering asc()
- Returns:
- Ascending sort orderings on this property.
-
ascs
public Orderings ascs()
- Returns:
- Ascending sort orderings on this property.
-
ascInsensitive
public Ordering ascInsensitive()
- Returns:
- Ascending case insensitive sort orderings on this property.
-
ascInsensitives
public Orderings ascInsensitives()
- Returns:
- Ascending case insensitive sort orderings on this property.
-
desc
public Ordering desc()
- Returns:
- Descending sort orderings on this property.
-
descs
public Orderings descs()
- Returns:
- Descending sort orderings on this property.
-
descInsensitive
public Ordering descInsensitive()
- Returns:
- Descending case insensitive sort orderings on this property.
-
descInsensitives
public Orderings descInsensitives()
- Returns:
- Descending case insensitive sort orderings on this property.
-
getFrom
public 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.
-
getFromAll
public 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.
-
setIn
public 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.
-
setInAll
public 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.
-
count
public NumericProperty<Long> count()
-
countDistinct
public NumericProperty<Long> countDistinct()
-
alias
public BaseProperty<E> alias(String alias)
Creates alias with different name for this property
-
isTrue
public Expression isTrue()
- Returns:
- An expression representing equality to TRUE.
-
isFalse
public Expression isFalse()
- Returns:
- An expression representing equality to FALSE.
-
eq
public Expression eq(E value)
- Returns:
- An expression representing equality to a value.
-
eq
public Expression eq(BaseProperty<?> value)
- Returns:
- An expression representing equality between two attributes (columns).
-
ne
public Expression ne(E value)
- Returns:
- An expression representing inequality to a value.
-
ne
public Expression ne(BaseProperty<?> value)
- Returns:
- An expression representing inequality between two attributes (columns).
-
in
public Expression in(E firstValue, E... moreValues)
- Returns:
- An expression for finding objects with values in the given set.
-
nin
public Expression nin(E firstValue, E... moreValues)
- Returns:
- An expression for finding objects with values not in the given set.
-
in
public Expression in(Collection<E> values)
- Returns:
- An expression for finding objects with values in the given set.
-
nin
public Expression nin(Collection<E> values)
- Returns:
- An expression for finding objects with values not in the given set.
-
in
public Expression in(ColumnSelect<? extends E> subquery)
- Returns:
- An expression for finding objects with values in the given subquery
-
nin
public Expression nin(ColumnSelect<? extends E> subquery)
- Returns:
- An expression for finding objects with values not in the given subquery
-
enclosing
public BaseProperty<E> enclosing()
- Returns:
- property that will be translated relative to parent query
-
function
public <T> BaseProperty<T> function(String functionName, Class<T> returnType, BaseProperty<?>... arguments)
- Returns:
- An expression for calling functionName with first argument equals to this property and provided additional arguments
-
function
public <T> BaseProperty<T> function(String functionName, Class<T> returnType, Object... arguments)
- Returns:
- An expression for calling functionName with first argument equals to this property and provided additional arguments
-
operator
public <T> BaseProperty<T> operator(String operator, Class<T> returnType, BaseProperty<?>... arguments)
- Returns:
- An expression for using operator with first argument equals to this property and provided additional arguments
-
operator
public <T> BaseProperty<T> operator(String operator, Class<T> returnType, Object... arguments)
- Returns:
- An expression for using operator with first argument equals to this property and provided additional arguments
-
-