getRestrictionCoder.coderT().isSubtypeOf(coderTypeOf(restrictionT)), "Uses restriction type %s, but @%s method %s returns %s " + "which is not a subtype of %s", formatType(restrictionT), DoFn.GetRestrictionCoder.class.getSimpleName(), format(getRestrictionCoder.targetMethod()), formatType(getRestrictionCoder.coderT()), formatType(coderTypeOf(restrictionT)));
@VisibleForTesting static DoFnSignature.GetRestrictionCoderMethod analyzeGetRestrictionCoderMethod( ErrorReporter errors, TypeDescriptor<? extends DoFn> fnT, Method m) { errors.checkArgument(m.getParameterTypes().length == 0, "Must have zero arguments"); TypeDescriptor<?> resT = fnT.resolveType(m.getGenericReturnType()); errors.checkArgument( resT.isSubtypeOf(TypeDescriptor.of(Coder.class)), "Must return a Coder, but returns %s", formatType(resT)); return DoFnSignature.GetRestrictionCoderMethod.create(m, resT); }
assertEquals(RestrictionTracker.class, signature.newTracker().trackerT().getRawType()); assertEquals(SomeRestriction.class, signature.newTracker().restrictionT().getRawType()); assertEquals(SomeRestrictionCoder.class, signature.getRestrictionCoder().coderT().getRawType());
assertEquals(SomeRestrictionTracker.class, signature.newTracker().trackerT().getRawType()); assertEquals(SomeRestriction.class, signature.newTracker().restrictionT().getRawType()); assertEquals(SomeRestrictionCoder.class, signature.getRestrictionCoder().coderT().getRawType());
private static Implementation getRestrictionCoderDelegation( TypeDescription doFnType, DoFnSignature signature) { if (signature.processElement().isSplittable()) { if (signature.getRestrictionCoder() == null) { return MethodDelegation.to( new DefaultRestrictionCoder(signature.getInitialRestriction().restrictionT())); } else { return new DowncastingParametersMethodDelegation( doFnType, signature.getRestrictionCoder().targetMethod()); } } else { return ExceptionMethod.throwing(UnsupportedOperationException.class); } }