title: How to convert these 2 methods into generic methods?
body: <p>Hello i have the follow two methods</p>
  
  <p>first</p>
  
  <pre><code>public ObjectId getObjectIdByRegionName(Region region) {        
          Query&lt;Region&gt; query = datastore.createQuery(Region.class);
          query.field("R_NAME").equal(region.getName());
          return query.get().getId();
      }
  </code></pre>
  
  <p>second</p>
  
  <pre><code>public ObjectId getObjectIdByNationName(Nation nation) {
          Query&lt;Nation&gt; query = datastore.createQuery(Nation.class);
          query.field("N_NAME").equal(nation.getName());
          return query.get().getId();
      }
  </code></pre>
  
  <p>how could i turn them into generic method?</p>