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

com.scalar.db.storage.cosmos.MapVisitor Maven / Gradle / Ivy

Go to download

A universal transaction manager that achieves database-agnostic transactions and distributed transactions that span multiple databases

The newest version!
package com.scalar.db.storage.cosmos;

import com.scalar.db.io.BigIntColumn;
import com.scalar.db.io.BlobColumn;
import com.scalar.db.io.BooleanColumn;
import com.scalar.db.io.ColumnVisitor;
import com.scalar.db.io.DoubleColumn;
import com.scalar.db.io.FloatColumn;
import com.scalar.db.io.IntColumn;
import com.scalar.db.io.TextColumn;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.concurrent.NotThreadSafe;

/**
 * A visitor to make a map to be used to create {@link Record}
 *
 * @author Yuji Ito
 */
@NotThreadSafe
public class MapVisitor implements ColumnVisitor {
  private final Map values = new HashMap<>();

  @SuppressFBWarnings("EI_EXPOSE_REP")
  public Map get() {
    return values;
  }

  @Override
  public void visit(BooleanColumn column) {
    values.put(column.getName(), column.hasNullValue() ? null : column.getBooleanValue());
  }

  @Override
  public void visit(IntColumn column) {
    values.put(column.getName(), column.hasNullValue() ? null : column.getIntValue());
  }

  @Override
  public void visit(BigIntColumn column) {
    values.put(column.getName(), column.hasNullValue() ? null : column.getBigIntValue());
  }

  @Override
  public void visit(FloatColumn column) {
    values.put(column.getName(), column.hasNullValue() ? null : column.getFloatValue());
  }

  @Override
  public void visit(DoubleColumn column) {
    values.put(column.getName(), column.hasNullValue() ? null : column.getDoubleValue());
  }

  @Override
  public void visit(TextColumn column) {
    values.put(column.getName(), column.hasNullValue() ? null : column.getTextValue());
  }

  @Override
  public void visit(BlobColumn column) {
    values.put(column.getName(), column.hasNullValue() ? null : column.getBlobValue());
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy