It generates the following for me:
package com.test;
import com.test1.Address;
public class TestClass {
private Address myAddr;
private Address myAddr2;
public Address getAddr() {
}
}
Maybe you are using an older version?
Mark Zhang wrote:
> Hello Kohsuke,
> I am doing some coding on code model. I am having an issue and wondering if you can give me some hints,I appreciate it.
> Here is what I have:
> JCodeModel cm = new JCodeModel();
> JDefinedClass dc = cm._class("com.test.TestClass");
> dc.field(JMod.PRIVATE, cm.ref("com.test1.Address"),"myAddr");
> dc.field(JMod.PRIVATE, cm.ref("com.test1.Address"),"myAddr2");
> dc.method(JMod.PUBLIC, cm.ref("com.test1.Address"), "getAddr");
>
> Here is what I got:
>
> package com.test;
>
> public class TestClass {
> private com.test1.Address myAddr;
> private com.test1.Address myAddr2;
> public TestClass() {
> }
> public com.test1.Address getAddr() {
> }
> put whatever you want here
> }
>
>
> and Here is what I wanted:
> (I want the import clause in the generated source code. and short name for the defination, It seems that what there are more the 2 filed have the same type , it goes that way. any help ?)
>
> package com.test;
> import com.test1.Address;
> public class TestClass {
> private Address myAddr;
> private Address myAddr2;
> public TestClass() {
> }
> public Address getAddr() {
> }
> put whatever you want here
> }
>
>
>
> Thanks a lot.
>
> Best Regards,
>
>
>
> ____________________________________________________________________________________
> Need a quick answer? Get one in minutes from people who know.
> Ask your question on www.Answers.yahoo.com
>
--
Kohsuke Kawaguchi
Sun Microsystems kohsuke.kawaguchi_at_sun.com