Interface Appender<T>
- Type Parameters:
T- the type of items that can be appended by this functional interface
public interface Appender<T>
A functional interface that takes and returns an object that is a CharSequence and is Appendable, appending
a
T item to it.
This is not typically a method reference to anything in Base, which is different from other Appender types. This will frequently
use a lambda.-
Field Summary
FieldsModifier and TypeFieldDescriptionUsed in enum-keyed maps and sets to write an Enum constant's name, rather than its toString result. -
Method Summary
Modifier and TypeMethodDescriptionstatic <S extends CharSequence & Appendable,T>
Sappend(S sb, T item) Commonly used as a method reference where a generic Appender is needed.static <S extends CharSequence & Appendable>
SappendEnumName(S sb, Enum<?> item) Appends theEnum.name()to the given Appendable CharSequence, sovalueOfcan be used to look up an enum constant when reading.<S extends CharSequence & Appendable>
SAppendsitemtosband returnssbfor chaining.
-
Field Details
-
ENUM_NAME_APPENDER
Used in enum-keyed maps and sets to write an Enum constant's name, rather than its toString result. Does not use a method reference, and instead has to use an anonymous inner class, because of GWT.
-
-
Method Details
-
apply
Appendsitemtosband returnssbfor chaining.- Type Parameters:
S- any type that is both a CharSequence and an Appendable, such as StringBuilder, StringBuffer, CharBuffer, or CharList- Parameters:
sb- an Appendable CharSequence that will be modified, such as a StringBuilderitem- the item to append- Returns:
sb, after modification
-
append
Commonly used as a method reference where a generic Appender is needed.- Type Parameters:
S- any type that is both a CharSequence and an Appendable, such as StringBuilder, StringBuffer, CharBuffer, or CharListT- the type ofitem, which will be run throughObjects.toString(Object)to get a String representation- Parameters:
sb- an Appendable CharSequence that will be modified, such as a StringBuilderitem- the item to append- Returns:
sb, after modification
-
appendEnumName
Appends theEnum.name()to the given Appendable CharSequence, sovalueOfcan be used to look up an enum constant when reading.
Similar toappend(CharSequence, Object), but not intended to be used as a method reference; useENUM_NAME_APPENDERif you need an Appender instance (it should perform identically, but works around a bug in GWT that would make a method reference fail to compile).- Type Parameters:
S- any type that is both a CharSequence and an Appendable, such as StringBuilder, StringBuffer, CharBuffer, or CharList- Parameters:
sb- an Appendable CharSequence that will be modified, such as a StringBuilderitem- the Enum item to append theEnum.name()of- Returns:
sb, after modification
-