Handle null exceptions in the response with Optional.

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/resource-management/resource-manager@160525 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Manuele Simi 2017-12-15 04:17:24 +00:00
parent b6b7e25d32
commit 265dca22df
1 changed files with 4 additions and 4 deletions

View File

@ -13,7 +13,7 @@ public class ResponseFromResourceRegistry {
private boolean success = false;
private String message;
protected ResponseFromResourceRegistry() {}
public boolean wasSuccessful() {return success;}
@ -31,8 +31,8 @@ public class ResponseFromResourceRegistry {
* @return the exception
*/
@SuppressWarnings("unchecked")
public <E extends Exception> E getException() {return success? null: (E) new Exception();}
public <E extends Exception> Optional<E> getException() {
return Optional.ofNullable(success? null: (E) new Exception());
}
}