You don’t have to write the entire code and main function and stuff.
To give a rough visualization of how rule works, consider that you are writing the code that is inside a callable function. What ever you write into it will be executed line by line. you don’t have to worry about how that is called or if there is a main function.
To kind of walkthrough the documentation you have the inputs section that available to be directly accessed. for example if you see the in the Example Section they would have used rawResponseObject in the line
Map response = (Map) JsonUtil.toMap(rawResponseObject);
Meaning it’s available across your Java code all the 5 inputs
When you take Output section into consideration, the code that write should have a return statement with that data,
If you see the example section you would notice that we have,
Map updatedMapInfo = new HashMap();
// some code logic you want to do
return updatedMapInfo;
Hope this gives you a rough context of how to get started with rules.