com.atlassian.bamboo.utils.fage
Class Result<E extends java.lang.Throwable,T>

java.lang.Object
  extended by com.atlassian.bamboo.utils.fage.Result<E,T>
Type Parameters:
E - exception type
T - result type

public class Result<E extends java.lang.Throwable,T>
extends java.lang.Object

Formalized encapsulation of Either to return either result or exception.


Method Summary
static
<E extends java.lang.Throwable,T>
Result<E,T>
exception(E exception)
          Create Result object with exception object
 E getException()
          Return exception object if Result object was created with one.
 T getResult()
          Return valid result object if Result object was created with one.
 T getResult(T defaultValue)
           
 T getResultThrowException()
           
 boolean hasException()
          Test if Result object holds an exception
static
<E extends java.lang.Throwable,T>
Result<E,T>
result(T result)
          Create Result object with valid result object
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

hasException

public boolean hasException()
Test if Result object holds an exception

Returns:
true if this Result object holds an exception

getResult

public T getResult()
Return valid result object if Result object was created with one.

Returns:
valid result object
Throws:
java.util.NoSuchElementException - if Result object was created with exception

getResult

@Nullable
public T getResult(@Nullable
                            T defaultValue)

getException

public E getException()
Return exception object if Result object was created with one.

Returns:
exception object
Throws:
java.util.NoSuchElementException - if Result object was created with valid result

getResultThrowException

public T getResultThrowException()
                          throws E extends java.lang.Throwable
Throws:
E extends java.lang.Throwable

result

public static <E extends java.lang.Throwable,T> Result<E,T> result(T result)
Create Result object with valid result object

Type Parameters:
E - exception type
T - valid result type
Parameters:
result - valid result object
Returns:
Result object

exception

public static <E extends java.lang.Throwable,T> Result<E,T> exception(E exception)
Create Result object with exception object

Type Parameters:
E - exception type
T - valid result type
Parameters:
exception - exception object
Returns:
Result object


Copyright © 2012 Atlassian. All Rights Reserved.