4 Replies Latest reply on Aug 6, 2010 12:19 AM by EJP

    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,