Skip to content

How to check that an interface overrides methods in parent interface #1047

Answered by hankem
armandino asked this question in Q&A
Discussion options

You must be logged in to vote

For now, you could define a custom check similar to the one that is currently being developed in #1040:

public boolean isOverridden(JavaMethod method) {
    return Stream.concat(method.getOwner().getAllRawSuperclasses().stream(), method.getOwner().getAllRawInterfaces().stream())
            .map(JavaClass::getAllMethods)
            .flatMap(Set<JavaMethod>::stream)
            .anyMatch(superMethod ->
                        superMethod.getName().equals(method.getName()) &&
                        superMethod.getParameterTypes().equals(method.getParameterTypes())
            );
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@armandino
Comment options

Answer selected by armandino
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants