Package com.wavefront.agent.preprocessor
Class Preprocessor<T>
- java.lang.Object
-
- com.wavefront.agent.preprocessor.Preprocessor<T>
-
public class Preprocessor<T> extends Object
Generic container class for storing transformation and filter rules Created by Vasily on 9/13/16.
-
-
Constructor Summary
Constructors Constructor Description Preprocessor()Preprocessor(List<Function<T,T>> transformers, List<AnnotatedPredicate<T>> filters)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddFilter(int index, AnnotatedPredicate<T> filter)Register a filter rule and place it at a specific indexvoidaddFilter(AnnotatedPredicate<T> filter)Register a filter rulevoidaddTransformer(int index, Function<T,T> transformer)Register a transformation rule and place it at a specific indexvoidaddTransformer(Function<T,T> transformer)Register a transformation rulebooleanequals(Object obj)booleanfilter(T item)Apply all filter predicates sequentially, stop at the first "false" resultbooleanfilter(T item, String[] messageHolder)Apply all filter predicates sequentially, stop at the first "false" resultList<AnnotatedPredicate<T>>getFilters()Check all filter rules as an immutable listList<Function<T,T>>getTransformers()Get all transformer rules as an immutable listinthashCode()Preprocessor<T>merge(Preprocessor<T> other)Create a new preprocessor with rules merged from this and another preprocessor.Ttransform(T item)Apply all transformation rules sequentially
-
-
-
Method Detail
-
transform
public T transform(@Nonnull T item)
Apply all transformation rules sequentially- Parameters:
item- input point- Returns:
- transformed point
-
filter
public boolean filter(@Nonnull T item)
Apply all filter predicates sequentially, stop at the first "false" result- Parameters:
item- item to apply predicates to- Returns:
- true if all predicates returned "true"
-
filter
public boolean filter(@Nonnull T item, @Nullable String[] messageHolder)
Apply all filter predicates sequentially, stop at the first "false" result- Parameters:
item- item to apply predicates tomessageHolder- container to store additional output from predicate filters- Returns:
- true if all predicates returned "true"
-
getFilters
public List<AnnotatedPredicate<T>> getFilters()
Check all filter rules as an immutable list- Returns:
- filter rules
-
getTransformers
public List<Function<T,T>> getTransformers()
Get all transformer rules as an immutable list- Returns:
- transformer rules
-
merge
public Preprocessor<T> merge(Preprocessor<T> other)
Create a new preprocessor with rules merged from this and another preprocessor.- Parameters:
other- preprocessor to merge with.- Returns:
- merged preprocessor.
-
addTransformer
public void addTransformer(Function<T,T> transformer)
Register a transformation rule- Parameters:
transformer- rule
-
addFilter
public void addFilter(AnnotatedPredicate<T> filter)
Register a filter rule- Parameters:
filter- rule
-
addTransformer
public void addTransformer(int index, Function<T,T> transformer)Register a transformation rule and place it at a specific index- Parameters:
index- zero-based indextransformer- rule
-
addFilter
public void addFilter(int index, AnnotatedPredicate<T> filter)Register a filter rule and place it at a specific index- Parameters:
index- zero-based indexfilter- rule
-
-