code: public static Optional<CopyableFileWatermarkGenerator> getCopyableFileWatermarkGenerator(State state)
        throws IOException {
      try {
        if (state.contains(WATERMARK_CREATOR)) {
          Class<?> watermarkCreatorClass = Class.forName(state.getProp(WATERMARK_CREATOR));
          return Optional.of((CopyableFileWatermarkGenerator) watermarkCreatorClass.newInstance());
        } else {
          return Optional.absent();
        }
      } catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
        throw new IOException("Failed to instantiate watermarkCreator.");
      }
    }
docs: Get Optional {@link CopyableFileWatermarkGenerator} from {@link State}.