#Visitor pattern using Ballerina

1 messages · Page 1 of 1 (latest)

jovial sky
#

How can we implement a visitor patter using Ballerina to extract information from an OpenAPI spec because Ballerina does not support method overloading?

grave wigeon
#

It is possible. Check this example: https://gist.github.com/hasithaa/47861aa8f2c8acf4f0e94ef31adf9bb8.

One downside to this approach is that everything must be modeled as objects. This might work or be suitable for your needs. However, without evaluating your requirements and model, I cannot definitively say that this is the best pattern to solve your problem.

jovial sky
#

thank you @grave wigeon

jovial sky
#

@grave wigeon actually I want to visit a set of records. Not objects.

#

in such cases, are there any best practices to implement visitors?

grave wigeon