title: Using generic interfaces and classes
body: <pre><code>java version "1.8.0_92"
  </code></pre>
  
  <p>I am trying to make a generic interface and a class that implements it. This is the interface:</p>
  
  <pre><code>interface UpdateDBListener&lt;T&gt; {
      void onUpdateSuccess(T person);
      void onUpdateFailure(String errMessage);
  }
  void updatePerson(T person, UpdateDBListener updateDBListener);
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>error: cannot find symbol method getId() where T is a type-variable: T extends Object declared in class PeopleListModelImp 
  </code></pre>
  
  <p>And this is the class that implements it:</p>
  
  <pre><code>public class PeopleListModelImp&lt;T&gt; implements PeopleListModelContract&lt;T&gt; {
  
  @Override
  public void updatePerson(T person, UpdateDBListener updateListener) {
      String id = person.getId(); /* ERROR */
  }
  </code></pre>
  
  <p>The class I am using to pass in in this:</p>
  
  <pre><code>public class Person {
      String mId;
      String mFirstName;
      String mLastName;
  
      public Person() {
      }
  
      public String getId() {
          return mId;
      }
  
      public void setId(String id) {
          this.mId = id;
      }
  
      public String getFirstName() {
          return mFirstName;
      }
  
      public void setFirstName(String firstName) {
          this.mFirstName = firstName;
      }
  
      public String getLastName() {
          return mLastName;
      }
  
      public void setLastName(String lastName) {
          this.mLastName = lastName;
      }
  }
  </code></pre>
  
  <p>However, if I try to get the Id in the class that implements the interface I get an error on this line:</p>
  
  <pre><code>String id = person.getId();
  </code></pre>
  
  <p>I think as person don't know its a Person class, so doesn't understand the getId(). I am just wondering I am doing this an incorrect way. I want the class to be completely generic so I can using it for other different classes.</p>
  
  <p>Is this possible?</p>
  
  <p>Many thanks in advance.</p>