StringProperty (cayenne-doc: Cayenne Documentation 5.0-M2 API)
Description: declaration: package: org.apache.cayenne.exp.property, class: StringProperty

# Class StringProperty<E extends CharSequence>

java.lang.Object
org.apache.cayenne.exp.property.BaseProperty<E>
org.apache.cayenne.exp.property.StringProperty<E>

All Implemented Interfaces:
  `ComparableProperty<E>, Property<E>`

public class StringProperty<E extends CharSequence> extends BaseProperty<E> implements ComparableProperty<E>
Property that represents attributes mapped on string types

String type is an any type inherited from `CharSequence`.

Provides basic string functions like `like(String)`, `concat(Object...)`, `upper()` and `contains(String)`}.

Example:

    ObjectSelect.query(Artist.class)
         .where(Artist.FIRST_NAME.trim().concat(Artist.LAST_NAME.trim()).length().gt(30))

Since:
  4.2
See Also:
  - `org.apache.cayenne.exp.property`

- ## Field Summary

  ### Fields inherited from class BaseProperty

  `expressionSupplier, path, type`
  Modifier and Type
  Field
  Description
  `protected final Supplier<Expression>`
  `expressionSupplier`
  Expression provider for the property
  `protected final CayennePath`
  `path`
  Path of this property
  `protected final Class<E>`
  `type`
  Explicit type of the property

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  `protected`
  `StringProperty(CayennePath path, Expression expression, Class<E> type)`
  Constructs a new property with the given name and expression

- ## Method Summary

  Modifier and Type
  Method
  Description
  `StringProperty<E>`
  `alias(String alias)`
  Creates alias with different name for this property
  `StringProperty<String>`
  `concat(Object... args)`
  Arguments will be converted as follows: if argument is a `BaseProperty` 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.
  `StringProperty<E>`
  `enclosing()`
  This operator allows to access properties of the enclosing query from the subquery.
  `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.
  `NumericProperty<Integer>`
  `length()`
  `Expression`
  `like(String pattern)`
  `Expression`
  `like(String pattern, char escapeChar)`
  `Expression`
  `like(StringProperty<?> pattern)`
  `Expression`
  `likeIgnoreCase(String pattern)`
  `Expression`
  `likeIgnoreCase(StringProperty<?> pattern)`
  `NumericProperty<Integer>`
  `locate(String string)`
  `NumericProperty<Integer>`
  `locate(StringProperty<? extends String> property)`
  `StringProperty<String>`
  `lower()`
  `Expression`
  `nlike(String value)`
  `Expression`
  `nlike(StringProperty<?> value)`
  `Expression`
  `nlikeIgnoreCase(String value)`
  `Expression`
  `nlikeIgnoreCase(StringProperty<?> value)`
  `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.
  `StringProperty<String>`
  `substring(int offset, int length)`
  `StringProperty<String>`
  `substring(NumericProperty<?> offset, NumericProperty<?> length)`
  `StringProperty<String>`
  `trim()`
  `StringProperty<String>`
  `upper()`

  ### Methods inherited from class BaseProperty

  `aggregate, asc, ascInsensitive, ascInsensitives, ascs, count, countDistinct, desc, descInsensitive, descInsensitives, descs, eq, eq, equals, function, function, getAlias, getExpression, getFrom, getFromAll, getName, getPath, getType, hashCode, in, in, in, isFalse, isNotNull, isNull, isTrue, ne, ne, nin, nin, nin, operator, operator, setIn, setInAll`
  Modifier and Type
  Method
  Description
  `<T> BaseProperty<T>`
  `aggregate(String function, Class<T> type)`
  `Ordering`
  `asc()`
  `Ordering`
  `ascInsensitive()`
  `Orderings`
  `ascInsensitives()`
  `Orderings`
  `ascs()`
  `NumericProperty<Long>`
  `count()`
  `NumericProperty<Long>`
  `countDistinct()`
  `Ordering`
  `desc()`
  `Ordering`
  `descInsensitive()`
  `Orderings`
  `descInsensitives()`
  `Orderings`
  `descs()`
  `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()`
  `CayennePath`
  `getPath()`
  `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)`
  `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.

  ### Methods inherited from class Object

  `clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface ComparableProperty

  `between, between, gt, gt, gtAll, gtAny, gte, gte, gteAll, gteAny, lt, lt, ltAll, ltAny, lte, lte, lteAll, lteAny, max, min`
  Modifier and Type
  Method
  Description
  `default Expression`
  `between(E lower, E upper)`
  `default Expression`
  `between(ComparableProperty<?> lower, ComparableProperty<?> upper)`
  `default Expression`
  `gt(E value)`
  `default Expression`
  `gt(ComparableProperty<?> value)`
  `default Expression`
  `gtAll(ColumnSelect<E> subquery)`
  `default Expression`
  `gtAny(ColumnSelect<E> subquery)`
  `default Expression`
  `gte(E value)`
  `default Expression`
  `gte(ComparableProperty<?> value)`
  `default Expression`
  `gteAll(ColumnSelect<E> subquery)`
  `default Expression`
  `gteAny(ColumnSelect<E> subquery)`
  `default Expression`
  `lt(E value)`
  `default Expression`
  `lt(ComparableProperty<?> value)`
  `default Expression`
  `ltAll(ColumnSelect<E> subquery)`
  `default Expression`
  `ltAny(ColumnSelect<E> subquery)`
  `default Expression`
  `lte(E value)`
  `default Expression`
  `lte(ComparableProperty<?> value)`
  `default Expression`
  `lteAll(ColumnSelect<E> subquery)`
  `default Expression`
  `lteAny(ColumnSelect<E> subquery)`
  `default BaseProperty<E>`
  `max()`
  `default BaseProperty<E>`
  `min()`

