* @throws ZendeskApiException
*/
public <T extends Object> List<T> getEntitiesFromSearch(Class<T> objectClass) throws ZendeskApiException {
String nameOfClass = objectClass.getName().replaceFirst(".*\\.", "").toLowerCase();
if (!VALID_SEARCH_CLASSES.contains(nameOfClass)) {
throw new ZendeskApiException("Class " + objectClass.getName() + " is not supported by the search API");
}
List<T> entities = new ArrayList<T>();
for (Object result : results) {
@SuppressWarnings("unchecked")
Map<String, String> map = (Map<String, String>) result;
if (map.get("result_type").contentEquals(nameOfClass)) {
Map<String, String> resultMap = new HashMap<String, String>();
resultMap.putAll(map);
resultMap.remove("result_type");
try {
String json = JsonHelper.getJsonString(resultMap);
entities.add(JsonHelper.unmarshal(json, objectClass));
} catch (Exception e) {
throw new ZendeskApiException(e);
}
}
}
if (entities.size() > 0) {