1 33 package net.sf.jga.fn.adaptor; 34 35 import net.sf.jga.fn.Generator; 36 37 42 43 public class AndGenerator extends Generator<Boolean > { 44 45 static final long serialVersionUID = 6260506966868219143L; 46 47 private Generator<Boolean > _first; 49 private Generator<Boolean > _second; 50 51 55 public AndGenerator(Generator<Boolean > first, Generator<Boolean > second) { 56 if (first == null || second == null) { 57 throw new IllegalArgumentException ("Two functors are required"); 58 } 59 60 _first = first; 61 _second = second; 62 } 63 64 65 public Generator<Boolean > getFirstFunctor() { return _first; } 66 67 public Generator<Boolean > getSecondFunctor() { return _second; } 68 69 70 public Boolean gen() { 71 return _first.gen() && _second.gen(); 72 } 73 74 78 public void accept(net.sf.jga.fn.Visitor v) { 79 if (v instanceof AndGenerator.Visitor) 80 ((AndGenerator.Visitor)v).visit(this); 81 else 82 v.visit(this); 83 } 84 85 87 public String toString() { 88 return _first +" && " +_second; 89 } 90 91 93 96 public interface Visitor extends net.sf.jga.fn.Visitor { 97 public void visit(AndGenerator host); 98 } 99 } 100 | Popular Tags |