Class Formatter

java.lang.Object
net.andreinc.mockneat.unit.text.Formatter
All Implemented Interfaces:
MockUnit<java.lang.String>, MockUnitString

public final class Formatter
extends java.lang.Object
implements MockUnitString
  • Constructor Details

    • Formatter

      public Formatter​(java.lang.String fmt)
  • Method Details

    • fmt

      public static Formatter fmt​(java.lang.String fmt)

      Returns a Formatter object than can be used to generate arbitrary patterns based on a given format.

      Parameters:
      fmt - The template of the desired pattern.
      Returns:
      A new Formatter object. The Formatter class implements MockUnitString.
    • formatter

      public static Formatter formatter​(java.lang.String fmt)

      Returns a Formatter object than can be used to generate arbitrary patterns based on a given format.

      Parameters:
      fmt - The template of the desired pattern.
      Returns:
      A new Formatter object. The Formatter class implements MockUnitString.
    • param

      public <T> Formatter param​(java.lang.String param, MockUnit<T> mock)

      This method can be used to map a parameter from the template with a MockUnit.

      Type Parameters:
      T - The type of the MockUnit
      Parameters:
      param - The parameter name as supplied in the template.
      mock - The MockUnit that generates values for the given parameter.
      Returns:
      The Formatter object.
    • param

      public Formatter param​(java.lang.String param, java.lang.String constValue)

      This method can be used to map a parameter from the template with a String value (not a MockUnit!).

      Parameters:
      param - The parameter name as supplied in the template.
      constValue - The string value.
      Returns:
      The Formatter object.
    • supplier

      public java.util.function.Supplier<java.lang.String> supplier()
      Description copied from interface: MockUnit
      This is the sole abstract method of the interface. Needs to be implemented every-time a MockUnit is implemented.
      Specified by:
      supplier in interface MockUnit<java.lang.String>
      Returns:
      A Supplier<T>.