/*
 * Copyright (c) 2009 JSCAPE
 * 1147 S. 53rd Pl., Mesa, Arizona, 85206, U.S.A.
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * JSCAPE. ("Confidential Information").  You shall not disclose such
 * Confidential Information and shall use it only in accordance with
 * the terms of the license agreement you entered into with JSCAPE.
 *
 */

package com.jscape.util.functor;

import java.io.Serializable;

/**
 * @author Alex Usun
 */
public abstract class Procedure
        implements Serializable {

    /** */
    public abstract void evaluate();

    /**
     * @param next next
     *
     * @return Procedure instance
     */
    public Procedure then(Procedure next) {
        return new Chain(this, next);
    }

    /** */
    public static class Chain
            extends Procedure {

        private Procedure first;
        private Procedure second;

        /**
         * @param first  first
         * @param second second
         */
        private Chain(Procedure first, Procedure second) {
            this.first = first;
            this.second = second;
        }

        /** */
        public void evaluate() {
            this.first.evaluate();
            this.second.evaluate();
        }

    }

}