[Beans] Créer un PropertyDescriptor avec une ReadMethod prenant un paramètre
Salut,
j'ai une classe avec getter/setter de ce type :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| public int getRGBAColorChannel(int index) {
if(index < 0 || index > 3) {
index = 0;
}
return this.rgbaColorChannels[index];
}
public void setRGBAColorChannel(int index, int value) {
if(index < 0 || index > 3) {
index = 0;
}
if (value < 0) {
value = 0;
}
else if (value > 255) {
value = 255;
}
this.rgbaColorChannels[index] = value;
} |
J'aimerais créer des PropertyDescriptor pour les 4 entrées du tableau rgbaColorChannels.
J'ai tenté :
Code:
1 2 3 4 5 6 7 8 9 10
| try {
PropertyDescriptor pd = new PropertyDescriptor("r channel", sprite.getClass().getMethod("getRGBAColorChannel", int.class),
sprite.getClass().getMethod("setRGBAColorChannel", int.class, int.class));
this.addPropertyDescriptor(pd);
}
catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} |
Mais j'ai l'exception suivante :
Code:
java.beans.IntrospectionException: bad read method arg count: public int VectorialSprite2d.getRGBAColorChannel(int)
Y aurait-il un moyen quelconque d'arriver à ce que je souhaite ?
Ou au pire y aurait-il moyen de binder une Method sur l'appel d'une autre en précisant des paramètres ? 8O arf pas très clair tout ça. L'idée serait de créer une nouvelle Method basée sur l'appel d'une existante avec des paramètres, pour l'exemple un truc du style :
getRChannel() bindée sur getRGBAChannel(0), sans créer évidemment getRChannel() dans la classe de base, juste pour la passer en tant que ReadMethod au PropertyDescriptor.
Merci d'avance.