-
Notifications
You must be signed in to change notification settings - Fork 0
Implementing your own suppliers
Esta Nagy edited this page Jul 1, 2020
·
3 revisions
Suppliers are really like magic: seemingly they can create things from thin air but there is always a parameter behind this neat trick.
To implement a new supplier, you just need to spend a few minutes on doing the following simple steps:
- Create a class for your supplier implementing the Supplier interface
- Create a constructor using only the supported parameter types as parameters
- Annotate your constructor with @NamedSupplier
- Annotate all of your constructor parameters as defined here
- Implement the
get()
method defined by the interface. - Register your supplier using FunctionRegistry#registerSupplierClass(Class)
- Make sure to add your supplier to the #/definitions/supplierTypes/definitions node of our JSON Schema
- Add a new definition similarly to the examples already in there
- Register the type supplier to the definition of the anySupplier definition by
- Adding the name to the enum containing all the names
- Adding a new object to the list similar to this:
{ "if": { "properties": { "name": { "const": "staticString" } } }, "then": { "$ref": "#/definitions/supplierTypes/definitions/supplierStaticString" } }
- ...and we are done, you can go play with your new supplier!