code: private static Method sam( Class<?> type )
      {
          if ( !type.isInterface() )
          {
              throw new IllegalArgumentException( "Not an interface: " + type.getName() );
          }
          return Stream.of( type.getMethods() )
                       .filter( m -> !(m.isDefault() || Modifier.isStatic( m.getModifiers() )) )
                       .reduce( ( l, r ) -> {
                           throw new IllegalStateException( "Too many methods." );
                       } ).orElseThrow( () -> new IllegalStateException( "No methods." ) );
      }
docs: Get the only abstract method of a class (such as a function interface).
  
  @param type the class (functional interface) to find the only abstract method of.
  @return the only abstract method of the given class.