Interface Transformer<T>
- All Known Implementing Classes:
CollapseNestedNonEditedAnnotations,CutNonEditedSubtrees,EliminateEmptyAlternatives,FeatureExpressionFilter,LabelWithEditClass,NaiveMovedArtifactDetection,RelabelNodes,RelabelRoot,RevertSomeChanges
public interface Transformer<T>
Models an operation that changes an object of type T inplace (i.e., the object is altered).
To model further assumptions on the given elements T (i.e., assumptions that cannot easily be expressed as a type),
Transformers may have dependencies to other transformers, which should be applied first.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> voidapply(List<? extends Transformer<T>> transformers, T element) Applies all given transformers to the given element sequentially.static <T> voidcheckDependencies(List<? extends Transformer<T>> transformers) Checks that the dependencies of all given transformers are satisfied when applying the transformers sequentially.default List<Class<? extends Transformer<T>>> Returns a list of dependencies to other transformers.voidApply a transformation to the given Object inplace.
-
Method Details
-
transform
Apply a transformation to the given Object inplace. The object will be changed.- Parameters:
element- The T object to transform.
-
getDependencies
Returns a list of dependencies to other transformers. A transformer should only be run, if another transformation with the respective type was run for each type on the dependencies.- Returns:
- List of types of which instances should be run before applying this transformation.
-
checkDependencies
Checks that the dependencies of all given transformers are satisfied when applying the transformers sequentially.- Parameters:
transformers- The transformers whose dependencies to check.- Throws:
RuntimeException- when a dependency is not met.
-
apply
Applies all given transformers to the given element sequentially. First checks that all dependencies between transformers are met viacheckDependencies(List).- Parameters:
transformers- Transformers to apply sequentially.element- Tree to transform inplace.
-