code: public static boolean instanceOf(Class type, Object object)
      {
          if (type.isInstance(object)) return true;
  
          Class<?> candidate = object.getClass();
          for (Method method : type.getMethods())
          {
              try
              {
                  candidate.getMethod(method.getName(), (Class[])method.getParameterTypes());
              }
              catch (NoSuchMethodException e)
              {
                  return false;
              }
          }
          return true;
      }
docs: Indicates if object is a (DuckType) instance of a type (interface).  That is,
  is every method in type is present on object.
  
  @param type   The interface to implement
  @param object The object to test
  @return true if every method in type is present on object, false otherwise