Interface Stringifier

All Known Implementing Classes:
ReflectionStringifier
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface Stringifier
A stringifier is a function for transforming objects to a string representations.
  • Method Summary

    Modifier and Type
    Method
    Description
    default Stringifier
    orElse(Stringifier stringifier)
    Returns a new stringifier using the given stringifier as an alternative to the current stringifier if the current stringifier cannot create a string representation.
    default String
    stringify(Object object)
    Creates a string representation of the given object or null, if no string representation can be created.
    default String
    stringifyOrElseDefault(Object object, String defaultString)
    Creates a string representation of the given object or use the given default string, if no string representation can be created.
    default String
    stringifyOrElseDefault(Object object, Supplier<String> defaultStringSupplier)
    Creates a string representation of the given object or the default string supplied by the given suuplier, if no string representation can be created.
    Creates a string representation of the given object or null, if no string representation can be created.
    default String
    Creates a string representation of the given object or use String.toString(), if no string representation can be created.
  • Method Details

    • orElse

      default Stringifier orElse(Stringifier stringifier)
      Returns a new stringifier using the given stringifier as an alternative to the current stringifier if the current stringifier cannot create a string representation.
      Parameters:
      stringifier - the stringifier to use as an alternative to the current stringifier
      Returns:
      the new stringifier using the given stringifier as an alternative to the current stringifier
    • stringify

      default String stringify(Object object)

      Creates a string representation of the given object or null, if no string representation can be created.

      This method is a shortcut for stringifyOrElseNull(Object)

      Parameters:
      object - the object to create a string representation for
      Returns:
      the string representation of the given object or null
    • stringifyOrElseDefault

      default String stringifyOrElseDefault(Object object, Supplier<String> defaultStringSupplier)
      Creates a string representation of the given object or the default string supplied by the given suuplier, if no string representation can be created.
      Parameters:
      object - the object to create a string representation for
      defaultStringSupplier - the supplier to use if no string representation can be created
      Returns:
      the string representation of the given object
    • stringifyOrElseDefault

      default String stringifyOrElseDefault(Object object, String defaultString)
      Creates a string representation of the given object or use the given default string, if no string representation can be created.
      Parameters:
      object - the object to create a string representation for
      defaultString - the default string to use if no string representation can be created
      Returns:
      the string representation of the given object
    • stringifyOrElseNull

      String stringifyOrElseNull(Object object)
      Creates a string representation of the given object or null, if no string representation can be created.
      Parameters:
      object - the object to create a string representation for
      Returns:
      the string representation of the given object or null
    • stringifyOrElseToString

      default String stringifyOrElseToString(Object object)
      Creates a string representation of the given object or use String.toString(), if no string representation can be created.
      Parameters:
      object - the object to create a string representation for
      Returns:
      the string representation of the given object