Class SpecimenBuilder<T>

    • Method Detail

      • create

        public T create()
        Specified by:
        create in interface ISpecimenBuilder<T>
        Returns:
        a new object based on this ISpecimenBuilder<T>
      • createMany

        public Stream<T> createMany​(int size)
        Creates a Stream of objects based on this ISpecimenBuilder<T> with the specified size
        Specified by:
        createMany in interface ISpecimenBuilder<T>
        Parameters:
        size - the size of the Stream to be created
        Returns:
        a Stream of objects based on this ISpecimenBuilder<T>
      • with

        public ISpecimenBuilder<T> with​(Consumer<T> function)
        Applies the specified function to the created object
        Specified by:
        with in interface ISpecimenBuilder<T>
        Parameters:
        function - a function to customise the created object
        Returns:
        this builder for further customisation
      • with

        public ISpecimenBuilder<T> with​(String fieldName,
                                        Object value)
        Sets the field with the specified name to the specified value during object creation
        Specified by:
        with in interface ISpecimenBuilder<T>
        Parameters:
        fieldName - the name of the field to be set
        value - the value to be set to the field
        Returns:
        this builder for further customisation
      • with

        public <U> ISpecimenBuilder<T> with​(Class<U> type,
                                            U value)
        Sets all fields with the specified type to the specified value during object creation.
        Specified by:
        with in interface ISpecimenBuilder<T>
        Type Parameters:
        U - the type of the value
        Parameters:
        type - the type of the fields to be set
        value - the value to be set to the fields
        Returns:
        this builder for further customisation
      • with

        public <U> ISpecimenBuilder<T> with​(SpecimenType<U> type,
                                            U value)
        Sets all fields with the specified type to the specified value during object creation.
        Specified by:
        with in interface ISpecimenBuilder<T>
        Type Parameters:
        U - the type of the value
        Parameters:
        type - the type of the fields to be set
        value - the value to be set to the fields
        Returns:
        this builder for further customisation
      • without

        public ISpecimenBuilder<T> without​(String fieldName)
        Omits the field with the specified name during object creation Primitives will receive their respective default-value, objects will be null
        Specified by:
        without in interface ISpecimenBuilder<T>
        Parameters:
        fieldName - the name of the field to be set
        Returns:
        this builder for further customisation