Module jakarta.data

Interface TextExpression<T>

Type Parameters:
T - entity type.
All Superinterfaces:
ComparableExpression<T,String>, Expression<T,String>
All Known Subinterfaces:
StringLiteral, TextAttribute<T>, TextFunctionExpression<T>, TextPath<T,U>
All Known Implementing Classes:
TextAttributeRecord

public interface TextExpression<T> extends ComparableExpression<T,String>

An expression that evaluates to a String value.

The entity and static metamodel for the code examples within this class are shown in the Attribute Javadoc.

Since:
1.1
  • Method Details

    • type

      default Class<String> type()
      Returns String.class as the type of the textual expression.
      Specified by:
      type in interface Expression<T,String>
      Returns:
      String.class.
    • prepend

      default TextExpression<T> prepend(String prefix)

      Represents the function to obtain the String value that is formed by prepending the specified prefix onto the beginning of the value to which the current expression evaluates.

      Example:

      
           found = cars.search(make,
                               _Car.model.prepend("Model ").equalTo(model));
       
      Returns:
      an expression for the function that computes the concatenated value.
      Throws:
      NullPointerException - if the prefix is null.
    • append

      default TextExpression<T> append(String suffix)

      Represents the function to obtain the String value that is formed by appending the specified suffix onto the end of the value to which the current expression evaluates.

      Example:

      
           found = cars.search(make,
                               _Car.model.append(" Hybrid").equalTo(hybridModel));
       
      Returns:
      an expression for the function that computes the concatenated value.
      Throws:
      NullPointerException - if the suffix is null.
    • prepend

      default TextExpression<T> prepend(TextExpression<? super T> prefixExpression)

      Represents the function to obtain the String value that is formed by prepending the prefix to which the specified expression evaluates onto the beginning of the value to which the current expression evaluates.

      Example:

      TODO 
           found = cars.search(
                   make,
                   _Car.model.prepend(_Car.year.append(" ")).equalTo(yearAndModel));
       
      Returns:
      an expression for the function that computes the concatenated value.
      Throws:
      NullPointerException - if the prefix expression is null.
    • append

      default TextExpression<T> append(TextExpression<? super T> suffixExpression)

      Represents the function to obtain the String value that is formed by appending the suffix to which the specified expression evaluates onto the end of the value to which the current expression evaluates.

      Example:

      
           found = cars.search(_Car.make.append(' ').append(_Car.model).equalTo(makeAndModel));
       
      Returns:
      an expression for the function that computes the concatenated value.
      Throws:
      NullPointerException - if the suffix expression is null.
    • upper

      default TextExpression<T> upper()

      Represents the function to obtain the upper case form of the value to which the current expression evaluates.

      Example:

      
           found = cars.search(_Car.make.upper().startsWith("CHEV"));
       
      Returns:
      an expression for the function that computes the upper case form of the value.
    • lower

      default TextExpression<T> lower()

      Represents the function to obtain the lower case form of the value to which the current expression evaluates.

      Example:

      
           found = cars.search(make,
                               _Car.model.lower().startsWith("f-"));
       
      Returns:
      an expression for the function that computes the lower case form of the value.
    • left

      default TextExpression<T> left(int length)

      Represents the function to obtain the specified number of characters at the beginning of the textual value to which the current expression evaluates.

      Example:

      
           startsWithCX = cars.search(make,
                                      _Car.model.left(2).equalTo("CX"));
       
      Returns:
      an expression for the function that obtains the leftmost characters.
    • right

      default TextExpression<T> right(int length)

      Represents the function to obtain the specified number of characters at the end of the textual value to which the current expression evaluates.

      Example:

      
           endsWithHybrid = cars.search(make,
                                        _Car.model.right(6).equalTo("Hybrid"));
       
      Returns:
      an expression for the function that obtains the rightmost characters.
    • length

      default NumericExpression<T,Integer> length()

      Represents the function to obtain the length of the textual value to which the current expression evaluates.

      Example:

      
           withModelNamesUpTo10Chars = cars.search(make,
                                                   _Car.model.length().lessThanEqual(10));
       
      Returns:
      an expression for the function that obtains the length of the textual value.
    • like

      default Restriction<T> like(Like pattern)

      Obtains a Restriction that requires that this expression evaluate to a value that is like the specified pattern.

      Example:

      
           found = cars.search(make, _Car.model.like(Like.pattern("% Hybrid")));
       
      Parameters:
      pattern - pattern against which to compare. Must not be null.
      Returns:
      the restriction.
      Throws:
      NullPointerException - if the pattern value is null.
    • like

      default Restriction<T> like(String pattern)

      Obtains a Restriction that requires that this expression evaluate to a value that is like the specified pattern.

      Example:

      
           found = cars.search(_Car.make.like("Chev%"));
       
      Parameters:
      pattern - pattern against which to compare. Must not be null.
      Returns:
      the restriction.
      Throws:
      NullPointerException - if the pattern is null.
    • like

      default Restriction<T> like(String pattern, char charWildcard, char stringWildcard)

      Obtains a Restriction that requires that this expression evaluate to a value that is like the specified pattern.

      Example:

      
           found = cars.search(make, _Car.model.like("F-_50%", '_', '%'));
       
      Parameters:
      pattern - pattern against which to compare. Must not be null.
      charWildcard - character that represents a position in the pattern where any 1 character is considered to match.
      stringWildcard - character that represents a position in the pattern where any number of characters (including 0) are considered to match.
      Returns:
      the restriction.
      Throws:
      NullPointerException - if the pattern value is null.
    • like

      default Restriction<T> like(String pattern, char charWildcard, char stringWildcard, char escape)

      Obtains a Restriction that requires that this expression evaluate to a value that is like the specified pattern.

      Example:

      
           found = cars.search(make, _Car.model.like("_R-V%", '_', '%', '^'));
       
      Parameters:
      pattern - pattern against which to compare. Must not be null.
      charWildcard - character that represents a position in the pattern where any 1 character is considered to match.
      stringWildcard - character that represents a position in the pattern where any number of characters (including 0) are considered to match.
      escape - character to use as an escape character within the pattern, indicating that the subsequent wildcard or escape character must be interpreted as its literal value rather than as a wildcard or escape.
      Returns:
      the restriction.
      Throws:
      NullPointerException - if the pattern value is null.
    • notLike

      default Restriction<T> notLike(String pattern)

      Obtains a Restriction that requires that this expression evaluate to a value that is not like the specified pattern.

      Example:

      
           found = cars.search(make, _Car.model.notLike("% EV"));
       
      Parameters:
      pattern - pattern against which to compare. Must not be null.
      Returns:
      the restriction.
      Throws:
      NullPointerException - if the pattern value is null.
    • notLike

      default Restriction<T> notLike(String pattern, char charWildcard, char stringWildcard)

      Obtains a Restriction that requires that this expression evaluate to a value that is not like the specified pattern.

      Example:

      
           found = cars.search(make, _Car.model.notLike("CX-_0 *", '_', '*'));
       
      Parameters:
      pattern - pattern against which to compare. Must not be null.
      charWildcard - character that represents a position in the pattern where any 1 character is considered to match.
      stringWildcard - character that represents a position in the pattern where any number of characters (including 0) are considered to match.
      Throws:
      NullPointerException - if the pattern value is null.
    • notLike

      default Restriction<T> notLike(String pattern, char charWildcard, char stringWildcard, char escape)

      Obtains a Restriction that requires that this expression evaluate to a value that is not like the specified pattern.

      Example:

      
           found = cars.search(make, _Car.model.notLike("* EV*", '_', '*', '^'));
       
      Parameters:
      pattern - pattern against which to compare. Must not be null.
      charWildcard - character that represents a position in the pattern where any 1 character is considered to match.
      stringWildcard - character that represents a position in the pattern where any number of characters (including 0) are considered to match.
      escape - character to use as an escape character within the pattern, indicating that the subsequent wildcard or escape character must be interpreted as its literal value rather than as a wildcard or escape.
      Returns:
      the restriction.
      Throws:
      NullPointerException - if the pattern value is null.
    • contains

      default Restriction<T> contains(String substring)

      Obtains a Restriction that requires that this expression evaluate to a value that contains the specified substring.

      Example:

      
           found = cars.search(make, _Car.model.contains("Hybrid"));
       
      Parameters:
      substring - substring against which to compare. Must not be null.
      Returns:
      the restriction.
      Throws:
      NullPointerException - if the substring value is null.
    • notContains

      default Restriction<T> notContains(String substring)

      Obtains a Restriction that requires that this expression evaluate to a value that does not contain the specified substring.

      Example:

      
           found = cars.search(make, _Car.model.notContains(" EV"));
       
      Parameters:
      substring - substring against which to compare. Must not be null.
      Returns:
      the restriction.
      Throws:
      NullPointerException - if the substring value is null.
    • startsWith

      default Restriction<T> startsWith(String prefix)

      Obtains a Restriction that requires that this expression evaluate to a value that begins with the specified prefix.

      Example:

      
           found = cars.search(_Car.make.startsWith("Chev"));
       
      Parameters:
      prefix - prefix against which to compare. Must not be null.
      Returns:
      the restriction.
      Throws:
      NullPointerException - if the prefix value is null.
    • notStartsWith

      default Restriction<T> notStartsWith(String prefix)

      Obtains a Restriction that requires that this expression evaluate to a value that does not begin with the specified prefix.

      Example:

      
           found = cars.search(make, _Car.model.notStartsWith("CR-"));
       
      Parameters:
      prefix - prefix against which to compare. Must not be null.
      Returns:
      the restriction.
      Throws:
      NullPointerException - if the prefix value is null.
    • endsWith

      default Restriction<T> endsWith(String suffix)

      Obtains a Restriction that requires that this expression evaluate to a value that ends with the specified suffix.

      Example:

      
           found = cars.search(make, _Car.model.endsWith(" EV"));
       
      Parameters:
      suffix - suffix against which to compare. Must not be null.
      Returns:
      the restriction.
      Throws:
      NullPointerException - if the suffix value is null.
    • notEndsWith

      default Restriction<T> notEndsWith(String suffix)

      Obtains a Restriction that requires that this expression evaluate to a value that does not end with the specified suffix.

      Example:

      
           found = cars.search(make, _Car.model.notEndsWith(" Hybrid"));
       
      Parameters:
      suffix - suffix against which to compare. Must not be null.
      Returns:
      the restriction.
      Throws:
      NullPointerException - if the suffix value is null.