Mittwoch, 21. April 2010

My first op4j code

I play around with op4j makes a lot of fun. Here my first op4j code:
// Create a array with out null and 0 values
Integer[] integers = Op.onArrayFor(1, 2, 3, null, 4, null, 0).removeAllNull().removeAllEqual(0).get();
// Assert
for (Integer value : integers) {
   assertNotSame(0, value);



  1. Fluent APIs are cool, but as long Java lacks closures this is not as cool as in e.g. JS.

  2. Thats right but the problem with JS and Fluent APIs is that the most IDEs don't have a very good JS support for content assist / auto completion. Means I must know all the operations in the API... And for a API like op4j thats very hard... At least one question is there a goog JS fluent API out there?

  3. JS is just the nearest language i know that actually has closures. But i think JQuery provides at least to some extend a fluent api. (See Tobse's talk)