Class TestPojoBuilder<T>


  • public class TestPojoBuilder<T>
    extends Object
    • Method Detail

      • addGenerator

        public TestPojoBuilder<T> addGenerator​(Generator generator)
        Adds a custom generator for a type that isn't currently supported out of the box. This allows the builder to know how to build an object it otherwise wouldn't know how. For example, if there's a new type of collection interface that isn't currently supported.
        Parameters:
        generator - generator for generating the new type of class.
        Returns:
        the builder
      • addProviderFunction

        public TestPojoBuilder<T> addProviderFunction​(ProviderFunction providerFunction,
                                                      Class<?> clazz,
                                                      Class<?>... clazzes)
        Adds a custom provider in order to allow the builder to know how to create a *New* object of that type. Requires at least one class for each provider. If the provider creates for multiple classes, you can provide more classes. I.E ( a concurrent map creation can provide for ConcurrentMap, Map, etc)
        Parameters:
        providerFunction - a provider that news an object of a provided type
        clazz - a mandatory class that will be created by the provider function.
        clazzes - additional classes that can be created by provider function.
        Returns:
        the builder
      • addProviderFunction

        public TestPojoBuilder<T> addProviderFunction​(ProviderFunction providerFunction,
                                                      String builderMethod,
                                                      Class<?> clazz,
                                                      Class<?>... clazzes)
        Adds a custom provider in order to allow the builder to know how to create a *New* object of that type. Requires at least one class for each provider. If the provider creates for multiple classes, you can provide more classes. I.E ( a concurrent map creation can provide for ConcurrentMap, Map, etc)
        Parameters:
        providerFunction - a provider that news an object of a provided type
        builderMethod - a method to call to build the class if its a builder
        clazz - a mandatory class that will be created by the provider function.
        clazzes - additional classes that can be created by provider function.
        Returns:
        the builder
      • addLimiter

        public TestPojoBuilder<T> addLimiter​(String fieldName,
                                             Limiter limiter)
        Adds a new Limiter per field name that will limit and control the randomness of the generated field.
        Parameters:
        fieldName - the name of the field
        limiter - the limiter for the field
        Returns:
        the builder
      • addExcludedField

        public TestPojoBuilder<T> addExcludedField​(String fieldName)
        Adds a field name to the builder so that this field will not be generated. This field will likely be null but can depend on the constructor or builder used to provide the new object. You can also control this via a provider.
        Parameters:
        fieldName - the field name
        Returns:
        the builder
      • addExcludedFields

        public TestPojoBuilder<T> addExcludedFields​(String fieldName,
                                                    String... fields)
        Adds multiple fields to be excluded from generation. This field will likely be null but can depend on the constructor or builder used to provide the new object. You can also control this via a provider.
        Parameters:
        fieldName - the field name to ignore
        fields - the additional field names to ignore
        Returns:
        the builder
      • setRandomGeneratorSeed

        public TestPojoBuilder<T> setRandomGeneratorSeed​(long seed)
      • setWarnOnFieldNotExisting

        public TestPojoBuilder<T> setWarnOnFieldNotExisting​(boolean warn)
        Typically, if you set an excluded field or limiter, we will throw an exception to let you know that the excludes or limiter isn't going to be used. Setting this to true, will enable only warning via log message and will not throw an exception
        Parameters:
        warn - if you want it to warn, otherwise error
        Returns:
        TestPojoBuilder
      • build

        public T build()
        Builds the object with the random data generated.
        Returns:
        T the object asked to build