More Readable Use Site extension Methods for java

Ali Ebrahimi ali.ebrahimi1781 at
Sun Dec 5 22:51:28 PST 2010

I propose to have use site and declaration site extension methods.

declaration site extension methods by Brian Defender Methods and use
site extension methods as following:

import static extends java.util.List;
import static MyUtils.sortby extends java.util.List;

List<Foo> myList=getList();

List newList{f -> f.isReal()}).sortby(F#getName());

class MyUtils{
      public <T> static List<T> select(List<T> list, Predicate<T> p);
      public <T> static List<T> sortby(List<T> list, Sorter<T> p);

interface Sorter<T>{
     Comparable<?> apply(T t);

This an enhanced version of previously proposed use site extension methods.

import statement can be in package level ( ) and even in
module level ( ).

this is for those prefer use site extension methods.

This is just an suggestion. I fully support current defender methods. In
current method, API consumers don't have control over them unless subclass
I suggest java to support both use site and declaration site extension

Best Regards

Ali Ebrahimi

More information about the lambda-dev mailing list