Source:
private EventGenerator<String> getEventGenerator(final WatermarkTypeEnum watermarkType, final Map<String, Object> sourceConfString, final Map<String, Object> watermarkConfString, final ClassLoader classLoader) throws RuntimeException { try { final Function<String, Tuple<String, Long>> timestampExtractionFunc; final ByteBuffer serializedExtractionFunc = (ByteBuffer) sourceConfString.get(SourceParameters.TIMESTAMP_EXTRACTION_FUNCTION); if (serializedExtractionFunc != null) { timestampExtractionFunc = deserializeLambda(serializedExtractionFunc, classLoader); } else { timestampExtractionFunc = null; } switch (watermarkType) { case PERIODIC: final long period = Long.parseLong(watermarkConfString.get(PeriodicWatermarkParameters.PERIOD).toString()); final long expectedDelay = Long.parseLong(watermarkConfString.get(PeriodicWatermarkParameters.EXPECTED_DELAY).toString()); return new PeriodicEventGenerator<>( timestampExtractionFunc, period, expectedDelay, TimeUnit.MILLISECONDS, scheduler); case PUNCTUATED: final Predicate<String> isWatermark = deserializeLambda((ByteBuffer) watermarkConfString.get( PunctuatedWatermarkParameters.WATERMARK_PREDICATE), classLoader); final Function<String, Long> parseTimestamp = deserializeLambda((ByteBuffer) watermarkConfString.get( PunctuatedWatermarkParameters.PARSING_TIMESTAMP_FROM_WATERMARK), classLoader); return new PunctuatedEventGenerator<>(timestampExtractionFunc, isWatermark, parseTimestamp); default: throw new IllegalArgumentException("MISTTask: Invalid WatermarkTypeEnum is detected!"); } } catch (final Exception e) { e.printStackTrace(); throw new RuntimeException(e); } }

Target:
private <I, V> EventGenerator<I> getEventGenerator(final WatermarkTypeEnum watermarkType, final Map<String, Object> sourceConfString, final Map<String, Object> watermarkConfString, final ClassLoader classLoader) throws RuntimeException { try { final Function<I, Tuple<V, Long>> timestampExtractionFunc; final ByteBuffer serializedExtractionFunc = (ByteBuffer) sourceConfString.get(SourceParameters.TIMESTAMP_EXTRACTION_FUNCTION); if (serializedExtractionFunc != null) { timestampExtractionFunc = deserializeLambda(serializedExtractionFunc, classLoader); } else { timestampExtractionFunc = null; } switch (watermarkType) { case PERIODIC: final long period = Long.parseLong(watermarkConfString.get(PeriodicWatermarkParameters.PERIOD).toString()); final long expectedDelay = Long.parseLong(watermarkConfString.get(PeriodicWatermarkParameters.EXPECTED_DELAY).toString()); return new PeriodicEventGenerator<>( timestampExtractionFunc, period, expectedDelay, TimeUnit.MILLISECONDS, scheduler); case PUNCTUATED: final Predicate<I> isWatermark = deserializeLambda((ByteBuffer) watermarkConfString.get( PunctuatedWatermarkParameters.WATERMARK_PREDICATE), classLoader); final Function<I, Long> parseTimestamp = deserializeLambda((ByteBuffer) watermarkConfString.get( PunctuatedWatermarkParameters.PARSING_TIMESTAMP_FROM_WATERMARK), classLoader); return new PunctuatedEventGenerator<>(timestampExtractionFunc, isWatermark, parseTimestamp); default: throw new IllegalArgumentException("MISTTask: Invalid WatermarkTypeEnum is detected!"); } } catch (final Exception e) { e.printStackTrace(); throw new RuntimeException(e); } }