All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sirix.api.Moved Maven / Gradle / Ivy

package org.sirix.api;

import static com.google.common.base.Preconditions.checkNotNull;
import javax.annotation.Nullable;

import com.google.common.base.MoreObjects;

/**
 * Determines that a {@link NodeCursor} has been moved.
 *
 * @author Johannes Lichtenberger
 *
 * @param  the cursor instance
 */
public final class Moved extends Move {

  /** {@link NodeCursor} implementation. */
  private final T mNodeCursor;

  /**
   * Constructor.
   *
   * @param nodeCursor the cursor which has been moved
   */
  public Moved(final T nodeCursor) {
    mNodeCursor = checkNotNull(nodeCursor);
  }

  @Override
  public boolean hasMoved() {
    return true;
  }

  @Override
  public T trx() {
    return mNodeCursor;
  }

  @Override
  public boolean equals(final @Nullable Object object) {
    if (this == object)
      return true;

    if (!(object instanceof Moved))
      return false;

    final Moved other = (Moved) object;
    return mNodeCursor.equals(other.mNodeCursor);
  }

  @Override
  public int hashCode() {
    return 0x598df91c + mNodeCursor.hashCode();
  }

  @Override
  public String toString() {
    return MoreObjects.toStringHelper(this).add("cursor", mNodeCursor).toString();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy