io.ebean.MethodCalls Maven / Gradle / Ivy
package io.ebean;
import java.util.ArrayList;
import java.util.List;
/**
* Created by rob on 17/07/15.
*/
public class MethodCalls {
List list = new ArrayList<>();
public void add(MethodCall call) {
list.add(call);
}
public int size() {
return list.size();
}
public List all() {
return list;
}
public List save() {
return matches(DelegateMethodNames.SAVE);
}
public List insert() {
return matches(DelegateMethodNames.INSERT);
}
public List update() {
return matches(DelegateMethodNames.UPDATE);
}
public List delete() {
return matches(DelegateMethodNames.DELETE);
}
protected List matches(String methodName) {
List matches = new ArrayList<>();
for (MethodCall call : list) {
if (isMatch(call, methodName)) {
matches.add(call);
}
}
return matches;
}
protected static boolean isMatch(MethodCall call, String methodName) {
return call.name.equals(methodName);
}
}