Search code examples
annotationsballerina

What is the purpose of using `@display` annotation in Ballerina?


In Ballerina, I've come across code that uses the @display annotation in service and record parameters. Can someone please clarify what the @display annotation is used for and provide some use cases for it?


Solution

  • The @display annotation in Ballerina is a general purpose annotation that serves various use cases.

    One use case is that when multiple services interact within a project, applying the same id in the @display annotation ensures the link of services with the clients accurately. This is useful to visualize the connection between clients and services in the diagrams. For more in-depth information, you can refer to this.

    Additionally, the label attribute of the @display annotation allows you to assign labels to services or records in diagrams. This feature enables you to provide meaningful names for services or records, enhancing their comprehensibility for developers.

    These are just a few of the use cases, but developers can adapt the @display annotation for various other purposes based on their preferences.