4 Replies Latest reply: Aug 5, 2010 7:19 PM by EJP RSS

    Enforcing subclass type

    843793
      I have the following structure

      public interface IMy {...}
      public interface IMyRepository {
      public void addMy (IMy my);
      }

      public class My implements IMy {
      }

      public class SpecialMy extends My {
      }

      public class SpecialMyRepository implements IMyRepository {
      => public void addMy (...) {
      }

      Is there any way to enforce using generics that SpecialMyRepository always accepts SpecialMy object types and not My or any other IMy types?

      Thanks,