com.atlassian.confluence.core
Class MaybeNot<T>

java.lang.Object
  extended by com.atlassian.confluence.core.MaybeNot<T>
Type Parameters:
T - the type Maybe is wrapping
All Implemented Interfaces:
com.atlassian.fugue.Effect.Applicant<T>, com.atlassian.fugue.Maybe<T>, com.google.common.base.Supplier<T>, java.lang.Iterable<T>

public abstract class MaybeNot<T>
extends java.lang.Object
implements com.atlassian.fugue.Maybe<T>

Helps constructing the left, erroneous case of a Maybe.

Since:
5.2

Method Summary
static
<T> com.atlassian.fugue.Maybe<T>
becauseOf(java.lang.String message, java.lang.Object... args)
          Constructs a Maybe which will escape with the given message on a Maybe.get() call.
static
<T> com.atlassian.fugue.Maybe<T>
becauseOfException(java.lang.Exception exception)
          Constructs a Maybe which will escape with the given exception on a Maybe.get() call.
static
<T> com.atlassian.fugue.Maybe<T>
becauseOfNoResult(com.atlassian.fugue.Maybe<?> maybe)
          Will cast the given Maybe to one with the expected parametrisation.
 boolean exists(com.google.common.base.Predicate<T> p)
           
 boolean forall(com.google.common.base.Predicate<T> p)
           
 void foreach(com.atlassian.fugue.Effect<T> effect)
           
<B extends T>
T
getOrElse(B other)
           
 T getOrElse(com.google.common.base.Supplier<T> supplier)
           
 T getOrError(com.google.common.base.Supplier<java.lang.String> msg)
           
 T getOrNull()
           
 boolean isDefined()
           
 boolean isEmpty()
           
 java.util.Iterator<T> iterator()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.atlassian.fugue.Maybe
get
 

Method Detail

becauseOfNoResult

public static <T> com.atlassian.fugue.Maybe<T> becauseOfNoResult(com.atlassian.fugue.Maybe<?> maybe)
Will cast the given Maybe to one with the expected parametrisation.

This has to be Maybe.isEmpty() since it is expected to escape on a Maybe.get() call.

Parameters:
maybe - to be casted to the target type
Returns:
the casted Maybe adhering to the taget type

becauseOf

public static <T> com.atlassian.fugue.Maybe<T> becauseOf(java.lang.String message,
                                                         java.lang.Object... args)
Constructs a Maybe which will escape with the given message on a Maybe.get() call.

Parameters:
message - the message used for the escape, may be formatted for application of String.format(String, Object...)
args - the arguments used for formatting the message, may be null
Returns:
the Maybe escaping on realization

becauseOfException

public static <T> com.atlassian.fugue.Maybe<T> becauseOfException(java.lang.Exception exception)
Constructs a Maybe which will escape with the given exception on a Maybe.get() call.

Parameters:
exception - the exception to be thrown, will be nested in a RuntimeException if it is checked
Returns:

getOrError

public T getOrError(com.google.common.base.Supplier<java.lang.String> msg)
Specified by:
getOrError in interface com.atlassian.fugue.Maybe<T>

getOrElse

public T getOrElse(com.google.common.base.Supplier<T> supplier)
Specified by:
getOrElse in interface com.atlassian.fugue.Maybe<T>

getOrElse

public <B extends T> T getOrElse(B other)
Specified by:
getOrElse in interface com.atlassian.fugue.Maybe<T>

foreach

public void foreach(com.atlassian.fugue.Effect<T> effect)
Specified by:
foreach in interface com.atlassian.fugue.Effect.Applicant<T>

getOrNull

public T getOrNull()
Specified by:
getOrNull in interface com.atlassian.fugue.Maybe<T>

exists

public boolean exists(com.google.common.base.Predicate<T> p)
Specified by:
exists in interface com.atlassian.fugue.Maybe<T>

iterator

public java.util.Iterator<T> iterator()
Specified by:
iterator in interface com.atlassian.fugue.Maybe<T>
Specified by:
iterator in interface java.lang.Iterable<T>

forall

public boolean forall(com.google.common.base.Predicate<T> p)
Specified by:
forall in interface com.atlassian.fugue.Maybe<T>

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface com.atlassian.fugue.Maybe<T>

isDefined

public boolean isDefined()
Specified by:
isDefined in interface com.atlassian.fugue.Maybe<T>


Copyright © 2003-2014 Atlassian. All Rights Reserved.