Re: 1.5.0 Syntex Question
From: Alan Moore (jbigboote_at_yoyodyne.com)
Date: 03/17/05
- Next message: David McDivitt: "Re: pooled connection myth"
- Previous message: David McDivitt: "Re: pooled connection myth"
- In reply to: Aryeh M. Friedman: "1.5.0 Syntex Question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 17 Mar 2005 07:59:44 -0800
On Thu, 17 Mar 2005 01:57:23 -0500, "Aryeh M. Friedman"
<aryeh@m-net.arbornet.org> wrote:
>public class Assert {
>
> .
> .
> .
>
> /**
>
> if val is between (inclusive) min and max pass else fail
>
> @param val the "real" value
> @param min the minimal value allowed
> @param max the maximum value allowed
> */
>
> public static void assertRange(Object val,Object min,Object max)
> {
> try {
> if(((Comparable<Object>) val).compareTo(min)<0)
> _assert("assertRange: value to low minimum value is "
> + min + " got " + val);
>
> // repeat test to see if more then max
> } catch(ClassCastException e) {
> TestResult.error(e);
> }
> }
>}
Change the method signature to:
public static <T extends Comparable<T>> void
assertRange(T val, T min, T max)
Then you won't need to do any casts, and the "unchecked" warnings
should go away.
- Next message: David McDivitt: "Re: pooled connection myth"
- Previous message: David McDivitt: "Re: pooled connection myth"
- In reply to: Aryeh M. Friedman: "1.5.0 Syntex Question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]