vendredi 4 décembre 2015

How to give access inside Groovy script to a field by adding getter for a field through an annotation

I have a model class with fields inside:

public class Model1 {
  @Bind private int LL; 
  @Bind private  double[] twKI; 
  @Bind private  double[] twKS; 
  @Bind private  double[] twINW; 
  @Bind private  double[] twEKS; 
}

I created an annotation:

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME) 

public @interface Bind {


}

Is it possible to define getter and setters for fields inside Model1 class without modyfing it so later on they will by available in groovy script?





Aucun commentaire:

Enregistrer un commentaire