splitRestriction.restrictionT().equals(restrictionT), "Uses restriction type %s, but @%s method %s uses restriction type %s", formatType(restrictionT), DoFn.SplitRestriction.class.getSimpleName(), format(splitRestriction.targetMethod()), formatType(splitRestriction.restrictionT()));
@VisibleForTesting static DoFnSignature.SplitRestrictionMethod analyzeSplitRestrictionMethod( ErrorReporter errors, TypeDescriptor<? extends DoFn> fnT, Method m, TypeDescriptor<?> inputT) { // Method is of the form: // @SplitRestriction // void splitRestriction(InputT element, RestrictionT restriction); errors.checkArgument(void.class.equals(m.getReturnType()), "Must return void"); Type[] params = m.getGenericParameterTypes(); errors.checkArgument(params.length == 3, "Must have exactly 3 arguments"); errors.checkArgument( fnT.resolveType(params[0]).equals(inputT), "First argument must be the element type %s", formatType(inputT)); TypeDescriptor<?> restrictionT = fnT.resolveType(params[1]); TypeDescriptor<?> receiverT = fnT.resolveType(params[2]); TypeDescriptor<?> expectedReceiverT = outputReceiverTypeOf(restrictionT); errors.checkArgument( receiverT.equals(expectedReceiverT), "Third argument must be %s, but is %s", formatType(expectedReceiverT), formatType(receiverT)); return DoFnSignature.SplitRestrictionMethod.create(m, restrictionT); }
assertEquals( SomeRestriction.class, signature.getInitialRestriction().restrictionT().getRawType()); assertEquals(SomeRestriction.class, signature.splitRestriction().restrictionT().getRawType()); assertEquals(RestrictionTracker.class, signature.newTracker().trackerT().getRawType()); assertEquals(SomeRestriction.class, signature.newTracker().restrictionT().getRawType());
assertEquals( SomeRestriction.class, signature.getInitialRestriction().restrictionT().getRawType()); assertEquals(SomeRestriction.class, signature.splitRestriction().restrictionT().getRawType()); assertEquals(SomeRestrictionTracker.class, signature.newTracker().trackerT().getRawType()); assertEquals(SomeRestriction.class, signature.newTracker().restrictionT().getRawType());
private static Implementation splitRestrictionDelegation( TypeDescription doFnType, DoFnSignature signature) { if (signature.splitRestriction() == null) { return MethodDelegation.to(DefaultSplitRestriction.class); } else { return new DowncastingParametersMethodDelegation( doFnType, signature.splitRestriction().targetMethod()); } }