Currently, App Studio supports the Java class constructor, getter and setter functions, override methods of the parent class that a child class inherits, and API methods to be implemented.

Procedure

Perform either of the following operations to generate the Java code:

  • Right-click the code area and select Generate.

  • Press Command+M on the keyboard. The Java code is automatically generated.

Constructor

On the Generate panel, select Constructor.

Select the fields to be included in the constructor and click OK.

The constructor that contains the initialization statement of the fields is generated.

Getter and setter functions

Generate the getter and setter functions in a way similar to the constructor.

Note If a Java class does not have any field or the Java class is overwritten by the @data annotation of lombok, the getter or setter function is not required for the Java class. In this case, the Getter, Setter, and Getter And Setter options do not appear on the Generate panel.

Override methods

Select Override Methods on the Generate panel. All methods that can be overridden are listed on the Generate Code panel.

Select a method. The corresponding method is generated.

Implement methods

The way of implementing a method is similar to that of overriding a method. In Java, a class that implements an API must define the methods of the API. If a method is not implemented, the class syntax is incorrect, which is underlined with a red wavy line.

In addition to selecting Implement Methods on the Generate panel, you can also use the code hinting feature to implement a method.

The following figure shows the generated code.