@Override SinkInfo parse(String... args) throws Exception { if (args.length >= 3) { if (args.length > 4) { throw new IllegalArgumentException("Too many arguments."); } String name = args[0]; Destination destination; switch (args[1]) { case "bucket": destination = BucketDestination.of(args[2]); break; case "dataset": destination = DatasetDestination.of(args[2]); break; case "topic": destination = TopicDestination.of(args[2]); break; default: throw new IllegalArgumentException("Second argument must be bucket|dataset|topic."); } SinkInfo.Builder builder = SinkInfo.newBuilder(name, destination); if (args.length == 4) { builder.setFilter(args[3]); } return builder.build(); } throw new IllegalArgumentException("Missing required sink name, destination or filter."); }