001package io.ebean.typequery;
002
003/**
004 * Array property with E as the element type.
005 *
006 * @param <R> the root query bean type
007 * @param <E> the element type of the DbArray
008 */
009public class PArray<R, E> extends TQPropertyBase<R> {
010
011  /**
012   * Construct with a property name and root instance.
013   *
014   * @param name property name
015   * @param root the root query bean instance
016   */
017  public PArray(String name, R root) {
018    super(name, root);
019  }
020
021  /**
022   * Construct with additional path prefix.
023   */
024  public PArray(String name, R root, String prefix) {
025    super(name, root, prefix);
026  }
027
028  /**
029   * ARRAY contains the values.
030   * <p>
031   * <pre>{@code
032   *
033   *   new QContact()
034   *    .phoneNumbers.contains("4321")
035   *    .findList();
036   *
037   * }</pre>
038   *
039   * @param values The values that should be contained in the array
040   */
041  @SafeVarargs
042  public final R contains(E... values) {
043    expr().arrayContains(_name, (Object[]) values);
044    return _root;
045  }
046
047  /**
048   * ARRAY does not contain the values.
049   * <p>
050   * <pre>{@code
051   *
052   *   new QContact()
053   *    .phoneNumbers.notContains("4321")
054   *    .findList();
055   *
056   * }</pre>
057   *
058   * @param values The values that should not be contained in the array
059   */
060  @SafeVarargs
061  public final R notContains(E... values) {
062    expr().arrayNotContains(_name, (Object[]) values);
063    return _root;
064  }
065
066  /**
067   * ARRAY is empty.
068   * <p>
069   * <pre>{@code
070   *
071   *   new QContact()
072   *    .phoneNumbers.isEmpty()
073   *    .findList();
074   *
075   * }</pre>
076   */
077  public R isEmpty() {
078    expr().arrayIsEmpty(_name);
079    return _root;
080  }
081
082  /**
083   * ARRAY is not empty.
084   * <p>
085   * <pre>{@code
086   *
087   *   new QContact()
088   *    .phoneNumbers.isNotEmpty()
089   *    .findList();
090   *
091   * }</pre>
092   */
093  public R isNotEmpty() {
094    expr().arrayIsNotEmpty(_name);
095    return _root;
096  }
097
098}