// Path: graph/Iteration.java
// public abstract class Iteration<Type>
//     implements Iterator<Type>, Iterable<Type> {
// 
//     @Override
//     public Iterator<Type> iterator() {
//         return this;
//     }
// 
//     @Override
//     public void remove() {
//         throw new UnsupportedOperationException("remove not supported");
//     }
// 
//     /** A wrapper class that turns an Iterator<TYPE> into an Iteration<TYPE>. */
//     private static class SimpleIteration<Type> extends Iteration<Type> {
//         /** ITER as an iteration. */
//         SimpleIteration(Iterator<Type> iter) {
//             _iter = iter;
//         }
// 
//         @Override
//         public boolean hasNext() {
//             return _iter.hasNext();
//         }
// 
//         @Override
//         public Type next() {
//             return _iter.next();
//         }
// 
//         /** The iterator with which I was constructed. */
//         private Iterator<Type> _iter;
//     }
// 
//     /** Returns an Iteration<TYPE> that delegates to IT. */
//     static <Type> Iteration<Type> iteration(Iterator<Type> it) {
//         return new SimpleIteration<>(it);
//     }
// 
//     /** Returns an Iteration<TYPE> that delegates to ITERABLE. */
//     static <Type> Iteration<Type> iteration(Iterable<Type> iterable) {
//         return new SimpleIteration<>(iterable.iterator());
//     }
// 
// }
// 
// Path: make/Main.java
// static void error(String format, Object... args) {
//     throw new IllegalArgumentException(String.format(format, args));
// }


import java.util.ArrayList;
import java.util.List;
import graph.Iteration;
import static make.Main.error;
package make;




/** Represents the rules concerning a single target in a makefile.
 *  @author P. N. Hilfinger
 */
class Rule {
    /** A new Rule for TARGET. Adds corresponding vertex to MAKER's dependence
     *  graph. */
    Rule(Maker maker, String target) {
        _maker = maker;
        _depends = _maker.getGraph();
        _target = target;
        _vertex = _depends.add(this);
        _time = _maker.getInitialAge(target);
        _finished = false;
    }

    /** Add the target of DEPENDENT to my dependencies. */
    void addDependency(Rule dependent) {
        _depends.add(dependent);
        _depends.add(getVertex(), dependent.getVertex());
    }

    /** Add COMMANDS to my command set.  Signals IllegalStateException if
     *  COMMANDS is non-empty, but I already have a non-empty command set.
     */
    void addCommands(List<String> commands) {
        try {
            if (_commands.size() != 0) {
                if (commands.size() != 0) {
                    error("Input and commands are not empty.");
                }
            }
        } catch (IllegalStateException exp) {
// Path: graph/Iteration.java
// public abstract class Iteration<Type>
//     implements Iterator<Type>, Iterable<Type> {
// 
//     @Override
//     public Iterator<Type> iterator() {
//         return this;
//     }
// 
//     @Override
//     public void remove() {
//         throw new UnsupportedOperationException("remove not supported");
//     }
// 
//     /** A wrapper class that turns an Iterator<TYPE> into an Iteration<TYPE>. */
//     private static class SimpleIteration<Type> extends Iteration<Type> {
//         /** ITER as an iteration. */
//         SimpleIteration(Iterator<Type> iter) {
//             _iter = iter;
//         }
// 
//         @Override
//         public boolean hasNext() {
//             return _iter.hasNext();
//         }
// 
//         @Override
//         public Type next() {
//             return _iter.next();
//         }
// 
//         /** The iterator with which I was constructed. */
//         private Iterator<Type> _iter;
//     }
// 
//     /** Returns an Iteration<TYPE> that delegates to IT. */
//     static <Type> Iteration<Type> iteration(Iterator<Type> it) {
//         return new SimpleIteration<>(it);
//     }
// 
//     /** Returns an Iteration<TYPE> that delegates to ITERABLE. */
//     static <Type> Iteration<Type> iteration(Iterable<Type> iterable) {
//         return new SimpleIteration<>(iterable.iterator());
//     }
// 
// }
// 
// Path: make/Main.java
// static void error(String format, Object... args) {
//     throw new IllegalArgumentException(String.format(format, args));
// }


// Path: make/Rule.java
import java.util.ArrayList;
import java.util.List;
import graph.Iteration;
import static make.Main.error;

package make;




/** Represents the rules concerning a single target in a makefile.
 *  @author P. N. Hilfinger
 */
class Rule {
    /** A new Rule for TARGET. Adds corresponding vertex to MAKER's dependence
     *  graph. */
    Rule(Maker maker, String target) {
        _maker = maker;
        _depends = _maker.getGraph();
        _target = target;
        _vertex = _depends.add(this);
        _time = _maker.getInitialAge(target);
        _finished = false;
    }

    /** Add the target of DEPENDENT to my dependencies. */
    void addDependency(Rule dependent) {
        _depends.add(dependent);
        _depends.add(getVertex(), dependent.getVertex());
    }

    /** Add COMMANDS to my command set.  Signals IllegalStateException if
     *  COMMANDS is non-empty, but I already have a non-empty command set.
     */
    void addCommands(List<String> commands) {
        try {
            if (_commands.size() != 0) {
                if (commands.size() != 0) {
                    error("Input and commands are not empty.");
                }
            }
        } catch (IllegalStateException exp) {
            error("Not legal.");