explicitly throw null ptr exception if function is null
This commit is contained in:
@@ -65,8 +65,12 @@ public class IntegralCalculator {
|
|||||||
* @param lowerBound The lower bound of the integration interval.
|
* @param lowerBound The lower bound of the integration interval.
|
||||||
* @param upperBound The upper bound of the integration interval.
|
* @param upperBound The upper bound of the integration interval.
|
||||||
* @return The estimated value of the definite integral.
|
* @return The estimated value of the definite integral.
|
||||||
|
* @throws NullPointerException if the function is null.
|
||||||
*/
|
*/
|
||||||
public double calculate(Function<Double, Double> function, double lowerBound, double upperBound) {
|
public double calculate(Function<Double, Double> function, double lowerBound, double upperBound) {
|
||||||
|
if (function == null)
|
||||||
|
throw new NullPointerException("function cannot be null");
|
||||||
|
|
||||||
if (lowerBound == upperBound) {
|
if (lowerBound == upperBound) {
|
||||||
this.callProgressCallback(0, 1);
|
this.callProgressCallback(0, 1);
|
||||||
this.callProgressCallback(1, 1);
|
this.callProgressCallback(1, 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user