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

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.

主站蜘蛛池模板: 鄂托克前旗| 雷山县| 阳山县| 南江县| 康定县| 珲春市| 阿勒泰市| 灵宝市| 鲁山县| 和田县| 阿拉尔市| 青浦区| 吉木萨尔县| 崇信县| 航空| 尼勒克县| 仙桃市| 宝丰县| 黄梅县| 德格县| 崇文区| 琼中| 东台市| 扎囊县| 湛江市| 东源县| 如皋市| 苏尼特左旗| 哈密市| 杭州市| 银川市| 夹江县| 纳雍县| 昌宁县| 青龙| 任丘市| 禹城市| 大名县| 泽州县| 靖宇县| 安化县|