// Path: ghostwriter-jdk-v7/src/main/java/io/ghostwriter/openjdk/v7/common/Logger.java
// public enum Logger {
//     ;
// 
//     private static Messager messager;
// 
//     private static boolean doVerboseLogging = false;
// 
//     private static String format(Class<?> klass, String method, String message) {
//         final int INITIAL_CAPACITY = 32;
//         StringBuilder sb = new StringBuilder(INITIAL_CAPACITY);
//         if (klass != null) {
//             sb.append(klass.getName());
//             sb.append(".");
//         }
//         sb.append(method);
//         sb.append(": ");
//         sb.append(message);
// 
//         return sb.toString();
//     }
// 
//     public static void note(Class<?> type, String method, String message) {
//         if (!doVerboseLogging) {
//             return;
//         }
// 
//         validateState();
//         String output = format(type, method, message);
//         messager.printMessage(Diagnostic.Kind.NOTE, output);
//     }
// 
//     public static void warning(Class<?> type, String method, String message) {
//         validateState();
//         String output = format(type, method, message);
//         messager.printMessage(Diagnostic.Kind.MANDATORY_WARNING, output);
//     }
// 
//     /**
//      * Display an error message.
//      *
//      * @param type    - class that produced the error
//      * @param method  - method that produced the error
//      * @param message - error description
//      */
//     public static void error(Class<?> type, String method, String message) {
//         validateState();
//         String output = format(type, method, message);
//         messager.printMessage(Diagnostic.Kind.ERROR, output);
//     }
// 
//     public static void initialize(Messager msg, boolean verbose) {
//         if (msg == null) {
//             throw new IllegalArgumentException("Cannot initialize with null!");
//         }
//         messager = msg;
//         doVerboseLogging = verbose;
//     }
// 
//     private static void validateState() {
//         if (messager == null) {
//             throw new IllegalStateException("Logger has not been initialized!");
//         }
//     }
// 
// }


import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.TreeTranslator;
import io.ghostwriter.openjdk.v7.common.Logger;
import java.util.*;
package io.ghostwriter.openjdk.v7.ast.collector;



public class Collector<T> extends TreeTranslator implements Iterable<T> {

    final private List<T> items = new ArrayList<>();

    final private JCTree rootElement;
    
    // the Collector is lazy because of initialization requirements
    private boolean hasExecuted = false;
    
    public Collector(JCTree rootElement) {
        super();
        this.rootElement = Objects.requireNonNull(rootElement);
    }
    
    protected Collector<T> execute() {
        rootElement.accept(this);
        return this;
    }

    protected void collect(T item) {
        if (item == null) {
// Path: ghostwriter-jdk-v7/src/main/java/io/ghostwriter/openjdk/v7/common/Logger.java
// public enum Logger {
//     ;
// 
//     private static Messager messager;
// 
//     private static boolean doVerboseLogging = false;
// 
//     private static String format(Class<?> klass, String method, String message) {
//         final int INITIAL_CAPACITY = 32;
//         StringBuilder sb = new StringBuilder(INITIAL_CAPACITY);
//         if (klass != null) {
//             sb.append(klass.getName());
//             sb.append(".");
//         }
//         sb.append(method);
//         sb.append(": ");
//         sb.append(message);
// 
//         return sb.toString();
//     }
// 
//     public static void note(Class<?> type, String method, String message) {
//         if (!doVerboseLogging) {
//             return;
//         }
// 
//         validateState();
//         String output = format(type, method, message);
//         messager.printMessage(Diagnostic.Kind.NOTE, output);
//     }
// 
//     public static void warning(Class<?> type, String method, String message) {
//         validateState();
//         String output = format(type, method, message);
//         messager.printMessage(Diagnostic.Kind.MANDATORY_WARNING, output);
//     }
// 
//     /**
//      * Display an error message.
//      *
//      * @param type    - class that produced the error
//      * @param method  - method that produced the error
//      * @param message - error description
//      */
//     public static void error(Class<?> type, String method, String message) {
//         validateState();
//         String output = format(type, method, message);
//         messager.printMessage(Diagnostic.Kind.ERROR, output);
//     }
// 
//     public static void initialize(Messager msg, boolean verbose) {
//         if (msg == null) {
//             throw new IllegalArgumentException("Cannot initialize with null!");
//         }
//         messager = msg;
//         doVerboseLogging = verbose;
//     }
// 
//     private static void validateState() {
//         if (messager == null) {
//             throw new IllegalStateException("Logger has not been initialized!");
//         }
//     }
// 
// }


// Path: ghostwriter-jdk-v7/src/main/java/io/ghostwriter/openjdk/v7/ast/collector/Collector.java
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.TreeTranslator;
import io.ghostwriter.openjdk.v7.common.Logger;
import java.util.*;

package io.ghostwriter.openjdk.v7.ast.collector;



public class Collector<T> extends TreeTranslator implements Iterable<T> {

    final private List<T> items = new ArrayList<>();

    final private JCTree rootElement;
    
    // the Collector is lazy because of initialization requirements
    private boolean hasExecuted = false;
    
    public Collector(JCTree rootElement) {
        super();
        this.rootElement = Objects.requireNonNull(rootElement);
    }
    
    protected Collector<T> execute() {
        rootElement.accept(this);
        return this;
    }

    protected void collect(T item) {
        if (item == null) {
            Logger.warning(getClass(), "collect", "tried to collect null item! Skipping!");