blob: 23fe09dce5e8ac0501bc16fbfbbc2cbbaf79df7c [file] [log] [blame]
package com.github.javaparser.printer.lexicalpreservation.changes;
import com.github.javaparser.ast.Node;
import com.github.javaparser.ast.observer.ObservableProperty;
import com.github.javaparser.printer.concretesyntaxmodel.CsmConditional;
import com.github.javaparser.utils.Utils;
/**
* This represent a change happened to a specific Node.
*/
public interface Change {
default boolean evaluate(CsmConditional csmConditional, Node node) {
switch (csmConditional.getCondition()) {
case FLAG:
return (Boolean) getValue(csmConditional.getProperty(), node);
case IS_NOT_EMPTY:
return !Utils.valueIsNullOrEmpty(getValue(csmConditional.getProperty(), node));
case IS_EMPTY:
return Utils.valueIsNullOrEmpty(getValue(csmConditional.getProperty(), node));
case IS_PRESENT:
return !Utils.valueIsNullOrEmpty(getValue(csmConditional.getProperty(), node));
default:
throw new UnsupportedOperationException("" + csmConditional.getProperty() + " " + csmConditional.getCondition());
}
}
Object getValue(ObservableProperty property, Node node);
}