import java.io.Serializable; public class Issue3032 { public static class PCollection implements PValue { public OutputT apply( String name, PTransform, OutputT> t) { throw new RuntimeException(); } } public abstract static class PTransform {} interface PInput {} interface POutput {} interface PValue extends PInput, POutput {} static class BillingEvent { InvoiceGroupingKey getInvoiceGroupingKey() { throw new RuntimeException(); } } public static class MapElements extends PTransform, PCollection> { public static MapElements via( final ProcessFunction fn) { throw new RuntimeException(); } } static class InvoiceGroupingKey {} @FunctionalInterface public interface ProcessFunction extends Serializable { OutputT apply(InputT input) throws Exception; } private static class GenerateInvoiceRows extends PTransform, PCollection> { public void expand(PCollection input) { input.apply( "Map to invoicing key", MapElements.via(BillingEvent::getInvoiceGroupingKey)); } } }