cdc.mf.transform.MfElementFixer Maven / Gradle / Ivy
package cdc.mf.transform;
import cdc.mf.model.MfAbstractElement;
/**
* Interface used to fix an element.
*
* A source element is transformed into a target element with the same type.
*
* @author Damien Carbonne
*
* @param The element type.
* @param The element builder type.
*/
@FunctionalInterface
public interface MfElementFixer> {
/**
* Fix an element.
*
* @param srcElement The source element.
* @param tgtBuilder The target element builder.
*/
public void fix(E srcElement,
B tgtBuilder);
/**
* Returns a fixer that combines this one followed another one.
*
* @param after The other fixer, applied after this one.
* @return A fixer that combines this one and {@code after}.
*/
public default MfElementFixer andThen(MfElementFixer after) {
return (srcElement,
tgtBuilder) -> {
this.fix(srcElement, tgtBuilder);
after.fix(srcElement, tgtBuilder);
};
}
/**
* Returns a fixer that combines this one following another one.
*
* @param before The other fixer, applied before this one.
* @return A fixer that combines {@code before} and this one.
*/
public default MfElementFixer compose(MfElementFixer before) {
return (srcElement,
tgtBuilder) -> {
before.fix(srcElement, tgtBuilder);
this.fix(srcElement, tgtBuilder);
};
}
}