001/*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License").  You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
010 * or http://forgerock.org/license/CDDLv1.0.html.
011 * See the License for the specific language governing permissions
012 * and limitations under the License.
013 *
014 * When distributing Covered Code, include this CDDL HEADER in each
015 * file and include the License file at legal-notices/CDDLv1_0.txt.
016 * If applicable, add the following below this CDDL HEADER, with the
017 * fields enclosed by brackets "[]" replaced with your own identifying
018 * information:
019 *      Portions Copyright [yyyy] [name of copyright owner]
020 *
021 * CDDL HEADER END
022 *
023 *
024 *      Copyright 2013-2014 ForgeRock AS
025 */
026package org.opends.server.replication.server.changelog.api;
027
028import org.opends.server.replication.common.CSN;
029import org.opends.server.types.DN;
030
031/**
032 * The Change Number Index Record class represents records stored in the
033 * {@link ChangeNumberIndexDB}. It stores data about a change that happened with
034 * the replication.
035 */
036public final class ChangeNumberIndexRecord
037{
038
039  /** This is the key used to store this record. */
040  private final long changeNumber;
041  /** The baseDN where the change happened. */
042  private final DN baseDN;
043  /** The CSN of the change. */
044  private final CSN csn;
045
046  /**
047   * Builds an instance of this class.
048   *
049   * @param changeNumber
050   *          the change number
051   * @param baseDN
052   *          the baseDN
053   * @param csn
054   *          the replication CSN field
055   */
056  public ChangeNumberIndexRecord(long changeNumber, DN baseDN, CSN csn)
057  {
058    this.changeNumber = changeNumber;
059    this.baseDN = baseDN;
060    this.csn = csn;
061  }
062
063  /**
064   * Builds an instance of this class, with changeNumber equal to 0.
065   * @param baseDN
066   *          the baseDN
067   * @param csn
068   *          the replication CSN field
069   *
070   * @see #ChangeNumberIndexRecord(long, DN, CSN)
071   */
072  public ChangeNumberIndexRecord(DN baseDN, CSN csn)
073  {
074    this(0, baseDN, csn);
075  }
076
077  /**
078   * Getter for the baseDN field.
079   *
080   * @return the baseDN
081   */
082  public DN getBaseDN()
083  {
084    return baseDN;
085  }
086
087  /**
088   * Getter for the replication CSN field.
089   *
090   * @return The replication CSN field.
091   */
092  public CSN getCSN()
093  {
094    return csn;
095  }
096
097  /**
098   * Getter for the change number field.
099   *
100   * @return The change number field.
101   */
102  public long getChangeNumber()
103  {
104    return changeNumber;
105  }
106
107  /** {@inheritDoc} */
108  @Override
109  public String toString()
110  {
111    return "changeNumber=" + changeNumber + " csn=" + csn + " baseDN=" + baseDN;
112  }
113}