jFluent is a little and simple library that provides a fluent layer over the java.util, java.lang and JDBC packages.
The library is in ALPHA stage, so if you want the very last version just check out the sources from the repository.
Now you can operate on lists and strings like that:
import static com.jfluent.builders.BuilderFacade.*;
import com.jfluent.base.*;
public class FluentSimpleTest {
public static void main(String[] args) {
string("o hai!")
.append(" ")
.append(
list("i", "can", "has", "cheezburger", "plz", "?")
.map(new Function() {
public String apply(String element) {
return element + " ";
}
})
.get())
.append("\n")
.append(
list(range('A', 'Z'))
.reverse()
.filter(new Predicate() {
public boolean apply(Character c) {
return c > 'M';
}
})
.join(","))
.println(System.out);
}
}Output:
o hai! i can has cheezburger plz ?
Z,Y,X,W,V,U,T,S,R,Q,P,O,NAlso, a fluent approach over jdbc is possible:
import static com.jfluent.builders.BuilderFacade.*;
import com.jfluent.db.base.Handle;
import java.util.List;
public final class DBFluentTest {
public static void main(String[] args) throws Exception {
Handle empList = param();
withConnection(JDBC_URI_HERE)
.username("scott")
.password("tiger")
.loadOracleDriver()
.doThis(
procedure("package1.open_cur_emp") // call this procedure
.outRS(empList, EmpBean.class) // put the resultset into a list of beans
.in(nullObj(Integer.class))); // passing a null integer as input
for (Object o : empList.value()) {
EmpBean e = (EmpBean)o;
// do something with your list of entity beans
}
}
}For more info on fluent interfaces and DSLs, the work in progress book by Martin Fowler is a good starting point. It can be found here: http://martinfowler.com/dslwip/
I'd like to hear opinions and suggestions for improvements! Contact me at martinelli.diego at gmail.com
Ohloh computes statistics on FOSS projects by examining source code and commit history in source code management systems. This project has no code locations, and so Ohloh cannot perform this analysis
Is this project's source code hosted in a publicly available repository? Do you know the URL? If you do, click the button below and tell us so that Ohloh can generate statistics! It's fast and easy - try it and see!
Copyright
©
2013
Black Duck Software, Inc.
and its contributors, Some Rights Reserved. Unless otherwise marked, this work is licensed under a
Creative Commons Attribution 3.0 Unported License
. Ohloh
®
and the Ohloh logo are trademarks of
Black Duck Software, Inc.
in the United States and/or other jurisdictions. All other trademarks are the property of their respective holders.