1 33 package net.sf.jga.fn.adaptor; 34 35 import net.sf.jga.fn.UnaryFunctor; 36 import net.sf.jga.util.ArrayUtils; 37 38 45 46 public class ApplyUnary<T> extends UnaryFunctor<T,Object []> { 47 48 static final long serialVersionUID = -7934367561074978884L; 49 50 private UnaryFunctor<T,?>[] _functors; 51 52 public ApplyUnary (UnaryFunctor<T,?>... functors){ 53 _functors = functors; 54 } 55 56 public UnaryFunctor<T,?>[] getFunctors() { 57 return _functors; 58 } 59 60 public Object [] fn(T arg) { 61 Object [] result = new Object [_functors.length]; 62 for (int i = 0; i < _functors.length; ++i) { 63 result[i] = _functors[i].fn(arg); 64 } 65 66 return result; 67 } 68 69 73 public void accept(net.sf.jga.fn.Visitor v) { 74 if (v instanceof ApplyUnary.Visitor) 75 ((ApplyUnary.Visitor)v).visit(this); 76 else 77 v.visit(this); 78 } 79 80 82 public String toString() { 83 return ArrayUtils.toString(_functors); 84 } 85 86 88 91 public interface Visitor extends net.sf.jga.fn.Visitor { 92 public void visit(ApplyUnary host); 93 } 94 } 95 | Popular Tags |