title: How to pass a variable from 2 different POJOs?
body: <p>I got 2 POJOs that are being passed to a HttpEntity and converted to json.</p>
  
  <p>Before passing them i need a variable which is in both of the POJOs with different names because of the needs of the API so i cant change them.</p>
  
  <p>What is the best way without casting and in terms of OOP also within the POJO definition like mentioned in <a href="https://en.wikipedia.org/wiki/Plain_Old_Java_Object" rel="nofollow">Wikipedia</a>? </p>
  
  <p>Abstract pojo</p>
  
  <pre><code>public abstract class Pojo{
  
  //some common variables
  //setter getters
  
  }
  </code></pre>
  
  <p>PojoOne</p>
  
  <pre><code>public class PojoOne extends Pojo{
  
  private String id;
  
  //setter getter for id
  
  }
  </code></pre>
  
  <p>PojoTwo</p>
  
  <pre><code>public class PojoTwo extends Pojo{
  
  private String identifier;
  
  // setter getter for identifier
  }
  </code></pre>
  
  <p>Class that </p>
  
  <pre><code>public class SomeOtherClass {
  
  public void getIdForUse(Pojo pojo){
  
  String s = pojo. // How should this be to have ability to get both id and identifier
  
  }
  </code></pre>
  
  <p>}</p>