This way you can propagate the error up the stack
Example:
if(imageTicket == null) {
throw new ImageTicketNotFoundException("Could not find a image ticket for the id provided");
}
if(imageTicket == null) {
throw new ImageTicketNotFoundException("Could not find a image ticket for the id provided");
}
@Override
public boolean equals(Object obj)
{
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
final Location other = (Location) obj;
if (getId() != other.getId()) return false;
return true;
}
use
@Override
public boolean equals(Object obj)
{
if (this == obj) return true;
if (obj == null) return false;
if (! getClass().isAssignableFrom( obj.getClass() ) ) return false;
final Location other = (Location) obj;
if (getId() != other.getId()) return false;
return true;
}
Ref:
http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/Class.html#isAssignableFrom(java.lang.Class)
switch (selectedTab) {
case (Tab.SITES):
//do something for sites
case (Tab.CATEGORY):
//do something for category
case (Tab.DEMOGRAPHIC):
//do something for demographics
case (Tab.ALL_SITES):
//do something for all sites
}
switch (selectedTab) {
case (Tab.SITES):
renderSitesTab();
case (Tab.CATEGORY):
renderCategoryTab();
case (Tab.DEMOGRAPHIC):
renderDemographicsTab();
case (Tab.ALL_SITES):
renderAllSites();
}