34 lines
814 B
Java
34 lines
814 B
Java
package dev.peerat.parser.java.operation;
|
|
|
|
import java.util.List;
|
|
import java.util.function.Function;
|
|
|
|
import dev.peerat.parser.java.JavaElement;
|
|
import dev.peerat.parser.java.Value;
|
|
|
|
public class IfOperation extends OperationBag{
|
|
|
|
private Value condition;
|
|
|
|
public IfOperation(Value condition){
|
|
super();
|
|
this.condition = condition;
|
|
}
|
|
|
|
public Value getCondition(){
|
|
return this.condition;
|
|
}
|
|
|
|
@Override
|
|
public <E extends JavaElement> E find(Function<JavaElement, Boolean> finder){
|
|
if(finder.apply(condition)) return (E)condition;
|
|
return super.find(finder);
|
|
}
|
|
|
|
@Override
|
|
public <E extends JavaElement> void findAll(Function<JavaElement, Boolean> finder, List<E> list){
|
|
if(finder.apply(condition)) list.add((E)condition);
|
|
condition.findAll(finder, list);
|
|
super.findAll(finder, list);
|
|
}
|
|
}
|