Class TemplateFunctions

java.lang.Object
org.mockserver.templates.engine.TemplateFunctions
All Implemented Interfaces:
Supplier<Object>

public class TemplateFunctions extends Object implements Supplier<Object>
  • Field Details

  • Constructor Details

    • TemplateFunctions

      public TemplateFunctions(Supplier<String> supplier)
  • Method Details

    • resolveFaker

      public static net.datafaker.Faker resolveFaker(long templateFakerSeed)
      Resolve the faker helper bound into template contexts.

      When templateFakerSeed is 0 (the default) the shared, unseeded FAKER is returned, so faker-driven sample data stays time/random-based and behaviour is unchanged. When a non-zero seed is configured a fresh Faker backed by a Random seeded with that value is returned, so faker-driven templates produce reproducible fixtures across runs (the template analogue of the OpenAPI SampleDataGenerator fixed-seed model). The returned seeded faker is intended to be created once per template engine and reused across renders, so its value sequence is deterministic for a given order of renders.

      Parameters:
      templateFakerSeed - faker seed, 0 to leave faker unseeded (random)
      Returns:
      the shared unseeded faker when the seed is 0, otherwise a freshly seeded faker
    • randomInteger

      public static String randomInteger(int max)
    • randomBytes

      public static String randomBytes(int size)
    • get

      public Object get()
      Specified by:
      get in interface Supplier<Object>
    • toString

      public String toString()
      Overrides:
      toString in class Object