peer-at-code-parser-java/src/dev/peerat/parser/java/operation/TryOperation.java

44 lines
989 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.Variable;
public class TryOperation extends OperationBag{
private Variable resource;
public TryOperation(){
super();
}
public TryOperation(Variable resource){
this();
this.resource = resource;
}
public Variable getResource(){
return this.resource;
}
@Override
public <E extends JavaElement> E find(Function<JavaElement, Boolean> finder){
return resource != null ? finder.apply(resource) ? (E)resource : super.find(finder) : super.find(finder);
}
@Override
public <E extends JavaElement> void findAll(Function<JavaElement, Boolean> finder, List<E> list){
if(resource != null){
if(finder.apply(resource)) list.add((E) resource);
resource.findAll(finder, list);
}
super.findAll(finder, list);
}
@Override
public void build(Builder builder) throws Exception {
}
}