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 find(Function finder){ return resource != null ? finder.apply(resource) ? (E)resource : super.find(finder) : super.find(finder); } @Override public void findAll(Function finder, List 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 { } }