views:

148

answers:

2

I read through the javadoc and couldn't find anything that resembles it.

A: 

I think that you don't have a exact inject method.. but you can obtain a similar solution by using the transformValues methods supplied

Maps.transformValues(Map<K,V1> fromMap, Function<? super V1,V2> function)
List.transform(List<F> fromList, Function<? super F,? extends T> function)

Of course you'll need a Function class defined ad hoc to work with the passed parameter of the inject:

class MyFunction<Type, Type>
{
  static String variable;

  Type apply(Type t)
  {
     //do whatever you want with t
     // and storing intermediate result to variable

     // return same t to make this function work like identity
     return t;
  }

}
Jack
I think you'd be a lot better off just writing your own Reducer interface and static reduce method. It's not too hard and it'd at least make your intent clear rather than being a hack.
ColinD
Tha't undoubtely true but maybe in this way you couple it with a *should be* optimized approach..
Jack
+2  A: 

No, it does not.

While it does have certain functional programming elements (Predicate, Function), those were to support specific needs and its core focus is not adding functional programming elements for Java (seeing as how it's terribly verbose currently). See this issue for a bit on that.

ColinD