title: How do i get a values from fields of a class which implements interface using reflection?
body: <p>I'm reading all fields values from an object and his children:</p>
  
  <pre><code>private List&lt;Object&gt; getAllFieldsValues(Class&lt;?&gt; clazz, String[] filter) throws IllegalArgumentException, IllegalAccessException {
      List&lt;Object&gt; fieldsValues = new ArrayList&lt;&gt;();
      Field[] fields = clazz.getDeclaredFields();
  
      for (Field field : fields) {
  
          // some code
  
          if (field.getType().isInterface()) {
              // get all fields from a class which implements the interface
          }
      }
      return fieldsValues;
  }
  </code></pre>
  
  <p>I need to get all values from class which implements the interface. How?</p>
  
  <p>EDIT:
  My goal is get all fields values to generate some hash:</p>
  
  <pre><code>public class HashGen&lt;T extends Layout&gt; {    
      public String hash(T layout, String[] filter) throws IllegalArgumentException, IllegalAccessException {
          Class&lt;?&gt; current = layout.getClass();
  
          List&lt;Object&gt; fieldValues = new ArrayList&lt;&gt;();
          while (!current.getName().equals("Object")) {
              fieldValues.addAll(getAllFieldsValues(current, filter));
              current = current.getSuperclass();
          }
  
          return generateHashFromValues(fieldValues);
      }
  }
  </code></pre>
  
  <p>Exemple of my class structure:</p>
  
  <pre><code>public interface SomeInterface { }
  
  public class SomeClass implements SomeInterface { 
      private int someField;
  
      // get / set
  }
  
  
  public interface Layout { }
  
  public interface X540 extends Layout { }
  
  public class X540Impl implements X540 { 
      private int id;
      private SomeInterface;
  
      // get / set
  }
  
  
  public static void main(String[] args) {
      X540 x540 = new X540Impl();
      x540.setId(1);
  
      SomeInterface someInterface = new SomeClass();
      someInterface.setSomeField(5454);
  
      x540.setSomeInterface(someInterface);
  
      // i need to generate an hash of all fields values of X540Impl and SomeClass because X540Impl has a SomeClass
      String hash = new HashGen().hash(x540, new String[] {});
  
  }
  </code></pre>