1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 package org.apache.commons.statistics.distribution; 18 19 import java.util.Locale; 20 21 /** 22 * Package private exception class with constants for frequently used messages. 23 */ 24 class DistributionException extends IllegalArgumentException { 25 /** Error message for "too large" condition when {@code x > y}. */ 26 static final String TOO_LARGE = "%s > %s"; 27 /** Error message for "too small" condition when {@code x < y}. */ 28 static final String TOO_SMALL = "%s < %s"; 29 /** Error message for "out of range" condition when "x not in [a, b]". */ 30 static final String OUT_OF_RANGE = "Number %s is out of range [%s, %s]"; 31 /** Error message for "invalid range" condition when "lower >= upper". */ 32 static final String INVALID_RANGE_LOW_GTE_HIGH = "Lower bound %s >= upper bound %s"; 33 /** Error message for "invalid range" condition when "lower > upper". */ 34 static final String INVALID_RANGE_LOW_GT_HIGH = "Lower bound %s > upper bound %s"; 35 /** Error message for "invalid probability" condition when "x not in [0, 1]". */ 36 static final String INVALID_PROBABILITY = "Not a probability: %s is out of range [0, 1]"; 37 /** Error message for "invalid non-zero probability" condition when "x not in (0, 1]". */ 38 static final String INVALID_NON_ZERO_PROBABILITY = "Not a non-zero probability: %s is out of range (0, 1]"; 39 /** Error message for "negative" condition when {@code x < 0}. */ 40 static final String NEGATIVE = "Number %s is negative"; 41 /** Error message for "not strictly positive" condition when {@code x <= 0}. */ 42 static final String NOT_STRICTLY_POSITIVE = "Number %s is not greater than 0"; 43 /** Error message for "not strictly positive finite" condition when {@code x <= 0 || x == inf}. */ 44 static final String NOT_STRICTLY_POSITIVE_FINITE = "Number %s is not greater than 0 and finite"; 45 46 /** Serializable version identifier. */ 47 private static final long serialVersionUID = 20180119L; 48 49 /** 50 * Creates an exception. 51 * 52 * @param message Exception message with replaceable parameters. 53 * @param formatArguments Arguments for formatting the message. 54 */ 55 DistributionException(String message, Object... formatArguments) { 56 super(String.format(Locale.ROOT, message, formatArguments)); 57 } 58 }