Class Formats

java.lang.Object
eu.bandm.tools.lexic.Formats

final class Formats extends Object
This class contains only static factories for pretty-printable representations of collections. It cannot be instantiated.
See Also:
  • Method Details

    • setFormat

      static <F> F setFormat(FormatServer<F> server, @Opt @Opt Set<?> set)
      Returns a pretty-printable representation of a set.

      The default representation of elements via Format.of(java.lang.Object) is used.

      Type Parameters:
      F - the type of format objects to produce
      Parameters:
      server - a factory object that can produce format objects
      set - the set, or null
      Returns:
      a pretty-printable representation of the given set, or the literal null
    • setFormat

      static <A, F> F setFormat(FormatServer<F> server, @Opt @Opt Set<A> set, Function<? super A,? extends F> onElem)
      Returns a pretty-printable representation of a set.
      Type Parameters:
      A - the type of elements
      F - the type of format objects to produce
      Parameters:
      server - a factory object that can produce format objects
      set - the set, or null
      onElem - the function for computing representations of elements
      Returns:
      a pretty-printable representation of the given set, or the literal null
    • listFormat

      static <F> F listFormat(FormatServer<F> server, @Opt @Opt List<?> list)
      Returns a pretty-printable representation of a list.

      The default representation of elements via Format.of(java.lang.Object) is used.

      Type Parameters:
      F - the type of format objects to produce
      Parameters:
      server - a factory object that can produce format objects
      list - the list, or null
      Returns:
      a pretty-printable representation of the given list, or the literal null
    • listFormat

      static <A, F> F listFormat(FormatServer<F> server, @Opt @Opt List<A> list, Function<? super A,? extends F> onElem)
      Returns a pretty-printable representation of a list.
      Type Parameters:
      A - the type of elements
      F - the type of format objects to produce
      Parameters:
      server - a factory object that can produce format objects
      list - the list, or null
      onElem - the function for computing representations of elements
      Returns:
      a pretty-printable representation of the given list, or the literal null
    • collectionFormat

      static <A, F> F collectionFormat(FormatServer<F> server, @Opt @Opt Collection<A> collection, Function<? super A,? extends F> onElem, F open, F close)
      Returns a pretty-printable representation of a collection.
      Type Parameters:
      A - the type of elements
      F - the type of format objects to produce
      Parameters:
      server - a factory object that can produce format objects
      collection - the collection, or null
      onElem - the function for computing representations of elements
      open - the opening bracket
      close - the closing bracket
      Returns:
      a pretty-printable representation of the given list, or the literal null
    • mapFormat

      static <K, V, F> F mapFormat(FormatServer<F> server, @Opt @Opt Map<K,V> map, Function<? super K,? extends F> onKey, Function<? super V,? extends F> onValue)
      Returns a pretty-printable representation of a map.
      Type Parameters:
      K - the type of keys
      V - the type of values
      F - the type of format objects to produce
      Parameters:
      server - a factory object that can produce format objects
      map - the map, or null
      onKey - the function for computing representations of keys
      onValue - the function for computing representations of values
      Returns:
      a pretty-printable representation of the given map, or the literal null
    • entryFormat

      static <K, V, F> F entryFormat(FormatServer<F> server, Map.Entry<K,V> entry, Function<? super K,? extends F> onKey, Function<? super V,? extends F> onValue)
      Returns a pretty-printable representation of a map entry.
      Type Parameters:
      K - the type of keys
      V - the type of values
      F - the type of format objects to produce
      Parameters:
      server - a factory object that can produce format objects
      entry - the map entry
      onKey - the function for computing representations of keys
      onValue - the function for computing representations of values
      Returns:
      a pretty-printable representation of the given map entry