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, 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:
  • Field Details

    • path

      protected final CayennePath path
      Path of this property
    • expressionSupplier

      protected final Supplier<Expression> expressionSupplier
      Expression provider for the property
    • type

      protected final Class<E> type
      Explicit type of the property
  • Constructor Details

  • Method Details

    • getName

      public String getName()
      Specified by:
      getName in interface Property<E>
      Returns:
      Name of the property in the object.
      See Also:
    • getPath

      public CayennePath getPath()
      Specified by:
      getPath in interface Property<E>
      Returns:
      path this property represents
      Since:
      5.0
      See Also:
    • getAlias

      public String getAlias()
      Specified by:
      getAlias in interface Property<E>
      Returns:
      alias for this property
    • getExpression

      public Expression getExpression()
      This method returns fresh copy of the expression for each call.
      Specified by:
      getExpression in interface Property<E>
      Returns:
      expression that represents this Property
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • 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()
      See Also:
    • countDistinct

      public NumericProperty<Long> countDistinct()
      See Also:
    • aggregate

      public <T> BaseProperty<T> aggregate(String function, Class<T> type)
      Since:
      5.0
      See Also:
    • alias

      public BaseProperty<E> alias(String alias)
      Creates alias with different name for this property
    • getType

      public Class<E> getType()
      Specified by:
      getType in interface Property<E>
      Returns:
      type of entity attribute described by 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()
      This operator allows to access properties of the enclosing query from the subquery. It allows multiple nesting levels to access a corresponding query in case of multiple levels of subqueries. Example:
      
       ObjectSelect.query(Artist.class)
                       .where(ExpressionFactory.notExists(ObjectSelect.query(Painting.class)
                               .where(Painting.TO_ARTIST.eq(Artist.ARTIST_ID_PK_PROPERTY.enclosing()))))
       
       
      Returns:
      property that will be translated relative to a 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