001package io.ebean;
002
003/**
004 * Bean holding the details to update the document store.
005 */
006public final class DocStoreQueueEntry {
007
008  /**
009   * Action to either update or delete a document from the index.
010   */
011  public enum Action {
012
013    /**
014     * Action is to update a document in the doc store.
015     */
016    INDEX(1),
017
018    /**
019     * Action is to delete a document from the doc store..
020     */
021    DELETE(2),
022
023    /**
024     * An update is required based on a change to a nested/embedded object at a given path.
025     */
026    NESTED(3);
027
028    int value;
029
030    Action(int value) {
031      this.value = value;
032    }
033
034    /**
035     * Return the value associated with this action type.
036     */
037    public int getValue() {
038      return value;
039    }
040  }
041
042  private final Action type;
043
044  private final String queueId;
045
046  private final String path;
047
048  private final Object beanId;
049
050  /**
051   * Construct for an INDEX or DELETE action.
052   */
053  public DocStoreQueueEntry(Action type, String queueId, Object beanId) {
054    this(type, queueId, null, beanId);
055  }
056
057  /**
058   * Construct for an NESTED/embedded path invalidation action.
059   */
060  public DocStoreQueueEntry(Action type, String queueId, String path, Object beanId) {
061    this.type = type;
062    this.queueId = queueId;
063    this.path = path;
064    this.beanId = beanId;
065  }
066
067  /**
068   * Return the event type.
069   */
070  public Action getType() {
071    return type;
072  }
073
074  /**
075   * Return the associate queueId.
076   */
077  public String getQueueId() {
078    return queueId;
079  }
080
081  /**
082   * Return the path if this is a nested update.
083   */
084  public String getPath() {
085    return path;
086  }
087
088  /**
089   * Return the bean id (which matches the document id).
090   */
091  public Object getBeanId() {
092    return beanId;
093  }
094}