Log = require('../log/Log.coffee').Log
Logable = require('../log/RandomAccessLoggable.coffee').RandomAccessLoggable

#import jetbrains.exodus.database.ByteIterable;
#import jetbrains.exodus.log.Loggable;
#import jetbrains.exodus.tree.INode;
#import jetbrains.exodus.tree.LongIterator;
#import org.jetbrains.annotations.NotNull;

#/**
#* Base implementation of leaf node
#*/
#abstract class BaseLeafNode implements ILeafNode {

class BaseLeafNode
#@Override
#public boolean equals(Object obj) {
#return this == obj || (obj instanceof INode && getKey().equals(((INode) obj).getKey()));
#}
  equals: (obj) ->
    return this = obj || getKey().equals(obj.getKey())

#@Override
#public boolean hasValue() {
#return true;
#}
  hasValue: () ->
    return true

#@Override
#public boolean isDupLeaf() {
#return false;
#}
  isDupLeaf: () ->
    return false

#@Override
#public int hashCode() {
#return getKey().hashCode();
#}
  hashCode: () ->
    return @getKey().hashCode()

#@Override
#public long getAddress() {
#return Loggable.NULL_ADDRESS;
#}
  getAddress: () ->
    return Loggable.NULL_ADDRESS

#@Override
#@NotNull
#public BTreeBase getTree() {
#throw new UnsupportedOperationException();
#}
  getTree: () ->
    console.log "Unsupported operation exception"

#@Override
#@NotNull
#public LongIterator addressIterator() {
#return LongIterator.EMPTY;
#}
  addressIterator: () ->
# TODO

#@Override
#public boolean isDup() {
#return false;
#}
  isDup: () ->
    false

#@Override
#public long getDupCount() {
#return 1;
#}
  getDupCount: () ->
    return 1

#@Override
#public boolean valueExists(@NotNull ByteIterable value) {
#return compareValueTo(value) == 0;
#}
  valueExists: (value) ->
    return @compareValueTo(value) == 0

#@Override
#public int compareKeyTo(@NotNull final ByteIterable iterable) {
#return getKey().compareTo(iterable);
#}
  compareKeyTo: (iterable) ->
    return @getKey().compareTo(iterable)

#@Override
#public int compareValueTo(@NotNull final ByteIterable iterable) {
#return getValue().compareTo(iterable);
#}
  compareValueTo: (iterable) ->
    return @getValue().compareTo(iterable)

#@Override
#public String toString() {
#return "LN {key:" + getKey().toString() + "} @ " + getAddress();
#}
  toString: () ->
    return "LN {key:" + @getKey().toString() + "} @ " + @getAddress()

#@Override
#public void dump(PrintStream out, int level, ToString renderer) {
#BasePage.indent(out, level);
#out.println(renderer == null ? toString() : renderer.toString(this));
#}

