@Nullable private static Method findAnnotatedMethod( ErrorReporter errors, Class<? extends Annotation> anno, Class<?> fnClazz, boolean required) { Collection<Method> matches = declaredMethodsWithAnnotation(anno, fnClazz, DoFn.class); if (matches.isEmpty()) { errors.checkArgument(!required, "No method annotated with @%s found", anno.getSimpleName()); return null; } // If we have at least one match, then either it should be the only match // or it should be an extension of the other matches (which came from parent // classes). Method first = matches.iterator().next(); for (Method other : matches) { errors.checkArgument( first.getName().equals(other.getName()) && Arrays.equals(first.getParameterTypes(), other.getParameterTypes()), "Found multiple methods annotated with @%s. [%s] and [%s]", anno.getSimpleName(), format(first), format(other)); } ErrorReporter methodErrors = errors.forMethod(anno, first); // We need to be able to call it. We require it is public. methodErrors.checkArgument((first.getModifiers() & Modifier.PUBLIC) != 0, "Must be public"); // And make sure its not static. methodErrors.checkArgument((first.getModifiers() & Modifier.STATIC) == 0, "Must not be static"); return first; }
ErrorReporter onTimerErrors = errors.forMethod(DoFn.OnTimer.class, m); for (int i = 0; i < params.length; ++i) { Parameter parameter =
ErrorReporter onWindowExpirationErrors = errors.forMethod(DoFn.OnWindowExpiration.class, m); for (int i = 0; i < params.length; ++i) { Parameter parameter =
errors.forMethod(DoFn.ProcessElement.class, processElementMethod); DoFnSignature.ProcessElementMethod processElement = analyzeProcessElementMethod( ErrorReporter startBundleErrors = errors.forMethod(DoFn.StartBundle.class, startBundleMethod); signatureBuilder.setStartBundle( analyzeStartBundleMethod(startBundleErrors, fnT, startBundleMethod, inputT, outputT)); errors.forMethod(DoFn.FinishBundle.class, finishBundleMethod); signatureBuilder.setFinishBundle( analyzeFinishBundleMethod(finishBundleErrors, fnT, finishBundleMethod, inputT, outputT)); analyzeLifecycleMethod(errors.forMethod(DoFn.Setup.class, setupMethod), setupMethod)); signatureBuilder.setTeardown( analyzeLifecycleMethod( errors.forMethod(DoFn.Teardown.class, teardownMethod), teardownMethod)); if (getInitialRestrictionMethod != null) { getInitialRestrictionErrors = errors.forMethod(DoFn.GetInitialRestriction.class, getInitialRestrictionMethod); signatureBuilder.setGetInitialRestriction( analyzeGetInitialRestrictionMethod( errors.forMethod(DoFn.SplitRestriction.class, splitRestrictionMethod); signatureBuilder.setSplitRestriction( analyzeSplitRestrictionMethod( errors.forMethod(DoFn.GetRestrictionCoder.class, getRestrictionCoderMethod);
errors.forMethod(DoFn.ProcessElement.class, processElement.targetMethod()); errors.forMethod(DoFn.GetInitialRestriction.class, getInitialRestriction.targetMethod()); TypeDescriptor<?> restrictionT = getInitialRestriction.restrictionT(); getInitialRestrictionErrors.checkArgument( errors.forMethod(DoFn.GetInitialRestriction.class, getInitialRestriction.targetMethod()); TypeDescriptor<?> restrictionT = getInitialRestriction.restrictionT(); processElementErrors.checkArgument(
errors.forMethod(DoFn.ProcessElement.class, m), fnContext, methodContext,