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

com.rollbar.notifier.transformer.TransformerPipeline Maven / Gradle / Ivy

Go to download

For connecting your applications built on the JVM to Rollbar for Error Reporting

The newest version!
package com.rollbar.notifier.transformer;

import com.rollbar.api.payload.data.Data;
import java.util.List;

/**
 * Utility to create a pipeline of {@link Transformer transformers} to transform
 * the {@link Data data}.
 */
public class TransformerPipeline implements Transformer {

  private final List pipeline;

  /**
   * Constructor.
   */
  public TransformerPipeline() {
    this(null);
  }

  /**
   * Constructor.
   * @param pipeline the list of transformers.
   */
  public TransformerPipeline(List pipeline) {
    this.pipeline = pipeline;
  }


  @Override
  public Data transform(Data data) {
    if (usePipeline()) {
      return pipeline(data);
    }

    return data;
  }

  private boolean usePipeline() {
    return pipeline != null && !pipeline.isEmpty();
  }

  private Data pipeline(Data data) {
    for (Transformer transformer : pipeline) {
      data = transformer.transform(data);
    }
    return data;
  }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy