Return-Path: Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: (qmail 58033 invoked from network); 1 Nov 2009 17:10:25 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 1 Nov 2009 17:10:25 -0000 Received: (qmail 52892 invoked by uid 500); 1 Nov 2009 17:10:25 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 52805 invoked by uid 500); 1 Nov 2009 17:10:25 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 52796 invoked by uid 99); 1 Nov 2009 17:10:25 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 01 Nov 2009 17:10:25 +0000 X-ASF-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 01 Nov 2009 17:10:22 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 792232388904; Sun, 1 Nov 2009 17:10:02 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r831709 - in /commons/proper/lang/trunk/src: java/org/apache/commons/lang/Validate.java test/org/apache/commons/lang/ValidateTest.java Date: Sun, 01 Nov 2009 17:10:02 -0000 To: commits@commons.apache.org From: scolebourne@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20091101171002.792232388904@eris.apache.org> Author: scolebourne Date: Sun Nov 1 17:10:02 2009 New Revision: 831709 URL: http://svn.apache.org/viewvc?rev=831709&view=rev Log: LANG-493 - Remove allElementsOfType as generics handles this pretty well now Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/Validate.java commons/proper/lang/trunk/src/test/org/apache/commons/lang/ValidateTest.java Modified: commons/proper/lang/trunk/src/java/org/apache/commons/lang/Validate.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/Validate.java?rev=831709&r1=831708&r2=831709&view=diff ============================================================================== --- commons/proper/lang/trunk/src/java/org/apache/commons/lang/Validate.java (original) +++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/Validate.java Sun Nov 1 17:10:02 2009 @@ -550,63 +550,6 @@ return collection; } - // allElementsOfType collection - //--------------------------------------------------------------------------------- - - /** - *

Validate an argument, throwing IllegalArgumentException - * if the argument collection is null or has elements that - * are not of type clazz or a subclass.

- * - *
-     * Validate.allElementsOfType(collection, String.class, "Collection has invalid elements");
-     * 
- * - * @param collection the collection to check, not null - * @param clazz the Class which the collection's elements are expected to be, not null - * @param message the exception message if the Collection has elements not of type clazz - * @since 2.1 - */ - public static void allElementsOfType(Collection collection, Class clazz, String message) { - Validate.notNull(collection); - Validate.notNull(clazz); - for (Iterator it = collection.iterator(); it.hasNext(); ) { - if (clazz.isInstance(it.next()) == false) { - throw new IllegalArgumentException(message); - } - } - } - - /** - *

- * Validate an argument, throwing IllegalArgumentException if the argument collection is - * null or has elements that are not of type clazz or a subclass. - *

- * - *
-     * Validate.allElementsOfType(collection, String.class);
-     * 
- * - *

- * The message in the exception is 'The validated collection contains an element not of type clazz at index: '. - *

- * - * @param collection the collection to check, not null - * @param clazz the Class which the collection's elements are expected to be, not null - * @since 2.1 - */ - public static void allElementsOfType(Collection collection, Class clazz) { - Validate.notNull(collection); - Validate.notNull(clazz); - int i = 0; - for (Iterator it = collection.iterator(); it.hasNext(); i++) { - if (clazz.isInstance(it.next()) == false) { - throw new IllegalArgumentException("The validated collection contains an element not of type " - + clazz.getName() + " at index: " + i); - } - } - } - // validIndex array //--------------------------------------------------------------------------------- Modified: commons/proper/lang/trunk/src/test/org/apache/commons/lang/ValidateTest.java URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/org/apache/commons/lang/ValidateTest.java?rev=831709&r1=831708&r2=831709&view=diff ============================================================================== --- commons/proper/lang/trunk/src/test/org/apache/commons/lang/ValidateTest.java (original) +++ commons/proper/lang/trunk/src/test/org/apache/commons/lang/ValidateTest.java Sun Nov 1 17:10:02 2009 @@ -626,46 +626,6 @@ //----------------------------------------------------------------------- //----------------------------------------------------------------------- - public void testAllElementsOfType() { - List coll = new ArrayList(); - coll.add("a"); - coll.add("b"); - Validate.allElementsOfType(coll, String.class, "MSG"); - Validate.allElementsOfType(coll, String.class); - try { - Validate.allElementsOfType(coll, Integer.class, "MSG"); - fail("Expecting IllegalArgumentException"); - } catch (IllegalArgumentException ex) { - assertEquals("MSG", ex.getMessage()); - } - coll.set(1, Boolean.FALSE); - try { - Validate.allElementsOfType(coll, String.class); - fail("Expecting IllegalArgumentException"); - } catch (IllegalArgumentException ex) { - assertEquals("The validated collection contains an element not of type java.lang.String at index: 1", ex.getMessage()); - } - - coll = new ArrayList(); - coll.add(new Integer(5)); - coll.add(new Double(2.0d)); - Validate.allElementsOfType(coll, Number.class, "MSG"); - try { - Validate.allElementsOfType(coll, Integer.class, "MSG"); - fail("Expecting IllegalArgumentException"); - } catch (IllegalArgumentException ex) { - assertEquals("MSG", ex.getMessage()); - } - try { - Validate.allElementsOfType(coll, Double.class, "MSG"); - fail("Expecting IllegalArgumentException"); - } catch (IllegalArgumentException ex) { - assertEquals("MSG", ex.getMessage()); - } - } - - //----------------------------------------------------------------------- - //----------------------------------------------------------------------- public void testConstructor() { assertNotNull(new Validate()); Constructor[] cons = Validate.class.getDeclaredConstructors();