If you vote you can be DZone's BFF! Login and vote now.
By jsugrue
via java.dzone.com
Submitted: May 01 2008 / 09:10
I want to share with you a little gadget that uses google-collections. Basically, a rule is a condition and an action.
So I will use Predicate as a condition and Function as an action. The composite function then consists of list of rules, for the first predicate that evaluates to true, it will invoke the corresponding function. If none of the predicates are matched - default function will be invoked.
Comments
ilazarte replied ago:
Very cool! I remember thinking up a rules concept a while ago, but being somewhat disappointed that commons collections didn't support generics to make it typesafe. I'm all about the compile-type safety as well; definitely feature more type safe examples like Ricky pointed out!
Voters For This Link (3)
Voters Against This Link (3)