2
我遇到了問題,我希望有人能幫助我。Spring - AOP - 註釋代碼生成
我使用Spring框架,我想裏面生成我的域名類的一個方法...
我有一個域實體:
@Entity
class AbcDomain {
private int id;
@CustomAnnotation(p1="x1", p2="y1")
private String a;
@CustomAnnotation(p1="x2", p2="y2")
private String b;
@CustomAnnotation(p1="3", p2="y3")
private int c;
private Set<Integer> d;
... getters and setters
}
我要生成「 m「方法到這個域。 方法包含的Fileds,這得到了「CustomAnnotation」的註釋是這樣的:
@Entity
class AbcDomain {
... Prev code ...
public String m() {
if ("x1".equals(a)) // "x1" comes from the annotation's p1 param
return "y1"; // "y1" comes from the annotation's p2 param
if ("x2".equals(b)) // "x2" comes from the annotation's p1 param
return "y2"; // "y2" comes from the annotation's p2 param
if (c == 3) // 3 comes from the annotation's p1 param
return "y3"; // "y3" comes from the annotation's p1 param
}
}
我很新的春天和AOP,任何人可以幫助我在哪裏可以找到解決辦法嗎?
感謝