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

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.

主站蜘蛛池模板: 扶沟县| 平塘县| 小金县| 无为县| 佛学| 琼中| 大同县| 南昌市| 逊克县| 大冶市| 卢龙县| 重庆市| 通化市| 武定县| 景德镇市| 新蔡县| 留坝县| 临泽县| 云安县| 体育| 南乐县| 綦江县| 军事| 苏尼特右旗| 嫩江县| 北安市| 来宾市| 伊春市| 吴忠市| 乌兰浩特市| 随州市| 汉川市| 集贤县| 八宿县| 沙田区| 大荔县| 德昌县| 惠安县| 罗江县| 乌拉特前旗| 江安县|