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 AbstractFixtureBuilderSELF- : The name of the subclass of the AbstractFixtureBuilder
public abstract class AbstractFixtureBuilder<TYPEBUILDER,SELF extends AbstractFixtureBuilder<TYPEBUILDER,SELF>>
extends Object
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract TYPEBUILDERbuild()should call the buildInternal method with the correct model to instantiate the object.protected final TYPEBUILDERbuildInternal(org.instancio.Model<TYPEBUILDER> model) This method will construct the actual instance.protected SELFignore(org.instancio.Selector selector) ignore a field / multiple fields using an instancio Selectorprotected SELFignoreField(org.instancio.GetMethodSelector<TYPEBUILDER, ?> methodReference) ignoreField will set a value to NULLabstract SELFself()should always return 'this' in every implementation.protected SELFset will set a field or multiple fields to a given value.protected <PROPTYPE> SELFsetField(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
-
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 setvalue- the value you want to assign- Returns:
- returns an instance of the FixtureBuilder
-
ignoreField
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
set will set a field or multiple fields to a given value. See instancio documentation for available Selectors- Parameters:
selector- instancio Selectorvalue- value to assign- Returns:
- current instance of FixtureBuilder
-
ignore
ignore a field / multiple fields using an instancio Selector- Parameters:
selector- instancio Selector to be used. See instancio documentation for available Selectors- Returns:
-
buildInternal
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
should call the buildInternal method with the correct model to instantiate the object. Should be implemented in each class- Returns:
- newly created instance
-
self
should always return 'this' in every implementation. This has to be implemented in each class- Returns:
- current fixture builder instance
-