Trim all strings elements in a complex object
<p>Can I write a generic method to trim all strings within an complex object (object containing other objects)? Should java reflection api be used to achieve this?Thanks.</p>

<p>I have provided a sample below. However in reality there could be multiple objects within objects. Each object might contain a collection of String or collection of other objects which may contain String. Is there a way to trim the Strings - ones directly with the objects and ones within collection.</p>

<pre><code>public class School{
   private List&lt;Course&gt; courses;
   private List&lt;Student&gt; students;       
   // Getters and Setters
}

public class Course{
   private String name;
   private String xxx;
   private String yyy;
   private List&lt;String&gt; zzzList;
}

public class Student{
   private Map&lt;String,String&gt; xxx;
   private List&lt;Course&gt; courseList;
}
</code></pre>
