code: private Object instantiateEntity(Class entityClass, Object entity)
      {
          try
          {
              if (entity == null)
              {
                  return entityClass.newInstance();
              }
              return entity;
          }
          catch (InstantiationException e)
          {
              log.error("Error while instantiating " + entityClass + ", Caused by: ", e);
          }
          catch (IllegalAccessException e)
          {
              log.error("Error while instantiating " + entityClass + ", Caused by: ", e);
          }
          return null;
      }
docs: Instantiate entity.
  
  @param entityClass
  the entity class
  @param entity
  the entity
  @return the object