I have my Java method as below;
public List<Lookup> findAll(String lang) {
Query query = entityManager.createNamedQuery("Lookup.findAll");
if (isValidLang(lang)) {
query.setParameter("lang", lang);
return query.getResultList();
} else {
//return empty list
}
}
Now the method returns List for valid matches of lang.
But if that is not the case, I want to return an empty list. My question is how do I update the code & what is the best way to return an empty list so that the code does not fail ?