001    package edu.nrao.sss.model.project.scheduling.constraint;
002    
003    /**
004     * Represents the result of analyzing the probability of success
005     * of a scheduling block under an operating condition. 
006     * @author slovelan
007     */
008    
009    public class ConstraintProbability {
010            
011            public static final int SUCCESS = 1;
012            public static final int FAILURE = 0;
013                    
014            public static final String NO_CONSTRAINT_SB = "The scheduling block did not have a restriction with respect to this condition.";
015            public static final String NO_CONSTRAINT_OPERATING = "There is currently no operating constraint for this condition.";
016            
017            private float successProb = FAILURE;
018            private String message = "";
019            private ConstraintType constraintType = ConstraintType.getDefault();
020            
021            /**
022             * Constructs a default instance with no probability of success.
023             */
024            
025            public ConstraintProbability(){
026            }
027            
028            public float getProbabilitySuccess(){
029                    return successProb;
030            }
031            
032            public void setProbabilitySuccess( float successProb ){
033                    if ( successProb >= FAILURE && successProb <= SUCCESS ){
034                            this.successProb = successProb;
035                    }
036                    else {
037                            throw new IllegalArgumentException( "The number "+successProb
038                                            +" does not represent a probability of success!");
039                    }
040            }
041            
042            public String getMessage(){
043                    return message;
044            }
045            
046            public void setMessage( String msg ){
047                    this.message = msg;
048            }
049            
050            public ConstraintType getConstraintType(){
051                    return constraintType;
052            }
053            
054            public void setConstraintType( ConstraintType constraintType ){
055                    if ( constraintType == null ){
056                            throw new IllegalArgumentException( "Need to know the operating condition this represents: "+ constraintType );
057                    }
058                    this.constraintType = constraintType;
059            }
060            
061    }