[fix][functions] Fix UserConfigWindowFunction
package org.apache.pulsar.functions.api.examples.window;
import java.util.Collection;
-import java.util.Optional;
import org.apache.pulsar.functions.api.Record;
import org.apache.pulsar.functions.api.WindowContext;
import org.apache.pulsar.functions.api.WindowFunction;
@@ -30,11 +29,6 @@ import org.apache.pulsar.functions.api.WindowFunction;
public class UserConfigWindowFunction implements WindowFunction<String, String> {
@Override
public String process(Collection<Record<String>> input, WindowContext context) throws Exception {
- Optional<Object> whatToWrite = context.getUserConfigValue("WhatToWrite");
- if (whatToWrite.get() != null) {
- return (String) whatToWrite.get();
- } else {
- return "Not a nice way";
- }
+ return (String) context.getUserConfigValue("WhatToWrite").orElse("Not a nice way");
}
}
