
package de.ivu.elect.presentation.table;

import javax.annotation.Nullable;

import de.ivu.elect.jee.entity.EagerLoading;
import de.ivu.elect.jee.entity.Entity;
import de.ivu.elect.jee.presentation.dynamictable.ColumnType;

public class ColorColumnEntryWrapper<E extends Entity< ? , ? >> extends AbstractColumnEntry<E> {

  private static final long serialVersionUID = 1L;

  private final AbstractColumnEntry<E> other;

  public ColorColumnEntryWrapper(AbstractColumnEntry<E> other) {
    super(other.getMessages());

    this.other = other;
  }

  @Override
  public boolean isRendered() {
    return other.isRendered();
  }

  @Override
  public String getName() {
    return other.getName();
  }

  @Override
  public ColumnType getType() {
    return ColumnType.COLOR;
  }

  @Override
  public String getHeader() {
    return other.getHeader();
  }

  @Override
  public Object getValue(E entity) {
    return other.getValue(entity);
  }

  @Override
  public boolean isIconPresent() {
    return other.isIconPresent();
  }

  @Nullable
  @Override
  public EagerLoading getEagerLoading() {
    return other.getEagerLoading();
  }

  @Override
  public int hashCode() {
    return other.hashCode();
  }

  @Override
  public boolean equals(Object obj) {
    if (super.equals(obj)) {
      return true;
    }

    if (obj instanceof ColorColumnEntryWrapper) {
      return other.equals(((ColorColumnEntryWrapper) obj).other);
    }

    return false;
  }

  public static <E extends Entity< ? , ? >> ColorColumnEntryWrapper<E> wrap(AbstractColumnEntry<E> other) {
    return new ColorColumnEntryWrapper<>(other);
  }
}
