Exemple #1
0
 public static <From, To> To fold(
     IEntityDefn primary,
     To initial,
     IEntityDefnFoldVisitor<From, To> visitor,
     IFoldFunction<From, To> foldFunction) {
   To accumulator = foldFunction.apply(visitor.acceptPrimary(primary), initial);
   return visitChildren(primary, accumulator, visitor, foldFunction);
 }
Exemple #2
0
 private static <To, From> To visitChildren(
     IEntityDefn parent,
     To initial,
     IEntityDefnFoldVisitor<From, To> visitor,
     IFoldFunction<From, To> foldFunction) {
   To accumulator = initial;
   for (IEntityDefn child : parent.getChildren()) {
     accumulator = foldFunction.apply(visitor.acceptChild(parent, child), accumulator);
     accumulator = visitChildren(parent, accumulator, visitor, foldFunction);
   }
   return accumulator;
 }