1 Reply Latest reply on Nov 24, 2008 4:27 PM by alesj

    Adding handy isInstance(Object) method to TypeInfo

    alesj

      I'm thinking about adding convenient isInstance method to TypeInfo.
      On ClassInfoImpl/JavassistTypeInfo it would use getType::isInstance,
      but on PrimitiveInfo it would still look into progression.

      The method would hide simple impl detail.

      TypeInfo ti = ...;
      Object value = ...; // not null
      
      //long version
      TypeInfoFactory tif = ti.getTypeInfoFactory();
      TypeInfo other = tif.getTypeInfo(value.getClass());
      boolean isInstance = ti.isAssignableFrom(other);
      
      // short
      boolean isInstance = ti.isInstance(value);
      
      // where this doesn't consider progression
      boolean isInstance = ti.getType().isInstance(value);
      


      OK?