/** * Creates the an entity based on its name. * * @param entityName The name of the entity * @return the entity object * @throws ODataUnmarshallingException If unable to load entity */ public Object loadEntity(String entityName) throws ODataUnmarshallingException { Object entity = null; if (entityName != null) { try { StructuredType entityType = JsonParserUtils.getStructuredType(entityName, entityDataModel); if (entityType != null) { entity = entityType.getJavaType().newInstance(); } else { LOG.warn("Given entity '{}' is not found in entity data model", entityName); throw new ODataUnmarshallingException("Couldn't initiate entity because given entity [" + entityName + "] is not found in entity data model."); } } catch (InstantiationException | IllegalAccessException e) { throw new ODataUnmarshallingException("Cannot instantiate entity", e); } } return entity; }
/** * Creates the an entity based on its name. * * @param entityName The name of the entity * @return the entity object * @throws ODataUnmarshallingException If unable to load entity */ public Object loadEntity(String entityName) throws ODataUnmarshallingException { Object entity = null; if (entityName != null) { try { StructuredType entityType = JsonParserUtils.getStructuredType(entityName, entityDataModel); if (entityType != null) { entity = entityType.getJavaType().newInstance(); } else { LOG.warn("Given entity '{}' is not found in entity data model", entityName); throw new ODataUnmarshallingException("Couldn't initiate entity because given entity [" + entityName + "] is not found in entity data model."); } } catch (InstantiationException | IllegalAccessException e) { throw new ODataUnmarshallingException("Cannot instantiate entity", e); } } return entity; }