org.omnaest.utils.structure.element
Class ExceptionHandledResult<E>

java.lang.Object
  extended by org.omnaest.utils.structure.element.ExceptionHandledResult<E>
Type Parameters:
E -

public class ExceptionHandledResult<E>
extends Object

An ExceptionHandledResult is the result of an operation which catches Exceptions and does not throw them.
The getResult() will return potential value.

Author:
Omnaest

Field Summary
protected  List<Exception> exceptionList
           
protected  E result
           
 
Constructor Summary
ExceptionHandledResult(E result, Collection<Exception> exceptionCollection)
           
 
Method Summary
 boolean containsAssignableException(Class<? extends Exception> exceptionType)
          Returns true if the ExceptionHandledResult contains any exception which could be assigned to the given Class of Exception
 List<Exception> getExceptionList()
          Returns the List of all catched Exceptions
 Exception getFirstException()
          Returns the first Exception if any Exception is present
 E getResult()
          Returns the resulting element
 boolean hasExceptions()
          Returns true if any Exceptions have been catched
 boolean hasNoExceptions()
          Returns true, if no Exceptions have been catched
 boolean hasResult()
          Returns true if getResult() is not null
 Exception resolveAssignableException(Class<? extends Exception> exceptionType)
          Resolves the first occurring stored Exception which can be assigned to the given Class type.
 void rethrowFirstExceptionAssignableToTypeIfAnyExceptionHasOccurred(Class<? extends Exception> exceptionType)
          Throws the first occurring Exception which is assignable to the given Class again.
 void rethrowFirstExceptionIfAnyExceptionHasOccurred()
          Throws the first Exception again if hasExceptions() is true which shows that at least one Exception has occurred.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

result

protected E result

exceptionList

protected List<Exception> exceptionList
Constructor Detail

ExceptionHandledResult

public ExceptionHandledResult(E result,
                              Collection<Exception> exceptionCollection)
Parameters:
result -
exceptionCollection -
Method Detail

getResult

public E getResult()
Returns the resulting element

Returns:

hasResult

public boolean hasResult()
Returns true if getResult() is not null

Returns:

getExceptionList

public List<Exception> getExceptionList()
Returns the List of all catched Exceptions

Returns:

hasNoExceptions

public boolean hasNoExceptions()
Returns true, if no Exceptions have been catched

Returns:

hasExceptions

public boolean hasExceptions()
Returns true if any Exceptions have been catched

Returns:

containsAssignableException

public boolean containsAssignableException(Class<? extends Exception> exceptionType)
Returns true if the ExceptionHandledResult contains any exception which could be assigned to the given Class of Exception

Parameters:
exceptionType -
Returns:

resolveAssignableException

public Exception resolveAssignableException(Class<? extends Exception> exceptionType)
Resolves the first occurring stored Exception which can be assigned to the given Class type. This includes the causes of stored Exceptions.

Parameters:
exceptionType -
Returns:
See Also:
containsAssignableException(Class)

rethrowFirstExceptionIfAnyExceptionHasOccurred

public void rethrowFirstExceptionIfAnyExceptionHasOccurred()
                                                    throws Exception
Throws the first Exception again if hasExceptions() is true which shows that at least one Exception has occurred.

Throws:
Exception

rethrowFirstExceptionAssignableToTypeIfAnyExceptionHasOccurred

public void rethrowFirstExceptionAssignableToTypeIfAnyExceptionHasOccurred(Class<? extends Exception> exceptionType)
                                                                    throws Exception
Throws the first occurring Exception which is assignable to the given Class again. If no Exception are present or match nothing will happen.

Throws:
Exception
See Also:
resolveAssignableException(Class)

getFirstException

public Exception getFirstException()
Returns the first Exception if any Exception is present

Returns:

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2013. All Rights Reserved.