Interface CharAppender


public interface CharAppender
A functional interface that takes and returns an object that is a CharSequence and is Appendable, appending a byte item to it. This is often a method reference to a method in Base, such as Base.appendSigned(CharSequence, char).
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final CharAppender
    A static constant to avoid Android and its R8 compiler allocating a new lambda every time StringBuilder::append is present at a call-site.
    static final CharAppender
    Appends the given char in single quotes, with a backslash-escape if it would be necessary in Java sources.
    static final CharAppender
    Appends char constants as they would be read in Java sources, in single quotes, with backslash escapes if necessary.
  • Method Summary

    Modifier and Type
    Method
    Description
    static <S extends CharSequence & Appendable>
    S
    append(S sb, char item)
     
    <S extends CharSequence & Appendable>
    S
    apply(S sb, char item)
    Appends item to sb and returns sb for chaining.
  • Field Details

    • DEFAULT

      static final CharAppender DEFAULT
      A static constant to avoid Android and its R8 compiler allocating a new lambda every time StringBuilder::append is present at a call-site. This should be used in place of StringBuilder.append(char) when you want to use that as a CharAppender.
      This functional interface doesn't have a DENSE method reference because appending one shown char per char item is really as dense as you can get already.
    • QUOTED

      static final CharAppender QUOTED
      Appends the given char in single quotes, with a backslash-escape if it would be necessary in Java sources.
    • READABLE

      static final CharAppender READABLE
      Appends char constants as they would be read in Java sources, in single quotes, with backslash escapes if necessary.
  • Method Details

    • apply

      <S extends CharSequence & Appendable> S apply(S sb, char 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:
      first, after modification
    • append

      static <S extends CharSequence & Appendable> S append(S sb, char item)