Interface Appender<A extends Appendable>

Type Parameters:
A - the appendable
All Known Subinterfaces:
Escaper

public interface Appender<A extends Appendable>
A singleton like decorator for appendables that has additional methods for dealing with native types.
Author:
agentgt
See Also:
API Note
Unlike an Appendable this class is expected to be reused so avoid state and implementations should be thread safe.
  • Method Details

    • append

      void append(A a, CharSequence s) throws IOException
      Parameters:
      a - appendable to write to. Always non null.
      s - unlike appendable always non null.
      Throws:
      IOException - if an error happens while writting to the appendable
    • append

      void append(A a, CharSequence csq, int start, int end) throws IOException
      Parameters:
      a - appendable to write to. Never null.
      csq - Unlike appendable never null.
      start - start inclusive
      end - end exclusive
      Throws:
      IOException - if an error happens while writting to the appendable
    • append

      void append(A a, char c) throws IOException
      Appends a character to an appendable.
      Parameters:
      a - appendable to write to. Never null.
      c - character
      Throws:
      IOException - if an error happens while writting to the appendable
    • append

      default void append(A a, short s) throws IOException
      Write a short by using String.valueOf(int)
      Parameters:
      a - appendable to write to. Never null.
      s - short
      Throws:
      IOException - if an error happens while writting to the appendable
    • append

      default void append(A a, int i) throws IOException
      Write a int by using String.valueOf(int).

      Implementations should override if they want different behavior or able to support appendables that can write the native type.

      Parameters:
      a - appendable to write to. Never null.
      i - int
      Throws:
      IOException - if an error happens while writting to the appendable
    • append

      default void append(A a, long l) throws IOException
      Write a long by using String.valueOf(long).

      Implementations should override if they want different behavior or able to support appendables that can write the native type.

      Parameters:
      a - appendable to write to. Never null.
      l - long
      Throws:
      IOException - if an error happens while writting to the appendable
    • append

      default void append(A a, double d) throws IOException
      Write a long by using String.valueOf(long).

      Implementations should override if they want different behavior or able to support appendables that can write the native type.

      Parameters:
      a - appendable to write to. Never null.
      d - double
      Throws:
      IOException - if an error happens while writting to the appendable
    • append

      default void append(A a, boolean b) throws IOException
      Write a long by using String.valueOf(long).

      Implementations should override if they want different behavior or able to support appendables that can write the native type.

      Parameters:
      a - appendable to write to. Never null.
      b - boolean
      Throws:
      IOException - if an error happens while writting to the appendable
    • toAppendable

      default Appendable toAppendable(A appendable)
      Decorates an appendable with this appender such that the returned appendable will call the this appender which will then write to the inputted appendable.
      Parameters:
      appendable - never null.
      Returns:
      Appendable never null.
    • defaultAppender

      Default appender simply passes the contents unchanged to the Appendable.
      Returns:
      a passthrough appender
    • stringAppender

      An appender that will directly call StringBuilder methods for native types.

      This is a low level utility appenrer for where performance matters.

      Returns:
      an appender specifically for StringBuilder