net.sf.staccatocommons.lang
Class None<T>

java.lang.Object
  extended by net.sf.staccatocommons.lang.Option<T>
      extended by net.sf.staccatocommons.lang.None<T>
Type Parameters:
T - the type of value - although None options have no associated value at all.
All Implemented Interfaces:
Serializable, Iterable<T>, net.sf.staccatocommons.defs.partial.ContainsAware<T>, net.sf.staccatocommons.defs.partial.EmptyAware, net.sf.staccatocommons.defs.partial.SizeAware, net.sf.staccatocommons.defs.ProtoMonad<Option,T>, net.sf.staccatocommons.defs.Thunk<T>

@Value
@Immutable
public final class None<T>
extends Option<T>

An undefined Option, that it, and option that does not have a value

Author:
flbulgarelli
See Also:
Option, Serialized Form

Method Summary
 boolean contains(Object element)
           
 boolean equals(Object obj)
           
 int hashCode()
           
 void ifDefined(net.sf.staccatocommons.defs.Executable<? super T> block)
          Executed the given block if this option is defined
 boolean isDefined()
          Returns if the value has been defined or not.
 boolean isEmpty()
           
 Iterator<T> iterator()
           
static
<T> None<T>
none()
           
 int size()
           
 Option<T> skip(T element)
           
 String toString()
           
 T value()
          Gets the optional value, if defined, or throws an NoSuchElementException, otherwise.
 T valueOrElse(T ifUndefined)
          Returns the value of this Option, or the provided object if undefined
 T valueOrElse(net.sf.staccatocommons.defs.Thunk<? extends T> ifUndefined)
          Returns the value of this Option, or the provided object if undefined
 T valueOrNull()
          Returns the value of this Option, or null, if undefined.
 
Methods inherited from class net.sf.staccatocommons.lang.Option
filter, forEach, isUndefined, map, nullToNone, some, someNull
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

value

public T value()
Description copied from class: Option
Gets the optional value, if defined, or throws an NoSuchElementException, otherwise.

Specified by:
value in interface net.sf.staccatocommons.defs.Thunk<T>
Specified by:
value in class Option<T>
Returns:
The optional value. This value is nullable, if client code considers null as possible, valid values. Non null otherwise. Please prefer the second approach, as normally, null values are there in code to represent optional data, so nullable values in optional values is in most scenarios completely redundant, unnecessary an error prone.

isDefined

public boolean isDefined()
Description copied from class: Option
Returns if the value has been defined or not.

Specified by:
isDefined in class Option<T>
Returns:
true is the value is defined. False otherwise

valueOrElse

public T valueOrElse(T ifUndefined)
Description copied from class: Option
Returns the value of this Option, or the provided object if undefined

Specified by:
valueOrElse in class Option<T>
Parameters:
ifUndefined - the return value in case this Option is undefined
Returns:
this.value() if defined, other otherwise

valueOrElse

public T valueOrElse(@NonNull
                     net.sf.staccatocommons.defs.Thunk<? extends T> ifUndefined)
Description copied from class: Option
Returns the value of this Option, or the provided object if undefined

Specified by:
valueOrElse in class Option<T>
Parameters:
ifUndefined - the thunk of the return value in case this Option is undefined
Returns:
this.value() if defined, other.value() otherwise

ifDefined

public void ifDefined(net.sf.staccatocommons.defs.Executable<? super T> block)
Description copied from class: Option
Executed the given block if this option is defined

Specified by:
ifDefined in class Option<T>

valueOrNull

public T valueOrNull()
Description copied from class: Option
Returns the value of this Option, or null, if undefined.

Specified by:
valueOrNull in class Option<T>
Returns:
this.value() if defined, or null, otherwise

iterator

public Iterator<T> iterator()

size

public int size()

isEmpty

public boolean isEmpty()

contains

public boolean contains(Object element)

skip

public Option<T> skip(T element)

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object obj)
Overrides:
equals in class Object

toString

public String toString()
Overrides:
toString in class Object

none

@NonNull
public static <T> None<T> none()


Copyright © 2010-2012 Staccatocommons. All Rights Reserved.