51 lines
1.3 KiB
Java
51 lines
1.3 KiB
Java
package be.jeffcheasey88.peeratcode.parser.java.operation;
|
|
|
|
import java.util.List;
|
|
import java.util.function.Function;
|
|
|
|
import be.jeffcheasey88.peeratcode.parser.Token;
|
|
import be.jeffcheasey88.peeratcode.parser.java.JavaElement;
|
|
import be.jeffcheasey88.peeratcode.parser.java.Operation;
|
|
import be.jeffcheasey88.peeratcode.parser.java.Value;
|
|
|
|
public class MethodCallOperation extends Operation{
|
|
|
|
private Value start;
|
|
private MethodCallOperation previous;
|
|
private Token path;
|
|
private List<Value> parameters;
|
|
|
|
public MethodCallOperation(Value start, Token path, List<Value> parameters){
|
|
this.start = start;
|
|
this.path = path;
|
|
this.parameters = parameters;
|
|
}
|
|
|
|
public MethodCallOperation(MethodCallOperation previous, Token path, List<Value> parameters){
|
|
this((Value)null, path, parameters);
|
|
this.previous = previous;
|
|
}
|
|
|
|
public MethodCallOperation getPrevious(){
|
|
return this.previous;
|
|
}
|
|
|
|
public Token getPath(){
|
|
return path;
|
|
}
|
|
|
|
public List<Value> getParameters(){
|
|
return this.parameters;
|
|
}
|
|
|
|
@Override
|
|
public <E extends JavaElement> E find(Function<JavaElement, Boolean> finder) {
|
|
if(finder.apply(start)) return (E)start;
|
|
if(finder.apply(previous)) return (E) previous;
|
|
for(Value param : this.parameters){
|
|
if(finder.apply(param)) return (E)param;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
}
|