001package io.ebean.typequery;
002
003import io.ebean.ExpressionList;
004
005/**
006 * A property used in type query.
007 *
008 * @param <R> The type of the owning root bean
009 */
010public class TQProperty<R> {
011
012  protected final String _name;
013
014  protected final R _root;
015
016  /**
017   * Construct with a property name and root instance.
018   *
019   * @param name the name of the property
020   * @param root the root query bean instance
021   */
022  public TQProperty(String name, R root) {
023    this(name, root, null);
024  }
025
026  /**
027   * Construct with additional path prefix.
028   */
029  public TQProperty(String name, R root, String prefix) {
030    this._root = root;
031    this._name = TQPath.add(prefix, name);
032  }
033
034  public String toString() {
035    return _name;
036  }
037
038  /**
039   * Internal method to return the underlying expression list.
040   */
041  protected ExpressionList<?> expr() {
042    return ((TQRootBean) _root).peekExprList();
043  }
044
045  /**
046   * Return the property name.
047   */
048  protected String propertyName() {
049    return _name;
050  }
051
052  /**
053   * Is null.
054   */
055  public R isNull() {
056    expr().isNull(_name);
057    return _root;
058  }
059
060  /**
061   * Is not null.
062   */
063  public R isNotNull() {
064    expr().isNotNull(_name);
065    return _root;
066  }
067
068}