mardi 3 mars 2015

Validate annotation on getters in Spring 4

How to make delegate fields validation (using annotation) in wrapper? Is it possible to make annotation on getter instead on fields? I tried to do something like this:



class A{
private Object obj;

public Object getObj(){
return obj;
}

public void setObj(Object obj){
this.obj = obj;
}
}

@Component
class Wrapper{
A a;

public Wrapper(A a){
this.a = a;
}

@NotNull
public getObj(){
a.getObj();
}

public setObj(Object obj){
a.setObj(obj);
}
}

Aucun commentaire:

Enregistrer un commentaire