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(),method.getParameterTypes());
    }
 catch (    NoSuchMethodException e) {
      return false;
    }
  }
  return true;
}

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 ( ) , method . getParameterTypes ( ) ) ; } catch ( NoSuchMethodException e ) { return false ; } } return true ; }
indicates if object is a ( ducktype ) instance of a type ( interface ) . that is , is every method in type is present on object .
