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 Type
    Method
    Description
    static <T> void
    apply(List<? extends Transformer<T>> transformers, T element)
    Applies all given transformers to the given element sequentially.
    static <T> void
    checkDependencies(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.
    void
    transform(T element)
    Apply a transformation to the given Object inplace.
  • Method Details

    • transform

      void transform(T element)
      Apply a transformation to the given Object inplace. The object will be changed.
      Parameters:
      element - The T object to transform.
    • getDependencies

      default List<Class<? extends Transformer<T>>> 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

      static <T> void checkDependencies(List<? extends Transformer<T>> transformers)
      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

      static <T> void apply(List<? extends Transformer<T>> transformers, T element)
      Applies all given transformers to the given element sequentially. First checks that all dependencies between transformers are met via checkDependencies(List).
      Parameters:
      transformers - Transformers to apply sequentially.
      element - Tree to transform inplace.