001package io.ebean.plugin;
002
003import io.ebean.bean.EntityBean;
004import io.ebean.text.StringParser;
005
006/**
007 * A dot notation expression path.
008 */
009public interface ExpressionPath {
010
011  /**
012   * Return true if there is a property on the path that is a many property.
013   */
014  boolean containsMany();
015
016  /**
017   * Return the value from a given entity bean.
018   */
019  Object pathGet(Object bean);
020
021  /**
022   * Set a value to the bean for this expression path.
023   *
024   * @param bean  the bean to set the value on
025   * @param value the value to set
026   */
027  void pathSet(Object bean, Object value);
028
029  /**
030   * Convert the value to the expected type.
031   * <p>
032   * Typically useful for converting strings to the appropriate number type etc.
033   * </p>
034   */
035  Object convert(Object value);
036
037  /**
038   * Return the default StringParser for the scalar property.
039   */
040  StringParser stringParser();
041
042  /**
043   * Deprecated migrate to stringParser().
044   */
045  @Deprecated
046  default StringParser getStringParser() {
047    return stringParser();
048  }
049
050  /**
051   * For DateTime capable scalar types convert the long systemTimeMillis into
052   * an appropriate java time (Date,Timestamp,Time,Calendar, JODA type etc).
053   */
054  Object parseDateTime(long systemTimeMillis);
055
056  /**
057   * Return true if the last type is "DateTime capable" - can support
058   * {@link #parseDateTime(long)}.
059   */
060  boolean isDateTimeCapable();
061
062  /**
063   * Return the underlying JDBC type or 0 if this is not a scalar type.
064   */
065  int jdbcType();
066
067  /**
068   * Deprecated migrate to jdbcType().
069   */
070  @Deprecated
071  default int getJdbcType() {
072    return jdbcType();
073  }
074
075  /**
076   * Return true if this is an ManyToOne or OneToOne associated bean property.
077   */
078  boolean isAssocId();
079
080  /**
081   * Return the Id expression string.
082   * <p>
083   * Typically used to produce id = ? expression strings.
084   * </p>
085   */
086  String assocIdExpression(String propName, String bindOperator);
087
088  /**
089   * Deprecated migrate to assocIdExpression().
090   */
091  @Deprecated
092  default String getAssocIdExpression(String propName, String bindOperator) {
093    return assocIdExpression(propName, bindOperator);
094  }
095
096  /**
097   * Return the Id values for the given bean value.
098   */
099  Object[] assocIdValues(EntityBean bean);
100
101  /**
102   * Deprecated migrate to assocIdValues().
103   */
104  @Deprecated
105  default Object[] getAssocIdValues(EntityBean bean) {
106    return assocIdValues(bean);
107  }
108
109  /**
110   * Return the underlying bean property.
111   */
112  Property property();
113
114  /**
115   * Deprecated migrate to property().
116   */
117  @Deprecated
118  default Property getProperty() {
119    return property();
120  }
121
122  /**
123   * The ElPrefix plus name.
124   */
125  String elName();
126
127  /**
128   * Deprecated migrate to elName().
129   */
130  @Deprecated
131  default String getElName() {
132    return elName();
133  }
134}