Package org.n52.io.response
Class OptionalOutput<T>
- java.lang.Object
-
- org.n52.io.response.OptionalOutput<T>
-
- Type Parameters:
T- the type of the output value to wrap.
public final class OptionalOutput<T> extends Object
Takes a value which may be marked as serialized or not. A caller still can force to retrieve the actual value even not marked for serialization (by setting the appropriate flag). By default a value will be marked to be serialized.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)TgetValue()TgetValue(boolean forced)inthashCode()booleanisAbsent()booleanisPresent()booleanisSerialize()static <T> OptionalOutput<T>of(T value)Creates an instance which is serialized by default.static <T> OptionalOutput<T>of(T value, boolean serialize)Creates an instance with a flag indicating if given value shall be serialized or not.
-
-
-
Method Detail
-
of
public static <T> OptionalOutput<T> of(T value)
Creates an instance which is serialized by default.- Type Parameters:
T- the type of the output value to wrap- Parameters:
value- the output value (can benull)- Returns:
- a optional value which is serialized by default.
-
of
public static <T> OptionalOutput<T> of(T value, boolean serialize)
Creates an instance with a flag indicating if given value shall be serialized or not.- Type Parameters:
T- the type of the output value to wrap- Parameters:
value- the output value (can benull)serialize-trueif the value shall be serialized,falseotherwise.- Returns:
- a optional value indicating if it shall be serialied or not.
-
isSerialize
public boolean isSerialize()
-
isPresent
public boolean isPresent()
-
isAbsent
public boolean isAbsent()
-
getValue
public T getValue()
- Returns:
- the value if it shall be serialized,
nullotherwise.
-
getValue
public T getValue(boolean forced)
- Parameters:
forced- if value shall be returned independent of serialization flag is set or not.- Returns:
- the acutal set value (can be
null).
-
-