private Method replaceWithOverriddenOrInterfaceMethod(Method method, List<Method> allMethodsOfType) { LinkedList<Method> list = new LinkedList<>( allMethodsOfType ); Iterator<Method> iterator = list.descendingIterator(); while ( iterator.hasNext() ) { Method overriddenOrInterfaceMethod = iterator.next(); if ( executableHelper.overrides( method, overriddenOrInterfaceMethod ) ) { if ( method.getAnnotation( ValidateOnExecution.class ) != null ) { throw log.getValidateOnExecutionOnOverriddenOrInterfaceMethodException( method ); } return overriddenOrInterfaceMethod; } } return method; } }
private boolean overrides(Executable first, Executable other) { if ( first instanceof Constructor || other instanceof Constructor ) { return false; } return executableHelper.overrides( (Method) first, (Method) other ); }
@Override public boolean accepts(ConstrainedElement constrainedElement) { if ( kind != constrainedElement.getKind() ) { return false; } ExecutableElement executableElement = ( (ConstrainedExecutable) constrainedElement ).getExecutable(); //are the locations equal (created by different builders) or //does one of the executables override the other one? return executable.equals( executableElement ) || executableHelper.overrides( executable, executableElement ) || executableHelper.overrides( executableElement, executable ); }
private Method replaceWithOverriddenOrInterfaceMethod(Method method, List<Method> allMethodsOfType) { LinkedList<Method> list = new LinkedList<>( allMethodsOfType ); Iterator<Method> iterator = list.descendingIterator(); while ( iterator.hasNext() ) { Method overriddenOrInterfaceMethod = iterator.next(); if ( executableHelper.overrides( method, overriddenOrInterfaceMethod ) ) { if ( method.getAnnotation( ValidateOnExecution.class ) != null ) { throw log.getValidateOnExecutionOnOverriddenOrInterfaceMethodException( method ); } return overriddenOrInterfaceMethod; } } return method; } }
/** * Checks, whether the represented method overrides the given method. * * @param executableElement the method to test against * @param other The method to test. * * @return {@code true} If this methods overrides the passed method, * {@code false} otherwise. */ public boolean overrides(ExecutableElement executableElement, ExecutableElement other) { //constructors never override another constructor if ( executableElement.getMember() instanceof Constructor || other.getMember() instanceof Constructor ) { return false; } return overrides( (Method) executableElement.getMember(), (Method) other.getMember() ); }
@Override public final void add(ConstrainedElement constrainedElement) { super.add( constrainedElement ); ConstrainedExecutable constrainedExecutable = (ConstrainedExecutable) constrainedElement; signatures.add( constrainedExecutable.getExecutable().getSignature() ); constrainedExecutables.add( constrainedExecutable ); isConstrained = isConstrained || constrainedExecutable.isConstrained(); crossParameterConstraints.addAll( constrainedExecutable.getCrossParameterConstraints() ); typeArgumentsConstraints.addAll( constrainedExecutable.getTypeArgumentsConstraints() ); addToExecutablesByDeclaringType( constrainedExecutable ); // keep the "lowest" executable in hierarchy to make sure any type parameters declared on super-types (and // used in overridden methods) are resolved for the specific sub-type we are interested in if ( executable != null && executableHelper.overrides( constrainedExecutable.getExecutable(), executable ) ) { executable = constrainedExecutable.getExecutable(); } }