001    package edu.nrao.sss.model.project.scheduling.priority;
002    
003    public class PriorityFactory {
004            
005            private PriorityFactory(){
006                    
007            }
008            
009            public static PriorityMeasure getPriorityMeasure( PriorityMeasureType pmType ){
010                    PriorityMeasure pm = null;
011                    if ( PriorityMeasureType.WEIGHTED_SUM_OF_PRIORITIES.equals( pmType )){
012                            pm = new PriorityMeasureSum();
013                    }
014                    else {
015                            throw new IllegalArgumentException( "Unrecognized priority type: "+pmType );
016                    }
017                    return pm;
018            }
019            
020            public static PriorityMeasure getPriorityMeasureCopy( PriorityMeasure pm ){
021                    PriorityMeasure copy = null;
022                    if ( pm != null ){
023                            PriorityMeasureType pmt = pm.getPriorityMeasureType();
024                            if ( PriorityMeasureType.WEIGHTED_SUM_OF_PRIORITIES.equals( pmt )){
025                                    copy = new PriorityMeasureSum( (PriorityMeasureSum)pm );
026                            }
027                            else {
028                                    throw new IllegalArgumentException( "Unrecongnized priority type: "+pmt );
029                            }
030                    }
031                    return copy;
032            }
033            
034    
035    }