Improve getReportHandling code
This commit is contained in:
parent
4971adcfb3
commit
b5ef642f39
@ -569,22 +569,27 @@ public class ReportManager
|
||||
.thenApply(UtilCollections::unboxPresent)
|
||||
.thenApply(reports ->
|
||||
{
|
||||
Report report = null;
|
||||
int size = reports.size();
|
||||
|
||||
if (size == 1)
|
||||
if (size == 0)
|
||||
{
|
||||
report = reports.get(0);
|
||||
return Optional.empty();
|
||||
}
|
||||
else if (size > 1)
|
||||
else if (size == 1)
|
||||
{
|
||||
return Optional.of(reports.get(0));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalStateException("Account is handling multiple reports.");
|
||||
}
|
||||
|
||||
return Optional.ofNullable(report);
|
||||
});
|
||||
|
||||
future.exceptionally(throwable -> Optional.empty());
|
||||
future.exceptionally(throwable ->
|
||||
{
|
||||
_plugin.getLogger().log(Level.SEVERE, "Error whilst fetching report being handled by: " + accountId + ".");
|
||||
return Optional.empty();
|
||||
});
|
||||
|
||||
return future;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user