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

fr.figarocms.flume.formatter.config.Formatter Maven / Gradle / Ivy

package fr.figarocms.flume.formatter.config;

import com.cloudera.flume.core.Event;
import com.google.common.collect.Maps;
import fr.figarocms.flume.formatter.mapping.Mapping;

import java.util.Map;

public class Formatter {

  private Mapping mapping;
  private Map format;

  public void setMapping(Mapping mapping) {
    this.mapping = mapping;
  }

  public void setFormat(Map format) {
    this.format = format;
  }

  public Map format(Event e) {
    if (mapping == null) {
      mapping = new Mapping();
    }

    Map objectMap = mapping.map(e);
    if (format == null) {
      return objectMap;
    }
    return Maps.transformValues(format, new FormatValueTransformer(objectMap));
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy