This
- Self-reference to the subclass type itself.public abstract class SingleString<This extends SingleString<This>> extends Object implements SingleComparable<This>, CharSequence, Supplier<String>
String
.Modifier | Constructor and Description |
---|---|
protected |
SingleString(String rawValue,
Function<? super String,? extends This> constructor) |
Modifier and Type | Method and Description |
---|---|
char |
charAt(int position) |
char |
charAt(IntSupplier position) |
int |
compareTo(This that) |
boolean |
equals(Object other) |
boolean |
equals(This that) |
Optional<This> |
filter(Predicate<? super String> condition)
Test the raw value by
condition . |
This |
flatMap(Function<? super String,? extends This> mapper)
Construct a new value of this type with the raw underlying value converted by
mapper . |
String |
get() |
int |
hashCode() |
boolean |
is(Predicate<? super String> condition)
Test the raw value with
condition . |
boolean |
isEmpty() |
boolean |
isNot(Predicate<? super String> condition)
Reverse of
is(Predicate) . |
boolean |
isNotEmpty() |
This |
left(int length) |
This |
left(IntSupplier length) |
int |
length() |
This |
map(Function<? super String,String> mapper)
Construct a new value of this type with the raw underlying value converted by
mapper . |
String |
raw()
Return the raw underlying value.
|
This |
replaceLiteral(CharSequence literal,
CharSequence replacement) |
This |
replaceLiteral(Supplier<String> literal,
Supplier<String> replacement) |
This |
replaceRegex(String regex,
String replacement) |
This |
replaceRegex(Supplier<String> regex,
Supplier<String> replacement) |
This |
right(int length) |
This |
right(IntSupplier length) |
This |
subSequence(int start,
int end) |
This |
subSequence(IntSupplier start,
IntSupplier end) |
String |
toString()
Override this method to provide custom
Object.toString() formatting. |
This |
trim() |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
isGreaterThan, isGreaterThanOrEqualTo, isLessThan, isLessThanOrEqualTo, max, min
chars, codePoints
public final String raw()
public String toString()
Object.toString()
formatting.
The default returns the raw string value.toString
in interface CharSequence
toString
in class Object
public final int compareTo(This that)
compareTo
in interface Comparable<This extends SingleString<This>>
public final int length()
length
in interface CharSequence
public final char charAt(int position)
charAt
in interface CharSequence
public final char charAt(IntSupplier position)
public final This subSequence(int start, int end)
subSequence
in interface CharSequence
public final This subSequence(IntSupplier start, IntSupplier end)
public final This left(int length)
length
characters.public final This left(IntSupplier length)
public final This right(int length)
length
characters.public final This right(IntSupplier length)
public final This trim()
public final boolean isEmpty()
true
if the raw string is zero-length; false
otherwise.public final boolean isNotEmpty()
true
if the raw string is non-zero-length; false
otherwise.public final This replaceRegex(String regex, String replacement)
public final This replaceLiteral(CharSequence literal, CharSequence replacement)
public final This replaceLiteral(Supplier<String> literal, Supplier<String> replacement)
public final boolean equals(This that)
public final boolean is(Predicate<? super String> 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 String> condition)
is(Predicate)
.public final Optional<This> filter(Predicate<? super String> condition)
condition
.Optional
containing this instance if the condition is met; empty otherwise.is(Predicate)
public final This map(Function<? super String,String> mapper)
mapper
.mapper
- The mapping function to apply to the raw underlying value.Copyright © 2022. All rights reserved.