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

io.annot8.common.data.content.DefaultRow Maven / Gradle / Ivy

The newest version!
/* Annot8 (annot8.io) - Licensed under Apache-2.0. */
package io.annot8.common.data.content;

import java.util.List;
import java.util.Optional;

public class DefaultRow implements Row {

  private final int index;
  private final List columnNames;
  private final List data;

  public DefaultRow(int index, List columnNames, List data) {
    this.index = index;
    this.columnNames = columnNames;
    this.data = data;
  }

  @Override
  public List getColumnNames() {
    return columnNames;
  }

  @Override
  public int getColumnCount() {
    return data.size();
  }

  @Override
  public int getRowIndex() {
    return index;
  }

  @Override
  public Optional getValueAt(int index) {
    if (index < 0 || index > data.size() - 1) {
      return Optional.empty();
    }
    return Optional.ofNullable(data.get(index));
  }
}