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

    Fields
    Modifier and Type
    Field
    Description
    static final Appender<Enum<?>>
    Used in enum-keyed maps and sets to write an Enum constant's name, rather than its toString result.
  • Method Summary

    Modifier and Type
    Method
    Description
    static <S extends CharSequence & Appendable, T>
    S
    append(S sb, T item)
    Commonly used as a method reference where a generic Appender is needed.
    static <S extends CharSequence & Appendable>
    S
    appendEnumName(S sb, Enum<?> item)
    Appends the Enum.name() to the given Appendable CharSequence, so valueOf can be used to look up an enum constant when reading.
    <S extends CharSequence & Appendable>
    S
    apply(S sb, T item)
    Appends item to sb and returns sb for chaining.
  • Field Details

    • ENUM_NAME_APPENDER

      static final Appender<Enum<?>> 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

      <S extends CharSequence & Appendable> S apply(S sb, T item)
      Appends item to sb and returns sb for 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 StringBuilder
      item - the item to append
      Returns:
      sb, after modification
    • append

      static <S extends CharSequence & Appendable, T> S append(S sb, T item)
      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 CharList
      T - the type of item, which will be run through Objects.toString(Object) to get a String representation
      Parameters:
      sb - an Appendable CharSequence that will be modified, such as a StringBuilder
      item - the item to append
      Returns:
      sb, after modification
    • appendEnumName

      static <S extends CharSequence & Appendable> S appendEnumName(S sb, Enum<?> item)
      Appends the Enum.name() to the given Appendable CharSequence, so valueOf can be used to look up an enum constant when reading.
      Similar to append(CharSequence, Object), but not intended to be used as a method reference; use ENUM_NAME_APPENDER if 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 StringBuilder
      item - the Enum item to append the Enum.name() of
      Returns:
      sb, after modification