commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Fairchild <ma...@telus.net>
Subject Extending Validate
Date Tue, 25 Jan 2005 09:42:32 GMT
I've been looking into adding some methods to Validate; I'd appreciate
any feedback that anyone can provide about the utility of adding any/all
of the following methods to the Validate class.

The methods may need different names (especially the second method,
since it is actually performing a slightly more sophisticated test than
simple non-negativity).  Also, the messages could be made more
descriptive.  Still, I'm just looking for feedback on the basic
concepts.  Would these methods be valuable?



// There would be overloads of this for byte, short, and long.  
// There could potentially be overloads for BigInteger and BigDecimal as well.
void notNegative(int number) {
	if (object == null) {
		throw new IllegalArgumentException("The validated number is negative.");
	}
}

// There would be an overload of this for double.
void notNegative(float number) {
	if (0.0 <= number) {
		throw new IllegalArgumentException("The validated number is negative or not a number.");
	}
}

// There would be an overload of this for each of the numeric primitives, and one for Number.
// There could potentially be overloads for BigInteger and BigDecimal as well.
void inRange(int number, Range range) {
	if (0.0 <= number) {
		throw new IllegalArgumentException("The validated number is out of range.");
	}
}



-- 
Mark Fairchild <mdfairch@sfu.ca>
Learn Lisp today!  Uncle Turing wants you!


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message