Subversion Repositories DevTools

Rev

Rev 7133 | Blame | Compare with Previous | Last modification | View Log | RSS feed

package com.erggroup.buildtool.ripple;

import java.util.Comparator;


/** Class to contain package build information
 *  Information not stored in the package as its dynamic
 */
class PlannedPackage {
    /**
     * The build level assigned to the package in the collection
     */
    int mBuildLevel = 0;
    
    /**
     * The package
     */
    Package mPkg = null;
    
    /**
     * A flag used in the calculation of build order
     */
    boolean mProcessed = false;
    
    public PlannedPackage (Package pkg)
    {
        this.mPkg = pkg;
    }
    
    /** Comparator for sorting package collections by mRippleOrder, mBuildTime and mSeqId.
     *  mSeqId help UTF reproducibility  
     */
    static final Comparator<PlannedPackage> BuildOrderComparitor = new Comparator<PlannedPackage>() {
        
        /**
         * Returns -ve: p1 < p2
         *           0: p1 = p2
         *         +ve: p1 > p2
         */
        public int compare (PlannedPackage p1, PlannedPackage p2) {
            if (p1.mBuildLevel == p2.mBuildLevel)
            {
                if (p1.mPkg.mBuildTime == p2.mPkg.mBuildTime) {
                    return p1.mPkg.mSeqId - p2.mPkg.mSeqId;
                }
                return p1.mPkg.mBuildTime - p2.mPkg.mBuildTime;
            }
            return p1.mBuildLevel - p2.mBuildLevel;
        }
    };
    
}