Package dev.zyzdev
Class FakeModelBuilder
java.lang.Object
dev.zyzdev.FakeModelBuilder
This is a library help to new instance of a data model.
To custom the generation rule of field value, you should add
annotation
FakeConfig to the field.- Since:
- 0.0.1
- Version:
- 0.0.1
- Author:
- zyzdev https://github.com/zyzdev
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDefultValue(String fieldName, Object value) Add default value of the field.<T> TBuild fake model of T.voidremoveDefultValue(String fieldName) Remove default value of the field.
-
Constructor Details
-
FakeModelBuilder
public FakeModelBuilder()A empry argument constructor.
-
-
Method Details
-
build
public <T> T build(Class<T> clazz) throws InstantiationException, IllegalAccessException, InvocationTargetException Build fake model of T.- Type Parameters:
T- the type of data model- Parameters:
clazz- the Class of data model- Returns:
- the fake data model
- Throws:
InstantiationException- new instance data model may exceptionIllegalAccessException- new instance data model or set value to field may exception.InvocationTargetException- new instance data model may exception
-
addDefultValue
Add default value of the field.- Parameters:
fieldName- the name of the fieldvalue- the field default value you want to set
-
removeDefultValue
Remove default value of the field.- Parameters:
fieldName- the name of the field
-