How to determine how many fields are set on a object in Java
<p>Not sure if I can do this but, say I had the object:</p>

<pre><code>public class SomeObject
{
    private String field1;
    private String field2;
    ....

    //Blah Blah getters and setters for all fields
}
</code></pre>

<p>I want to get a count of how many of these fields are non-null.  My particular object has like 40 fields so I really don't want to have a if block to check each of the 40 fields individually.  I was thinking I could do this with reflection somehow? but really don't know what I am doing with it.  It would be nice to just iterate through all the fields and check their value.</p>

<p>I feel like this is a no brainer for someone out there.</p>
