package curam.inheritance; import curam.inheritance.DogImpl; import curam.inheritance.struct.AnimalDtls; import curam.test.codetable.ANIMAL_TYPE; import curam.util.persistence.EntityInfo; import curam.util.persistence.helper.SingleTableEntityImpl; public class DogImpl extends AnimalImpl implements Dog { protected DogImpl() { } /** * {@inheritDoc} */ @Override public void setEntityInfo( EntityInfo<Long, SingleTableEntityImpl<AnimalDtls>, AnimalDtls> entityInfo) { super.setEntityInfo(entityInfo); // check that this object has been constructed with an // appropriate row if (getID() != null && !getDtls().animalType.equals(ANIMAL_TYPE.DOG)) { throw new RuntimeException("Expected to be a dog"); } } public String getFavouriteTrick() { return getDtls().favouriteTrick; } public void setFavouriteTrick(final String value) { getDtls().favouriteTrick = value; } public void crossFieldValidation() { // none required } public void crossEntityValidation() { // none required } public void mandatoryFieldValidation() { // none required } public void speak() { System.out.println("Woof! My name is " + getName() + " and I like to " + getFavouriteTrick()); } public void setNewInstanceDefaults() { getDtls().animalType = ANIMAL_TYPE.DOG; } }
The structure of this class is similar to CatImpl above.