1 package com.github.javaparser.printer.lexicalpreservation.changes; 2 3 import com.github.javaparser.ast.Node; 4 import com.github.javaparser.ast.observer.ObservableProperty; 5 import com.github.javaparser.printer.concretesyntaxmodel.CsmConditional; 6 import com.github.javaparser.utils.Utils; 7 8 /** 9 * This represent a change happened to a specific Node. 10 */ 11 public interface Change { 12 13 default boolean evaluate(CsmConditional csmConditional, Node node) { 14 switch (csmConditional.getCondition()) { 15 case FLAG: 16 return (Boolean) getValue(csmConditional.getProperty(), node); 17 case IS_NOT_EMPTY: 18 return !Utils.valueIsNullOrEmpty(getValue(csmConditional.getProperty(), node)); 19 case IS_EMPTY: 20 return Utils.valueIsNullOrEmpty(getValue(csmConditional.getProperty(), node)); 21 case IS_PRESENT: 22 return !Utils.valueIsNullOrEmpty(getValue(csmConditional.getProperty(), node)); 23 default: 24 throw new UnsupportedOperationException("" + csmConditional.getProperty() + " " + csmConditional.getCondition()); 25 } 26 } 27 28 Object getValue(ObservableProperty property, Node node); 29 } 30