- ## Constructor Details

  - ### StringProperty

    protected StringProperty(CayennePath path, Expression expression, Class<E> type)
    Constructs a new property with the given name and expression
    Parameters:
      `path` - of the property (will be used as alias for the expression)
      `expression` - expression for property
      `type` - of the property
    See Also:
      - `PropertyFactory.createString(String, Expression, Class)`

- ## Method Details

  - ### like

    public Expression like(String pattern)
    Parameters:
      `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.
    Returns:
      An expression for a Database "LIKE" query.

  - ### like

    public Expression like(StringProperty<?> pattern)
    Parameters:
      `pattern` - a pattern matching property value. Pattern may include "_" and "%" wildcard symbols to match any single character or a sequence of characters.
    Returns:
      An expression for a Database "LIKE" query.

  - ### like

    public Expression like(String pattern, char escapeChar)
    Parameters:
      `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 "_".
    Returns:
      An expression for a Database "LIKE" query.

  - ### likeIgnoreCase

    public Expression likeIgnoreCase(String pattern)
    Returns:
      An expression for a case insensitive "LIKE" query.

  - ### likeIgnoreCase

    public Expression likeIgnoreCase(StringProperty<?> pattern)
    Returns:
      An expression for a case insensitive "LIKE" query.

  - ### nlike

    public Expression nlike(String value)
    Returns:
      An expression for a Database "NOT LIKE" query.

  - ### nlike

    public Expression nlike(StringProperty<?> value)
    Returns:
      An expression for a Database "NOT LIKE" query.

  - ### nlikeIgnoreCase

    public Expression nlikeIgnoreCase(String value)
    Returns:
      An expression for a case insensitive "NOT LIKE" query.

  - ### nlikeIgnoreCase

    public Expression nlikeIgnoreCase(StringProperty<?> value)
    Returns:
      An expression for a case insensitive "NOT LIKE" query.

  - ### contains

    public Expression contains(String substring)
    Creates an expression for a database "LIKE" query with the value converted to a pattern matching anywhere in the String.
    Parameters:
      `substring` - a String to match against property value. "_" and "%" symbols are NOT treated as wildcards and are escaped when converted to a LIKE expression.
    Returns:
      a newly created expression.

  - ### startsWith

    public 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.
    Parameters:
      `value` - a String to match against property value. "_" and "%" symbols are NOT treated as wildcards and are escaped when converted to a LIKE expression.
    Returns:
      a newly created expression.

  - ### endsWith

    public 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.
    Parameters:
      `value` - a String to match against property value. "_" and "%" symbols are NOT treated as wildcards and are escaped when converted to a LIKE expression.
    Returns:
      a newly created expression.

  - ### containsIgnoreCase

    public Expression containsIgnoreCase(String value)
    Same as `contains(String)`, only using case-insensitive comparison.

  - ### startsWithIgnoreCase

    public Expression startsWithIgnoreCase(String value)
    Same as `startsWith(String)`, only using case-insensitive comparison.

  - ### endsWithIgnoreCase

    public Expression endsWithIgnoreCase(String value)
    Same as `endsWith(String)`, only using case-insensitive comparison.

  - ### length

    public NumericProperty<Integer> length()
    See Also:
      - `FunctionExpressionFactory.lengthExp(Expression)`

  - ### locate

    public NumericProperty<Integer> locate(String string)
    See Also:
      - `FunctionExpressionFactory.locateExp(String, Expression)`

  - ### locate

    public NumericProperty<Integer> locate(StringProperty<? extends String> property)
    See Also:
      - `FunctionExpressionFactory.locateExp(Expression, Expression)`

  - ### trim

    public StringProperty<String> trim()
    See Also:
      - `FunctionExpressionFactory.trimExp(Expression)`

  - ### upper

    public StringProperty<String> upper()
    See Also:
      - `FunctionExpressionFactory.upperExp(Expression)`

  - ### lower

    public StringProperty<String> lower()
    See Also:
      - `FunctionExpressionFactory.lowerExp(Expression)`

  - ### concat

    public StringProperty<String> concat(Object... args)

    Arguments will be converted as follows:

    - if argument is a `BaseProperty` 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

    Usage:

            Property<String> fullName = Artist.FIRST_NAME.concat(" ", Artist.SECOND_NAME);

    See Also:
      - `FunctionExpressionFactory.concatExp(Expression...)`

  - ### substring

    public StringProperty<String> substring(int offset, int length)
    See Also:
      - `FunctionExpressionFactory.substringExp(Expression, int, int)`

  - ### substring

    public StringProperty<String> substring(NumericProperty<?> offset, NumericProperty<?> length)
    See Also:
      - `FunctionExpressionFactory.substringExp(Expression, Expression, Expression)`

  - ### alias

    public StringProperty<E> alias(String alias)
    Creates alias with different name for this property
    Overrides:
      `alias` in class `BaseProperty<E extends CharSequence>`

  - ### enclosing

    public StringProperty<E> enclosing()
    Description copied from class: `BaseProperty`
    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()))))

    Overrides:
      `enclosing` in class `BaseProperty<E extends CharSequence>`
    Returns:
      property that will be translated relative to a parent query