Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > jFluent - a new library that provides a fluent interface over Javacore packages

Reply
Thread Tools

jFluent - a new library that provides a fluent interface over Javacore packages

 
 
shinya
Guest
Posts: n/a
 
      04-20-2008
Hi folks!
I wrote a little library, just as an exercise to grasp techniques
around DSLs and fluent interfaces, that provides a fluent layer upon
java.util.List and java.lang.String(and StringBuilder).

The project can be reached here: http://code.google.com/p/jfluent/
Here's an example of what you can do with the library, in pure Java:

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<String, String>() {
public String apply(String element) {
return element + " ";
}
})
.get())
.append("\n")
.append(
list(range('A', 'Z'))
.reverse()
.filter(new Predicate<Character>() {
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,N


I don't know if it's a dream or a nightmare for you but i'd like to
hear any kind of opinions, critics, possible improvements, etc...
The library is in ALPHA stage, it lacks lots of documentation, but
your IDE should be enough since intellisense should guide you through.
Most methods are just wrapped on the java's ones.

Thanks for listening!
 
Reply With Quote
 
 
 
 
Stefan Ram
Guest
Posts: n/a
 
      04-21-2008
shinya <(E-Mail Removed)> writes:
>around DSLs and fluent interfaces, that provides a fluent layer upon


See also

http://stephan.reposita.org/archives...e-collections/

When I first heard of »fluent interface«, I misunderstood the
meaning of the term somewhat: I thought, it was about trying
to make an expression or statement of a programming language
to be a legible English language phrase or sentence, too.

For example, IIRC Sun Microsystems, Inc. uses code like:

value.add( other );

while with my own big number class, I use:

value.plus( other );

which to me sounds more like a legible English phrase.

http://google.to/search?q=%22one+*+one+makes+two%22

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in running a basic code in python 3.3.0 that includes HTML file Satabdi Mukherjee Python 1 04-04-2013 07:48 PM
Creating a "fluent" interface Rahul Kumar Ruby 0 10-02-2010 02:09 PM
Help, how to analyze javacore and heap dump ken Java 0 05-05-2009 03:12 AM
IBM JVM javacore and heapdump analyzers? C B Java 0 04-13-2004 09:37 PM



Advertisments