1 /* 2 * Copyright 2006 - 2012 Christina Bohk and Roland Ewald 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package p3j.misc.errors; 17 18 /** 19 * An exception that represents an error with a set of probabilities. This 20 * happen if, e.g., it is 0 or doesn't sum up to 1. 21 * 22 * Created on January 21, 2007 23 * 24 * @author Christina Bohk 25 * @author Roland Ewald 26 * 27 */ 28 public class ProbabilityError extends GeneratorError { 29 30 /** Serialization ID. */ 31 private static final long serialVersionUID = 2294871670420743398L; 32 33 /** 34 * Flag if probability sum equals zero. If this is false, the exception marks 35 * a list of stochastically occurring objects whose probabilities do not sum 36 * up to 1. 37 */ 38 private final boolean equalZero; 39 40 /** 41 * Default constructor. 42 * 43 * @param eqZero 44 * flag that indicates the sum is equal to zero 45 * @param msg 46 * the message to be displayed to the user 47 */ 48 public ProbabilityError(boolean eqZero, String msg) { 49 super(msg); 50 this.equalZero = eqZero; 51 } 52 53 public boolean isEqualZero() { 54 return equalZero; 55 } 56 }