How can I know the last object when I reflect?
<p>I have a DTO like this,</p>

<pre><code>ADto{
  BDto bDto;
  Cto cDto;
}

BDto{
  String a1;
  String b1;
  int b1;
}

CDto{
  String a2;
  String b2;
  int b2;
}
</code></pre>

<p>When I use reflect,I want to get the <code>BDto</code> and <code>CDto</code> in <code>ADto</code> Object.Code like this:</p>

<pre><code> for (Field field : aObj.getClass().getDeclaredFields()) {
            try {
                Object fieldValue = field.get(object);
 //todo  how to collect all String value  in `BDto` and `CDto` of aObj
                if (fieldValue instanceof String) {
                    shouldCheckFieldValues.add((String) fieldValue);
                }
            } catch (Exception e) {
                logger.error("some error has happened when fetch data in loop", e);
            }

        }
    }
</code></pre>

<p>I want to collect all String value in <code>BDto</code> and <code>CDto</code> of aObj?How can I achieve this? Or how can I know the field which I have to recursive traversal with no hard code?</p>