001package com.avaje.ebean.config;
002
003/**
004 * Represents a Property of a Compound Value Object.
005 * <p>
006 * For each property in a {@link CompoundType} you need an implementation of
007 * this CompoundTypeProperty interface.
008 * 
009 * </p>
010 * 
011 * @author rbygrave
012 * 
013 * @param <V>
014 *          The type of the Compound value object
015 * @param <P>
016 *          The type of the property
017 * 
018 * @see CompoundType
019 * @see ScalarTypeConverter
020 */
021public interface CompoundTypeProperty<V, P> {
022
023  /**
024   * The name of this property.
025   */
026  String getName();
027
028  /**
029   * Return the property value from the containing compound value object.
030   * 
031   * @param valueObject
032   *          the compound value object
033   * @return the property value.
034   */
035  P getValue(V valueObject);
036
037  /**
038   * This should <b>ONLY</b> be used when the persistence type is different from
039   * the logical type returned. It most cases just return 0 and Ebean will
040   * persist the logical type.
041   * <p>
042   * Typically this should be used when the logical type is long but the
043   * persistence type is java.sql.Timestamp. In this case return
044   * java.sql.Types.TIMESTAMP (rather than 0).
045   * </p>
046   * 
047   * @return Return the java.sql.Type that you want to use to persist this
048   *         property or 0 and Ebean will use the logical type.
049   */
050  int getDbType();
051}