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

org.molgenis.data.support.AbstractWritable Maven / Gradle / Ivy

There is a newer version: 8.4.5
Show newest version
package org.molgenis.data.support;

import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Stream;
import org.molgenis.data.Entity;
import org.molgenis.data.Writable;

public abstract class AbstractWritable implements Writable {
  public enum EntityWriteMode {
    ENTITY_LABELS,
    ENTITY_IDS
  }

  public enum AttributeWriteMode {
    ATTRIBUTE_NAMES,
    ATTRIBUTE_LABELS
  }

  private EntityWriteMode entityWriteMode;
  private AttributeWriteMode attributeWriteMode;

  public EntityWriteMode getEntityWriteMode() {
    return entityWriteMode;
  }

  public void setEntityWriteMode(EntityWriteMode entityWriteMode) {
    this.entityWriteMode = entityWriteMode;
  }

  public AttributeWriteMode getAttributeWriteMode() {
    return attributeWriteMode;
  }

  public void setAttributeWriteMode(AttributeWriteMode attributeWriteMode) {
    this.attributeWriteMode = attributeWriteMode;
  }

  @Override
  public Integer add(Stream entities) {
    AtomicInteger count = new AtomicInteger(0);
    entities.forEach(
        entity -> {
          add(entity);
          count.incrementAndGet();
        });
    return count.get();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy