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

io.annot8.common.data.bounds.MultiCellData Maven / Gradle / Ivy

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

import java.util.Collection;
import java.util.Map;
import java.util.Optional;

public class MultiCellData {

  private final Map data;
  private final Map columnNames;

  public MultiCellData(Map data, Map columnNames) {
    this.data = data;
    this.columnNames = columnNames;
  }

  public Collection getColumns() {
    return data.keySet();
  }

  public Map getColumnNames() {
    return columnNames;
  }

  public Map getData() {
    return data;
  }

  public  Optional getDataForColumn(String columnName, Class requiredClass) {
    if (getColumnNames().containsKey(columnName)) {
      return getDataForColumn(getColumnNames().get(columnName), requiredClass);
    }
    return Optional.empty();
  }

  public  Optional getDataForColumn(int column, Class requiredClass) {
    if (data.containsKey(column)) {
      Object value = data.get(column);
      if (requiredClass.isAssignableFrom(value.getClass())) {
        return Optional.of(requiredClass.cast(value));
      }
    }
    return Optional.empty();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy