BdEngineer :
I am trying to iterate list of objects
Optional<QueryEntities> entities = InputYamlProcessor.process(ymlFilename);
entities.orElseThrow( ()->{
logger.error("Unable to parse YAL ,Correct YML and retry");
new NoExtractorDefinedException("Unable to parse YAL ,Correct YML and retry");
});
Getting error as below :
The method orElseThrow(Supplier) in the type Optional is not applicable for the arguments (() -> {})
What is wrong am i dong here ?
if QueryEntities class is as belw :
public class QueryEntities {
List<QueryEntity> entitiesList;
}
How to access each QueryEntity and retrieve its fields and print.
Smutje :
Optional#orElseThrow
takes a
Supplier<? extends X> exceptionSupplier
so you must provide it with one:
entities.orElseThrow(() -> {
logger.error("Unable to parse YAL ,Correct YML and retry");
return new NoExtractorDefinedException("Unable to parse YAL ,Correct YML and retry");
});
Guess you like
Origin http://43.154.161.224:23101/article/api/json?id=326524&siteId=1