官术网_书友最值得收藏!

Adding attributes to classes

To add a private name property with getters and setters to the HelloJBossWorld class, use the java-new-field Forge command. This command is applied to the selected classes:

[HelloJBossWorld.java]$ java-new-field
***INFO*** Required inputs not satisfied, entering interactive mode
[0] (x) com.beosbank.forge.demo.HelloJBossWorld
Press <ENTER> to confirm, or <CTRL>+C to cancel.
* Target Class (The class where the field will be created): [0] 0
* Field Name (The field name to be created in this class): name
* Field Type (The type intended to be used for this field) [String]:
[0] ( ) public
[1] ( ) protected
[2] (x) private
[3] ( ) default
Press <ENTER> to confirm, or <CTRL>+C to cancel.
? Access Type (The access type): [0-3] 2
? Generate Getter (Generate accessor method) [Y/n]: Y
? Generate Setter (Generate mutator method) [Y/n]: Y
? Update toString (Updates the toString method by adding the field) [Y/n]:Y
***SUCCESS*** Field name created

We now have a mini project set up with a single class. Forge commands are not only used to create a project's objects but can also serve as gateways to interact with project builder tools such as maven.

主站蜘蛛池模板: 辽宁省| 日土县| 淳安县| 江口县| 东莞市| 明光市| 阿鲁科尔沁旗| 盐亭县| 赣榆县| 富平县| 封丘县| 长白| 南平市| 抚顺市| 肥西县| 横山县| 呼图壁县| 石家庄市| 镇平县| 崇仁县| 阳东县| 安多县| 左权县| 富川| 闵行区| 天全县| 昂仁县| 霍林郭勒市| 宁夏| 康平县| 于田县| 介休市| 墨江| 岚皋县| 阳山县| 新蔡县| 西华县| 陈巴尔虎旗| 正镶白旗| 肃宁县| 昌都县|