001package io.ebean;
002
003import java.sql.Timestamp;
004import java.util.Map;
005
006/**
007 * Wraps a version of a @History bean.
008 */
009public class Version<T> {
010
011  /**
012   * The version of the bean.
013   */
014  protected T bean;
015
016  /**
017   * The effective start date time of this version.
018   */
019  protected Timestamp start;
020
021  /**
022   * The effective end date time of this version.
023   */
024  protected Timestamp end;
025
026  /**
027   * The map of changed properties.
028   */
029  protected Map<String, ValuePair> diff;
030
031  /**
032   * Construct with bean and an effective date time range.
033   */
034  public Version(T bean, Timestamp start, Timestamp end) {
035    this.bean = bean;
036    this.start = start;
037    this.end = end;
038  }
039
040  /**
041   * Default constructor - useful for JSON tools such as Jackson.
042   */
043  public Version() {
044  }
045
046  /**
047   * Return the bean instance for this version.
048   */
049  public T getBean() {
050    return bean;
051  }
052
053  /**
054   * Set the bean instance for this version.
055   */
056  public void setBean(T bean) {
057    this.bean = bean;
058  }
059
060  /**
061   * Return the effective start date time of this version.
062   */
063  public Timestamp getStart() {
064    return start;
065  }
066
067  /**
068   * Set the effective start date time of this version.
069   */
070  public void setStart(Timestamp start) {
071    this.start = start;
072  }
073
074  /**
075   * Return the effective end date time of this version.
076   */
077  public Timestamp getEnd() {
078    return end;
079  }
080
081  /**
082   * Set the effective end date time of this version.
083   */
084  public void setEnd(Timestamp end) {
085    this.end = end;
086  }
087
088  /**
089   * Set the map of differences from this bean to the prior version.
090   */
091  public void setDiff(Map<String, ValuePair> diff) {
092    this.diff = diff;
093  }
094
095  /**
096   * Return the map of differences from this bean to the prior version.
097   */
098  public Map<String, ValuePair> getDiff() {
099    return diff;
100  }
101}