Package dev.zyzdev

Class FakeModelBuilder

java.lang.Object
dev.zyzdev.FakeModelBuilder

public class FakeModelBuilder extends Object
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 Details

    • FakeModelBuilder

      public FakeModelBuilder()
      A empry argument constructor.
  • Method Details

    • build

      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 exception
      IllegalAccessException - new instance data model or set value to field may exception.
      InvocationTargetException - new instance data model may exception
    • addDefultValue

      public void addDefultValue(String fieldName, Object value)
      Add default value of the field.
      Parameters:
      fieldName - the name of the field
      value - the field default value you want to set
    • removeDefultValue

      public void removeDefultValue(String fieldName)
      Remove default value of the field.
      Parameters:
      fieldName - the name of the field