Class AbstractFixtureBuilder<TYPEBUILDER,SELF extends AbstractFixtureBuilder<TYPEBUILDER,SELF>>

java.lang.Object
io.github.wouterbauweraerts.instancio.fixture.builder.AbstractFixtureBuilder<TYPEBUILDER,SELF>
Type Parameters:
TYPEBUILDER - : The class that you will be instantiating using instancio in combination with the AbstractFixtureBuilder
SELF - : The name of the subclass of the AbstractFixtureBuilder

public abstract class AbstractFixtureBuilder<TYPEBUILDER,SELF extends AbstractFixtureBuilder<TYPEBUILDER,SELF>> extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract TYPEBUILDER
    should call the buildInternal method with the correct model to instantiate the object.
    protected final TYPEBUILDER
    buildInternal(org.instancio.Model<TYPEBUILDER> model)
    This method will construct the actual instance.
    protected SELF
    ignore(org.instancio.Selector selector)
    ignore a field / multiple fields using an instancio Selector
    protected SELF
    ignoreField(org.instancio.GetMethodSelector<TYPEBUILDER,?> methodReference)
    ignoreField will set a value to NULL
    abstract SELF
    should always return 'this' in every implementation.
    protected SELF
    set(org.instancio.TargetSelector selector, Object value)
    set will set a field or multiple fields to a given value.
    protected <PROPTYPE> SELF
    setField(org.instancio.GetMethodSelector<TYPEBUILDER,PROPTYPE> methodReference, PROPTYPE value)
    setField method will define the value for a given field, which will be used once the instance is constructed

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AbstractFixtureBuilder

      public AbstractFixtureBuilder()
  • Method Details

    • setField

      protected <PROPTYPE> SELF setField(org.instancio.GetMethodSelector<TYPEBUILDER,PROPTYPE> methodReference, PROPTYPE value)
      setField method will define the value for a given field, which will be used once the instance is constructed
      Type Parameters:
      PROPTYPE - type of the attribute you want to set to a specific value
      Parameters:
      methodReference - method-reference to the getter of the field you want to set
      value - the value you want to assign
      Returns:
      returns an instance of the FixtureBuilder
    • ignoreField

      protected SELF ignoreField(org.instancio.GetMethodSelector<TYPEBUILDER,?> methodReference)
      ignoreField will set a value to NULL
      Parameters:
      methodReference - method-reference referencing the getter of the field you want to ignore
      Returns:
      current instance of the FixtureBuilder
    • set

      protected SELF set(org.instancio.TargetSelector selector, Object value)
      set will set a field or multiple fields to a given value. See instancio documentation for available Selectors
      Parameters:
      selector - instancio Selector
      value - value to assign
      Returns:
      current instance of FixtureBuilder
    • ignore

      protected SELF ignore(org.instancio.Selector selector)
      ignore a field / multiple fields using an instancio Selector
      Parameters:
      selector - instancio Selector to be used. See instancio documentation for available Selectors
      Returns:
    • buildInternal

      protected final TYPEBUILDER buildInternal(org.instancio.Model<TYPEBUILDER> model)
      This method will construct the actual instance. It will take into account the model parameter, but also the values that were specified/ignored
      Parameters:
      model - Instancio model to be used for object creation
      Returns:
      Instance of the type being constructed
    • build

      public abstract TYPEBUILDER build()
      should call the buildInternal method with the correct model to instantiate the object. Should be implemented in each class
      Returns:
      newly created instance
    • self

      public abstract SELF self()
      should always return 'this' in every implementation. This has to be implemented in each class
      Returns:
      current fixture builder instance