Class PBaseValueEqual<R,T>

java.lang.Object
io.ebean.typequery.TQProperty<R,T>
io.ebean.typequery.TQPropertyBase<R,T>
io.ebean.typequery.PBaseValueEqual<R,T>
Type Parameters:
R - the root query bean type
T - the number type
All Implemented Interfaces:
io.ebean.Query.Property<T>
Direct Known Subclasses:
PBaseComparable, PBoolean, PByteArray, PEnum, PScalar, PUuid

public abstract class PBaseValueEqual<R,T> extends TQPropertyBase<R,T>
Base property for types that primarily have equal to.
  • Field Summary

    Fields inherited from class io.ebean.typequery.TQProperty

    _name, _root
  • Constructor Summary

    Constructors
    Constructor
    Description
    PBaseValueEqual(String name, R root)
    Construct with a property name and root instance.
    PBaseValueEqual(String name, R root, String prefix)
    Construct with additional path prefix.
  • Method Summary

    Modifier and Type
    Method
    Description
    final R
    Set the property as the map key for a findMap query.
    final R
    eq(io.ebean.Query.Property<T> other)
    Is equal to another property.
    final R
    eq(io.ebean.Query<?> subQuery)
    Property is equal to the result of a sub-query.
    final R
    eq(T value)
    Is equal to.
    final R
    eqIfPresent(@Nullable T value)
    Is equal to if value is non-null and otherwise no expression is added to the query.
    final R
    eqOrNull(T value)
    Is equal to or Null.
    final R
    eqSubQuery(String sqlSubQuery, Object... bindValues)
    Equal To a raw SQL SubQuery.
    final R
    equalTo(T value)
    Is equal to.
    final R
    Is equal to or Null.
    final R
    in(io.ebean.Query<?> subQuery)
    Is in the result of a subquery.
    final R
    in(Collection<T> values)
    Is in a list of values.
    final R
    in(T... values)
    Is in a list of values.
    final R
    In where null or empty values means that no predicate is added to the query.
    final R
    inSubQuery(String sqlSubQuery, Object... bindValues)
    IN a raw SQL SubQuery.
    final R
    isIn(io.ebean.Query<?> subQuery)
    Is in the result of a sub-query.
    final R
    isIn(Collection<T> values)
    Is in a list of values.
    final R
    isIn(T... values)
    Is in a list of values.
    final R
    ne(io.ebean.Query.Property<T> other)
    Is not equal to another property.
    final R
    ne(io.ebean.Query<?> subQuery)
    Property is not equal to the result of a sub-query.
    final R
    ne(T value)
    Is not equal to.
    final R
    neSubQuery(String sqlSubQuery, Object... bindValues)
    Not Equal To a raw SQL SubQuery.
    final R
    notEqualTo(T value)
    Is not equal to.
    final R
    notIn(io.ebean.Query<?> subQuery)
    Is NOT in the result of a sub-query.
    final R
    notIn(Collection<T> values)
    Is NOT in a list of values.
    final R
    notIn(T... values)
    Is NOT in a list of values.
    final R
    notInSubQuery(String sqlSubQuery, Object... bindValues)
    Not IN a raw SQL SubQuery.

    Methods inherited from class io.ebean.typequery.TQPropertyBase

    asc, desc

    Methods inherited from class io.ebean.typequery.TQProperty

    expr, isNotNull, isNull, propertyName, toString

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • PBaseValueEqual

      public PBaseValueEqual(String name, R root)
      Construct with a property name and root instance.
      Parameters:
      name - property name
      root - the root query bean instance
    • PBaseValueEqual

      public PBaseValueEqual(String name, R root, String prefix)
      Construct with additional path prefix.
  • Method Details

    • asMapKey

      public final R asMapKey()
      Set the property as the map key for a findMap query.
      
      
         Map<String, Customer> map =
           new QCustomer()
             .organisation.id.equalTo(42)
             .email.asMapKey() // email property as map key
             .findMap();
      
       
      Returns:
      the root query bean instance
    • equalToOrNull

      public final R equalToOrNull(T value)
      Is equal to or Null.
      Parameters:
      value - the equal to bind value
      Returns:
      the root query bean instance
    • equalTo

      public final R equalTo(T value)
      Is equal to.
      Parameters:
      value - the equal to bind value
      Returns:
      the root query bean instance
    • eq

      public final R eq(T value)
      Is equal to.
      Parameters:
      value - the equal to bind value
      Returns:
      the root query bean instance
    • eq

      public final R eq(io.ebean.Query.Property<T> other)
      Is equal to another property.
      Parameters:
      other - the other property to compare
      Returns:
      the root query bean instance
    • eqIfPresent

      public final R eqIfPresent(@Nullable T value)
      Is equal to if value is non-null and otherwise no expression is added to the query.

      That is, only add the EQUAL TO predicate if the value is not null.

      This is the EQUAL TO equivalent to inOrEmpty(Collection) where the expression/predicate is only added to the query when the value is non-null.

      This is effectively a helper method that allows a query to be built in fluid style where some predicates are effectively optional. We can use eqIfPresent() rather than having a separate if block.

      Parameters:
      value - the equal to bind value
      Returns:
      the root query bean instance
    • eqOrNull

      public final R eqOrNull(T value)
      Is equal to or Null.
      Parameters:
      value - the equal to bind value
      Returns:
      the root query bean instance
    • notEqualTo

      public final R notEqualTo(T value)
      Is not equal to.
      Parameters:
      value - the equal to bind value
      Returns:
      the root query bean instance
    • ne

      public final R ne(T value)
      Is not equal to.
      Parameters:
      value - the equal to bind value
      Returns:
      the root query bean instance
    • ne

      public final R ne(io.ebean.Query.Property<T> other)
      Is not equal to another property.
      Parameters:
      other - the other property to compare
      Returns:
      the root query bean instance
    • in

      @SafeVarargs public final R in(T... values)
      Is in a list of values.
      Parameters:
      values - the list of values for the predicate
      Returns:
      the root query bean instance
    • inOrEmpty

      public final R inOrEmpty(Collection<T> values)
      In where null or empty values means that no predicate is added to the query.

      That is, only add the IN predicate if the values are not null or empty.

      Without this we typically need to code an if block to only add the IN predicate if the collection is not empty like:

      Without inOrEmpty()

      
      
         List<String> names = Arrays.asList("foo", "bar");
      
         QCustomer query = new QCustomer()
             .registered.before(LocalDate.now())
      
         // conditionally add the IN expression to the query
         if (names != null && !names.isEmpty()) {
             query.name.in(names)
         }
      
         query.findList();
      
       

      Using inOrEmpty()

      
      
         List<String> names = Arrays.asList("foo", "bar");
      
         new QCustomer()
             .registered.before(LocalDate.now())
             .name.inOrEmpty(names)
             .findList();
      
       
    • notIn

      @SafeVarargs public final R notIn(T... values)
      Is NOT in a list of values.
      Parameters:
      values - the list of values for the predicate
      Returns:
      the root query bean instance
    • isIn

      @SafeVarargs public final R isIn(T... values)
      Is in a list of values. Synonym for in().
      Parameters:
      values - the list of values for the predicate
      Returns:
      the root query bean instance
    • in

      public final R in(Collection<T> values)
      Is in a list of values.
      Parameters:
      values - the list of values for the predicate
      Returns:
      the root query bean instance
    • notIn

      public final R notIn(Collection<T> values)
      Is NOT in a list of values.
      Parameters:
      values - the list of values for the predicate
      Returns:
      the root query bean instance
    • isIn

      public final R isIn(Collection<T> values)
      Is in a list of values. Synonym for in().
      Parameters:
      values - the list of values for the predicate
      Returns:
      the root query bean instance
    • in

      public final R in(io.ebean.Query<?> subQuery)
      Is in the result of a subquery.
      Parameters:
      subQuery - values provided by a subQuery
      Returns:
      the root query bean instance
    • isIn

      public final R isIn(io.ebean.Query<?> subQuery)
      Is in the result of a sub-query. Synonym for in().
      Parameters:
      subQuery - values provided by a subQuery
      Returns:
      the root query bean instance
    • notIn

      public final R notIn(io.ebean.Query<?> subQuery)
      Is NOT in the result of a sub-query.
      Parameters:
      subQuery - values provided by a subQuery
      Returns:
      the root query bean instance
    • inSubQuery

      public final R inSubQuery(String sqlSubQuery, Object... bindValues)
      IN a raw SQL SubQuery.
      Parameters:
      sqlSubQuery - The SQL SubQuery
      bindValues - Optional bind values if the SubQuery uses ? bind values.
    • notInSubQuery

      public final R notInSubQuery(String sqlSubQuery, Object... bindValues)
      Not IN a raw SQL SubQuery.
      Parameters:
      sqlSubQuery - The SQL SubQuery
      bindValues - Optional bind values if the SubQuery uses ? bind values.
    • eqSubQuery

      public final R eqSubQuery(String sqlSubQuery, Object... bindValues)
      Equal To a raw SQL SubQuery.
      Parameters:
      sqlSubQuery - The SQL SubQuery
      bindValues - Optional bind values if the SubQuery uses ? bind values.
    • neSubQuery

      public final R neSubQuery(String sqlSubQuery, Object... bindValues)
      Not Equal To a raw SQL SubQuery.
      Parameters:
      sqlSubQuery - The SQL SubQuery
      bindValues - Optional bind values if the SubQuery uses ? bind values.
    • eq

      public final R eq(io.ebean.Query<?> subQuery)
      Property is equal to the result of a sub-query.
      Parameters:
      subQuery - value provided by a subQuery
      Returns:
      the root query bean instance
    • ne

      public final R ne(io.ebean.Query<?> subQuery)
      Property is not equal to the result of a sub-query.
      Parameters:
      subQuery - value provided by a subQuery
      Returns:
      the root query bean instance