-
Notifications
You must be signed in to change notification settings - Fork 0
Implementing your own rules
Esta Nagy edited this page Jun 1, 2020
·
3 revisions
Each rule has two mandatory parameters and can have additional parameters on top of those at the discretion of the implementation.
The mandatory parameters are:
Name | Type |
---|---|
order |
Integer |
jsonPath |
com.jayway.jsonpath.JsonPath |
The interface all the Rules must implement is called JsonRule. If you can't seem to find the rule that fits your needs, you can always implement your own rule by doing the simple steps below.
- Create a class implementing the
JsonRule
interface or feel free to extend AbstractJsonRule for a bit of convenience. - Define a constructor with the following parameter list: ( FunctionRegistry, RawJsonRule )
- Annotate it with @NamedRule adding a unique name for your rule.
- In your constructor, figure out how to convert the input parameters you need.
- Implement the abstract methods coming form the interface/super class.
- Register your rule using JsonRuleRegistry#registerRuleClass(Class)
- Yippee-Ki-Yay you made it! You can start using your new rule.