GroovyCacheMap February 17, 2008 | 05:45 pm

Since it was easy enough to do, I just created a GroovyCacheMap, which takes a Groovy Closure (see info at “Closures“).

Someone with a Groovy background wanna make sure that it’s sufficiently groovy-esque for users, and start fishing for those really horrible surprises?

I should really be working on the pipelines. But there’s a lot of annoyance there, and I miss being productive.

Tags: , ,

  • http://hamletdarcy.blogspot.com Hamlet D’Arcy

    You can just as easily use the “as” keyword when passing the original CacheMap a groovy closure to make a groovy closure convert into a one-method interface (in this case a Transformer). This runs fine if you classpath is set up correctly… check it out:

    import jconch.cache.CacheMap;
    import org.apache.commons.collections.Transformer;
    import org.apache.commons.lang.StringUtils;

    def transformer = { stringToValidate ->
        if (stringToValidate == null) return false;

        return ((!StringUtils.isBlank(stringToValidate.toString())) &&
            (!StringUtils.isAlpha(stringToValidate.toString())));
    }

    CacheMap validationCache = new CacheMap(transformer as Transformer);

    assert false == validationCache.get(null);
    assert false == validationCache.get(“”);
    assert false == validationCache.get(“A”);
    assert true == validationCache.get(“2″);
    assert true == validationCache.get(2);
    assert true == validationCache.get(“A2A”);
    assert true == validationCache.get(“2A2″);
    assert true == validationCache.get(new StringBuffer(“2A2″));
    println “Success!”

  • http://www.linkedin.com/in/robertfischer Robert Fischer

    Wow. Seriously.

  • http://www.linkedin.com/in/robertfischer Robert Fischer

    Pipelines in Groovy are going to be crazy simple. :)