Entity interface inheritance

Let's take a simple example: You require to store information about Cats and Dogs. You identify that Cats and Dogs have a number of behaviors in common, and so you identify a common Animal interface.

You need to code three interfaces, Cat, Dog and Animal with the Cat and Dog interfaces both extending the Animal interface.

Figure 1. The Animal Interface
package curam.inheritance;

import curam.util.persistence.Insertable;
import curam.util.persistence.OptimisticLockModifiable;
import curam.util.persistence.StandardEntity;
import curam.util.persistence.helper.Named;

public interface Animal extends StandardEntity, Insertable,
    OptimisticLockModifiable, Named {

  public void speak();

}
Figure 2. The Cat Interface
package curam.inheritance;

public interface Cat extends Animal {

  public int getNumberOfLivesRemaining();

  public void setNumberOfLivesRemaining(final int value);

}
Figure 3. The Dog Interface
package curam.inheritance;

public interface Dog extends Animal {
  public String getFavouriteTrick();

  public void setFavouriteTrick(final String value);

}