Class FormatServer<F>

java.lang.Object
eu.bandm.tools.format.spi.FormatProxy<F>
eu.bandm.tools.format.spi.FormatServer<F>
Type Parameters:
F - the type of format objects to produce
All Implemented Interfaces:
FormatProvider<F>

public class FormatServer<F> extends FormatProxy<F>
A proxy provider that adds convenience methods for producing format objects.

The main reason for the existence of this class is that methods with generic vararg parameters cannot be safely declared in an interface.

See Also:
  • Field Summary

    Fields inherited from class eu.bandm.tools.format.spi.FormatProxy

    provider
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    final F
    append(F... elems)
    Returns a compound format object that concatenates the given elements horizontally with absolute indentation.
    final F
    beneath(F... elems)
    Returns a compound format object that concatenates the given elements vertically.
    final F
    beside(F... elems)
    Returns a compound format object that concatenates the given elements horizontally with relative indentation.
    final F
    block(F... elems)
    Returns a compound format object that concatenates the given elements first horizontally and then vertically.
    Represents the given object as a format object.
    final F
    line(F... elems)
    Returns a compound format object that concatenates the given elements either horizontally or vertically.

    Methods inherited from class eu.bandm.tools.format.spi.FormatProxy

    append, beneath, beside, block, line, literal, space

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • FormatServer

      public FormatServer(FormatProvider<F> provider)
      Creates a new instance.
      Parameters:
      provider - the provider to delegate to
      Throws:
      NullPointerException - if provider == null
  • Method Details

    • format

      public F format(@Opt @Opt Object x)
      Represents the given object as a format object.

      Instances of FormatClient are represented by passing this to their method FormatClient.format(eu.bandm.tools.format.spi.FormatServer<F>). Other objects, and null references, are represented by an atomic string according to String.valueOf(Object).

      Parameters:
      x - the object to represent, or null
      Returns:
      a format object representation
    • append

      @SafeVarargs public final F append(F... elems)
      Returns a compound format object that concatenates the given elements horizontally with absolute indentation.
      Parameters:
      elems - the format subobjects to concatenate
      Returns:
      a concatenated compound format object
    • beside

      @SafeVarargs public final F beside(F... elems)
      Returns a compound format object that concatenates the given elements horizontally with relative indentation.
      Parameters:
      elems - the format subobjects to concatenate
      Returns:
      a concatenated compound format object
    • beneath

      @SafeVarargs public final F beneath(F... elems)
      Returns a compound format object that concatenates the given elements vertically.
      Parameters:
      elems - the format subobjects to concatenate
      Returns:
      a concatenated compound format object
    • line

      @SafeVarargs public final F line(F... elems)
      Returns a compound format object that concatenates the given elements either horizontally or vertically.
      Parameters:
      elems - the format subobjects to concatenate
      Returns:
      a concatenated compound format object
    • block

      @SafeVarargs public final F block(F... elems)
      Returns a compound format object that concatenates the given elements first horizontally and then vertically.
      Parameters:
      elems - the format subobjects to concatenate
      Returns:
      a concatenated compound format object