Class JsonNullable<T>
java.lang.Object
org.openapitools.jackson.nullable.JsonNullable<T>
- All Implemented Interfaces:
Serializable
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbooleanIf a value is present, and the value matches the given predicate, returns a JsonNullable describing the value, otherwise returns an undefined JsonNullable.<U> JsonNullable<U>flatMap(Function<? super T, ? extends JsonNullable<? extends U>> mapper) If a value is present, returns the result of applying the given JsonNullable-bearing mapping function to the value, otherwise returns an undefined JsonNullable.get()Obtain the value of thisJsonNullable.inthashCode()voidIf the value is present and notnull, performs the given action with the value, otherwise does nothing.voidIf a value is present, performs the given action with the value, otherwise does nothing.voidifPresentOrElse(Consumer<? super T> action, Runnable undefinedAction) If a value is present, performs the given action with the value, otherwise performs the given empty-based action.booleanIf the value is present and notnull, returns true, otherwise false.booleanisNull()If the value is present andnull, returns true, otherwise false.booleanIf a value is present, returns true, otherwise false.booleanIf a value is not present, returns true, otherwise false.<U> JsonNullable<U>If a value is present, returns a JsonNullable describing the result of applying the given mapping function to the value, otherwise returns an undefined JsonNullable.static <T> JsonNullable<T>of(T value) Create aJsonNullablefrom the submitted value.static <T> JsonNullable<T>ofNull()Create aJsonNullablerepresenting an explicitnull(present, with anullvalue).or(Supplier<? extends JsonNullable<? extends T>> supplier) If a value is present, returns a JsonNullable describing the value, otherwise returns a JsonNullable produced by the supplying function.Obtain the value of thisJsonNullable.If a value is present, returns the value, otherwise returns the result produced by the supplying function.If a value is present, returns the value, otherwise throws NoSuchElementException.orElseThrow(Supplier<? extends X> supplier) If a value is present, returns the value, otherwise throws an exception produced by the exception supplying function.stream()If a value is present, returns a sequential Stream containing only that value, otherwise returns an empty Stream.toString()static <T> JsonNullable<T>Create aJsonNullablerepresenting an undefined value (not present).
-
Method Details
-
undefined
Create aJsonNullablerepresenting an undefined value (not present).- Type Parameters:
T- a type wildcard- Returns:
- an empty
JsonNullablewith no value defined
-
ofNull
Create aJsonNullablerepresenting an explicitnull(present, with anullvalue). Equal toof(null).- Type Parameters:
T- a type wildcard- Returns:
- a
JsonNullableholding an explicitnull - Since:
- 0.2.13
-
of
Create aJsonNullablefrom the submitted value.- Type Parameters:
T- the type of the value- Parameters:
value- the value- Returns:
- the
JsonNullablewith the submitted value present.
-
get
Obtain the value of thisJsonNullable.- Returns:
- the value, if present
- Throws:
NoSuchElementException- if no value is present
-
orElse
Obtain the value of thisJsonNullable.- Parameters:
other- the value to be returned if no value is present- Returns:
- the value of this
JsonNullableif present, the submitted value otherwise
-
orElseGet
If a value is present, returns the value, otherwise returns the result produced by the supplying function.- Parameters:
supplier- the supplying function that produces a value to be returned- Returns:
- the value, if present, otherwise the result produced by the supplying function
- Throws:
NullPointerException- if no value is present and the supplying function is null- Since:
- 0.2.8
-
orElseThrow
If a value is present, returns the value, otherwise throws NoSuchElementException.- Returns:
- the value of this JsonNullable
- Throws:
NoSuchElementException- if no value is present- Since:
- 0.2.8
-
orElseThrow
If a value is present, returns the value, otherwise throws an exception produced by the exception supplying function.- Type Parameters:
X- type of the exception to be thrown- Parameters:
supplier- the supplying function that produces an exception to be thrown- Returns:
- the value, if present
- Throws:
X- if no value is presentNullPointerException- if no value is present and the exception supplying function isnull- Since:
- 0.2.8
-
isPresent
public boolean isPresent()If a value is present, returns true, otherwise false.- Returns:
- true if a value is present, otherwise false
-
isUndefined
public boolean isUndefined()If a value is not present, returns true, otherwise false.- Returns:
- true if a value is not present, otherwise false
- Since:
- 0.2.8
-
isNull
public boolean isNull()If the value is present andnull, returns true, otherwise false. An undefinedJsonNullableis not null.- Returns:
- true if the value is present and
null, otherwise false - Since:
- 0.2.13
-
isNonNull
public boolean isNonNull()If the value is present and notnull, returns true, otherwise false.- Returns:
- true if the value is present and not
null, otherwise false - Since:
- 0.2.13
-
ifPresent
If a value is present, performs the given action with the value, otherwise does nothing.- Parameters:
action- the action to be performed, if a value is present- Throws:
NullPointerException- if a value is present and the given action is null
-
ifNonNull
If the value is present and notnull, performs the given action with the value, otherwise does nothing.- Parameters:
action- the action to be performed, if a non-null value is present- Throws:
NullPointerException- if a non-null value is present and the given action is null- Since:
- 0.2.13
-
ifPresentOrElse
If a value is present, performs the given action with the value, otherwise performs the given empty-based action.- Parameters:
action- the action to be performed, if a value is presentundefinedAction- the empty-based action to be performed, if no value is present- Throws:
NullPointerException- if a value is present and the given action is null, or no value is present and the given empty-based action is null- Since:
- 0.2.8
-
filter
If a value is present, and the value matches the given predicate, returns a JsonNullable describing the value, otherwise returns an undefined JsonNullable.- Parameters:
predicate- the predicate to apply to a value, if present- Returns:
- a JsonNullable describing the value of this JsonNullable, if a value is present and the value matches the given predicate, otherwise an undefined JsonNullable
- Throws:
NullPointerException- if the predicate is null- Since:
- 0.2.8
-
map
If a value is present, returns a JsonNullable describing the result of applying the given mapping function to the value, otherwise returns an undefined JsonNullable.- Type Parameters:
U- the type of the value returned from the mapping function- Parameters:
mapper- the mapping function to apply to a value, if present- Returns:
- a JsonNullable describing the result of applying a mapping function to the value of this JsonNullable, if a value is present, otherwise an undefined JsonNullable
- Throws:
NullPointerException- if the mapping function is null- Since:
- 0.2.8
-
flatMap
If a value is present, returns the result of applying the given JsonNullable-bearing mapping function to the value, otherwise returns an undefined JsonNullable.- Type Parameters:
U- the type of value of the JsonNullable returned by the mapping function- Parameters:
mapper- the mapping function to apply to a value, if present- Returns:
- the result of applying a JsonNullable-bearing mapping function to the value of this JsonNullable, if a value is present, otherwise an undefined JsonNullable
- Throws:
NullPointerException- if the mapping function is null or returns a null result- Since:
- 0.2.8
-
or
If a value is present, returns a JsonNullable describing the value, otherwise returns a JsonNullable produced by the supplying function.- Parameters:
supplier- the supplying function that produces a JsonNullable to be returned- Returns:
- returns a JsonNullable describing the value of this JsonNullable, if a value is present, otherwise a JsonNullable produced by the supplying function.
- Throws:
NullPointerException- if the supplying function is null or produces a null result- Since:
- 0.2.8
-
stream
If a value is present, returns a sequential Stream containing only that value, otherwise returns an empty Stream.- Returns:
- the JsonNullable value as a Stream
- Since:
- 0.2.8
-
equals
-
hashCode
public int hashCode() -
toString
-