Raw
- The underlying type.This
- Self-reference to the subclass type itself.public abstract class Single<Raw,This extends Single<Raw,This>> extends Object
Pure
value types.Modifier and Type | Field | Description |
---|---|---|
protected Raw |
raw |
The raw underlying value.
|
Modifier | Constructor | Description |
---|---|---|
protected |
Single(Raw rawValue,
Function<? super Raw,? extends This> constructor) |
Modifier and Type | Method | Description |
---|---|---|
boolean |
equals(Object other) |
|
static boolean |
equals(Object object1,
Object object2) |
Compare two objects for equality.
|
boolean |
equals(This that) |
|
Optional<This> |
filter(Predicate<? super Raw> condition) |
Test the raw value by
condition . |
This |
flatMap(Function<? super Raw,? extends This> mapper) |
Construct a new value of this type with the raw underlying value converted by
mapper . |
int |
hashCode() |
|
static int |
hashCode(Object object) |
Generate a hash code for
object . |
boolean |
is(Predicate<? super Raw> condition) |
Test the raw value with
condition . |
boolean |
isNot(Predicate<? super Raw> condition) |
Reverse of
is(Predicate) . |
This |
map(Function<? super Raw,? extends Raw> mapper) |
Construct a new value of this type with the raw underlying value converted by
mapper . |
Raw |
raw() |
Return the raw underlying value.
|
String |
toString() |
|
static String |
toString(Object object) |
Format a string to represent
object . |
protected final Raw raw
public Raw raw()
Single
is mutable. The default implementation assumes raw
is
immutable, and returns it as-is. The returned Single
value, if mutable, could be mutated, so the
overriding method should be careful to make a deep, defensive copy to return to the caller.public static int hashCode(Object object)
object
. If object
is an array, combine the hashes of each element.public final boolean equals(This that)
public static boolean equals(Object object1, Object object2)
public static String toString(Object object)
object
. If object
is an array, include each element.public final boolean is(Predicate<? super Raw> condition)
condition
.
This method is useful when using Optional.filter(java.util.function.Predicate<? super T>)
or Stream.filter(java.util.function.Predicate<? super T>)
.
optional.filter(x -> x.is(String::isEmpty))
public final boolean isNot(Predicate<? super Raw> condition)
is(Predicate)
.public final Optional<This> filter(Predicate<? super Raw> condition)
condition
.Optional
containing this instance if the condition is met; empty otherwise.is(Predicate)
public final This map(Function<? super Raw,? extends Raw> mapper)
mapper
.mapper
- The mapping function to apply to the raw underlying value.Copyright © 2020. All rights reserved.