1 Reply Latest reply on May 22, 2009 8:03 AM by Elias Ross

    Use of generics in org.jboss.seam.Component

    Elias Ross Master

      Why do these methods in Component return Object, not a type?


         public static Object getInstance(Class<?> clazz)
         {
            return getInstance(clazz, true);
         }
      
         public static Object getInstance(Class<?> clazz, boolean create)
         {
            return getInstance( getComponentName(clazz), create );
         }
      
         public static Object getInstance(Class<?> clazz, ScopeType scope)
         {
            return getInstance(clazz, scope, true);
         }
      
         public static Object getInstance(Class<?> clazz, ScopeType scope, boolean create)
         {
            return getInstance( getComponentName(clazz), scope, create );
         }
      
      



      Ordinarily, you would do:


         public static <T> T getInstance(Class<T> clazz)
         {
            return (T)getInstance(clazz, true);
         }
      
      



      Would help catch bugs I think.