summary of point lambdafication survey
Stuart Marks
stuart.marks at oracle.com
Fri Sep 23 11:11:16 PDT 2011
Brian has asked me to summarize the results of the point lambdafication survey
he sent out a few weeks ago:
http://mail.openjdk.java.net/pipermail/lambda-dev/2011-August/003919.html
There were 27 responses. Several responses were from the same individual, and
some respondents didn't provide a name (and in at least one case a response was
intended to supersede an earlier response) so it's hard to tell how many people
responded. Perhaps there were twenty different individuals. Thanks to all who
contributed.
Below is a brief summary of the responses. For the sake of brevity, I've taken
some liberties in this summary; some of you typed a lot of code! My opinions
and comments on the results will follow in a separate message.
* java.util.logging.Logger -- log(level, Callable<String>) -- 3 requests
- pass a function that generates a log message
- avoids overhead of string creation if level isn't enabled
- variations for finest(), info(), etc.
- need to deal with Exception thrown from Callable.call()
* BufferedReader.eachLine(block) -- 3 requests
- run a block on each line read
- variations with filtering
* java.util.concurrent.locks.Lock -- withLock(block) -- 2 requests
- runs block with lock held, release lock in finally-clause
- variations for lock with timeout, tryLock
* java.util.regex -- each() on Pattern, Matcher, or String -- 2 requests
- run a block on each match, possibly returning a replacement
* java.sql.ResultSet -- each(block) -- 2 requests
- run a block for each row in a ResultSet
* java.nio.Buffer family -- forEach(block)
- runs block on each buffer element
* Swing/AWT event listeners -- multiple requests
- rearrange non-SAM listeners to be suitable for lambdas
* SwingUtilities executeAndWait(callable), invokeAndWait(callable)
- convenience functions for current APIs, possibly also returning a value
* SwingWorker(callable)
- convenience method for creating a SwingWorker
- callable supplies implementation of doInBackground()
* java.nio.channels.FileChannel -- lockDuring(block)
- runs block with file lock held, release lock in finally-clause
- variation for tryLock
* java.nio.file.Files -- eachFile(block)
- run block for each file in a directory
* Collections.toMap(keyGen)
- for each element in a Collection, generate a key, store into a Map
- could be a static utility method or an extension method
* Process.onExit(block)
- execute block when the process exits
* Integer.times(block) -- execute block N times
* Objects.equals(obj1, obj2, fieldGetters...)
- helper method for writing equals() methods
- handles identity, casting, field-by-field comparisons
* Throwable.visitCauses(block)
- run block for each throwable in the chain of causes
* ThreadLocal(callable)
- callable supplies the implementation of initialValue()
- provides lazy initialization of thread-locals
s'marks
More information about the lambda-dev
mailing list