001package io.ebean.event.changelog;
002
003/**
004 * Transaction state when ChangeSets are sent to the ChangeSetListener.
005 * <p>
006 * For large transactions multiple ChangeSets can be sent in a batch fashion and in this
007 * case all but the last changeSet with have IN_PROGRESS state and the last changeSet will
008 * have the COMMITTED or ROLLBACK state.
009 * </p>
010 */
011public enum TxnState {
012
013  /**
014   * The Transaction is still in progress.
015   * <p>
016   * Used when the transaction is large/long and Ebean wants to send out the changeSets
017   * in batches and a changeSet is send before the transaction has completed.
018   */
019  IN_PROGRESS("I"),
020
021  /**
022   * The Transaction was committed.
023   */
024  COMMITTED("C"),
025
026  /**
027   * The Transaction was rolled back.
028   */
029  ROLLBACK("R");
030
031  private final String code;
032
033  TxnState(String code) {
034    this.code = code;
035  }
036
037  /**
038   * Return the short code for the transaction state.
039   * <p>
040   * C - Committed, R - Rollback and I for In progress.
041   * </p>
042   */
043  public String getCode() {
044    return code;
045  }
046}