code: public static String getEntityName(EntityDataModel entityDataModel, Object entity) throws ODataEdmException {
  
          // Get the entity type
          EntityType entityType = getAndCheckEntityType(entityDataModel, entity.getClass());
  
          // Check if the entity belongs to an Entity Set
          String entityName = null;
  
          for (EntitySet entitySet : entityDataModel.getEntityContainer().getEntitySets()) {
              if (entitySet.getTypeName().equals(entityType.getFullyQualifiedName())) {
                  entityName = entitySet.getName();
                  break;
              }
          }
  
          if (entityName == null) {
              for (Singleton singleton : entityDataModel.getEntityContainer().getSingletons()) {
                  if (singleton.getTypeName().equals(entityType.getFullyQualifiedName())) {
                      entityName = singleton.getName();
                      break;
                  }
              }
  
              if (entityName == null) {
                  throw new ODataSystemException("Entity not found in the entity data model for type: "
                          + entityType.getFullyQualifiedName());
              }
          }
          return entityName;
      }
docs: Get the entity name in the entity data model for the given entity.
  
  @param entityDataModel The Entity Data Model.
  @param entity          The given entity.
  @return Entity name which can be either EntitySet name or a Singleton Name
  @throws ODataEdmException If unable to get entity name from entity data model