dimanche 15 février 2015

Extract relative path of properties having a specific annotation in a nested data model

I have many pojo classes in my data model layer.

I want to get all the properties that have attribute @Searchable on them with the relative path in the object..

Actually I have written the @Searchable on the getter().

Now, my objects are usually nested as follows :



public class Dog {
private int id;
private String name;
private DogLeg leg;


public int getID(){ return id; }
@searchable
public String getName(){ return name; }
public DogLeg getLeg(){ return leg; }
}

public class DogLeg {
private int id;
private String legName;


public int getID(){ return id; }
@searchable
public String getLegName(){ return legName; }
}


What I want as an output is a list of strings containing:



dog.name, dog.leg.legName


How can I do it? Is there any framework that can do it out of the box? I tried using Introspector with recursion but got stuck deciding on a stop condition.






Aucun commentaire:

Enregistrer un commentaire