use of com.tngtech.archunit.PublicAPI in project ArchUnit by TNG.
the class ProxyRules method directly_call_other_methods_declared_in_the_same_class_that.
/**
* Returns a condition that matches classes that directly calls other methods
* declared in the same class that matches the given predicate.
*
* <p>
* For an example, see {@link #directly_call_other_methods_declared_in_the_same_class_that_are_annotated_with(Class)}
* </p>
*/
@PublicAPI(usage = ACCESS)
public static ArchCondition<JavaClass> directly_call_other_methods_declared_in_the_same_class_that(final DescribedPredicate<? super MethodCallTarget> predicate) {
return new ArchCondition<JavaClass>("directly call other methods declared in the same class that " + predicate.getDescription()) {
@Override
public void check(JavaClass javaClass, ConditionEvents events) {
for (JavaMethodCall call : javaClass.getMethodCallsFromSelf()) {
boolean satisfied = call.getOriginOwner().equals(call.getTargetOwner()) && predicate.test(call.getTarget());
events.add(new SimpleConditionEvent(call, satisfied, call.getDescription()));
}
}
};
}
Aggregations