use of org.freud.analysed.javasource.CodeBlock in project freud by LMAX-Exchange.
the class CodeBlockMatchers method hasMethodCall.
public static FreudExtendedMatcher<CodeBlock> hasMethodCall(final String methodCall) {
return new FreudExtendedMatcher<CodeBlock>() {
private final String methodName;
private final String[] instanceReferences;
{
String[] values = methodCall.split("\\.");
instanceReferences = new String[values.length - 1];
System.arraycopy(values, 0, instanceReferences, 0, instanceReferences.length);
methodName = values[values.length - 1];
}
@Override
protected boolean matchesSafely(final CodeBlock toBeAnalysed) {
List<MethodCall> methodCallList = toBeAnalysed.getMethodCallListByMethodName(methodName);
if (methodCallList != null) {
for (MethodCall methodCall : methodCallList) {
if (Arrays.equals(instanceReferences, methodCall.getInstanceReferences())) {
return true;
}
}
}
return false;
}
@Override
public void describeTo(final Description description) {
description.appendText("HasMethodCall(" + methodCall + ")");
}
};
}
Aggregations