From 003f022df47bfb1370514aca3b2cee1a9116f3d7 Mon Sep 17 00:00:00 2001 From: Luc Maisonobe Date: Wed, 5 Sep 2012 18:23:54 +0000 Subject: [PATCH] Added throw declarations for FieldElements. git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@1381282 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/commons/math3/FieldElement.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/apache/commons/math3/FieldElement.java b/src/main/java/org/apache/commons/math3/FieldElement.java index 14dc22134..dfe12a348 100644 --- a/src/main/java/org/apache/commons/math3/FieldElement.java +++ b/src/main/java/org/apache/commons/math3/FieldElement.java @@ -16,6 +16,9 @@ */ package org.apache.commons.math3; +import org.apache.commons.math3.exception.MathArithmeticException; +import org.apache.commons.math3.exception.NullArgumentException; + /** * Interface representing field elements. @@ -29,14 +32,16 @@ public interface FieldElement { /** Compute this + a. * @param a element to add * @return a new element representing this + a + * @throws NullArgumentException if {@code addend} is {@code null}. */ - T add(T a); + T add(T a) throws NullArgumentException; /** Compute this - a. * @param a element to subtract * @return a new element representing this - a + * @throws NullArgumentException if {@code a} is {@code null}. */ - T subtract(T a); + T subtract(T a) throws NullArgumentException; /** * Returns the additive inverse of {@code this} element. @@ -57,20 +62,24 @@ public interface FieldElement { /** Compute this × a. * @param a element to multiply * @return a new element representing this × a + * @throws NullArgumentException if {@code a} is {@code null}. */ - T multiply(T a); + T multiply(T a) throws NullArgumentException; /** Compute this ÷ a. * @param a element to add * @return a new element representing this ÷ a + * @throws NullArgumentException if {@code a} is {@code null}. + * @throws MathArithmeticException if {@code a} is zero */ - T divide(T a); + T divide(T a) throws NullArgumentException, MathArithmeticException; /** * Returns the multiplicative inverse of {@code this} element. * @return the inverse of {@code this}. + * @throws MathArithmeticException if {@code this} is zero */ - T reciprocal(); + T reciprocal() throws MathArithmeticException; /** Get the {@link Field} to which the instance belongs. * @return {@link Field} to which the instance belongs