title: how to remove following generic
body: <pre><code>@Autowired
  SessionFactory sessionFactory;
  
  public SPLoginUser loginUser(final LoginBean loginBean) {
      final Map&lt;String, Object&gt; inParamMap = new HashMap&lt;String, Object&gt;();
      inParamMap.put(DAOConstants.EMAIL, loginBean.getEmail());
      inParamMap.put(DAOConstants.PASSWORD, loginBean.getPassword());
      @SuppressWarnings("unchecked")
      final List&lt;SPLoginUser&gt; list = sessionFactory
              .getCurrentSession()
              .getNamedQuery(
                      DAOConstants.SQL_FUNCTIONS.NAMED_NATIVE_QUERY.LOGIN_USER)
              .setProperties(inParamMap).list();
  
      if (list != null &amp;&amp; list.size() == 1) {
          if (list.get(0).getErrorCode() == 200) {
              return list.get(0);
          } else {
              throw new UserNotFoundException(list.get(0).getErrorMessage());
          }
      } else {
          throw new UserNotFoundException();
      }
  }
  </code></pre>
  
  <p>in the above mentioned code of my spring controller i want to remove:</p>
  
  <pre><code>    if (list != null &amp;&amp; list.size() == 1) {
          if (list.get(0).getErrorCode() == 200) {
              return list.get(0);
          } else {
              throw new UserNotFoundException(list.get(0).getErrorMessage());
          }
      } else {
          throw new UserNotFoundException();
      }
  enter code here
  </code></pre>
  
  <p>and wants this to be generic and in 1 or 2 lines.</p>
  
  <p>please help me out. this is throughout my spring mvc 4 application.</p>