From: erik Date: Mon, 12 May 2008 09:29:18 +0000 (+0000) Subject: Added SetterConfiguration class for configuring how setters correspond to required... X-Git-Tag: wamblee-utils-0.2~1^2~161 X-Git-Url: http://wamblee.org/gitweb/?a=commitdiff_plain;h=f40c213efe9e06805afd66f8569c9cf9acc57184;p=utils Added SetterConfiguration class for configuring how setters correspond to required interfaces. --- diff --git a/support/general/src/main/java/org/wamblee/collections/CollectionFilter.java b/support/general/src/main/java/org/wamblee/collections/CollectionFilter.java index c52bf7b1..75cdcb1e 100644 --- a/support/general/src/main/java/org/wamblee/collections/CollectionFilter.java +++ b/support/general/src/main/java/org/wamblee/collections/CollectionFilter.java @@ -21,6 +21,14 @@ import org.wamblee.conditions.Condition; public class CollectionFilter { + /** + * Filters a collection by adding all elements in the from collection + * that satisfy a given condition to the to collection. + * @param Type of contained element. + * @param aFrom From container to which the condition is applied. + * @param aTo To container to which matching elements are added. + * @param aCondition Condition by which elements are matched. + */ public static void filter(Collection aFrom, Collection aTo, Condition aCondition) { for (T t: aFrom) { if ( aCondition.matches(t)) { diff --git a/support/general/src/test/java/org/wamblee/test/AssertionUtils.java b/support/general/src/test/java/org/wamblee/test/AssertionUtils.java index 0a3e4171..82462041 100644 --- a/support/general/src/test/java/org/wamblee/test/AssertionUtils.java +++ b/support/general/src/test/java/org/wamblee/test/AssertionUtils.java @@ -15,6 +15,8 @@ */ package org.wamblee.test; +import java.util.Arrays; +import java.util.Comparator; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -45,9 +47,10 @@ public final class AssertionUtils { * @param aActual * Actual object array. */ - public static void assertEquals(Object[] aExpected, Object[] aActual) { + public static void assertEquals(T[] aExpected, T[] aActual) { assertEquals("", aExpected, aActual); } + /** * Asserts that two object arrays are equal. @@ -59,8 +62,8 @@ public final class AssertionUtils { * @param aActual * Actual array. */ - public static void assertEquals(String aMsg, Object[] aExpected, - Object[] aActual) { + public static void assertEquals(String aMsg, T[] aExpected, + T[] aActual) { TestCase.assertEquals(aMsg + ": Array lengths ", aExpected.length, aActual.length); @@ -69,6 +72,7 @@ public final class AssertionUtils { aActual[i]); } } + /** * Asserts that two objects are equal, and in case the object is an Object[] @@ -81,8 +85,8 @@ public final class AssertionUtils { * @param aActual * Actual result. */ - public static void assertEquals(String aMsg, Object aExpected, - Object aActual) { + public static void assertEquals(String aMsg, T aExpected, + T aActual) { if (aExpected instanceof Object[]) { AssertionUtils.assertEquals(aMsg, (Object[]) aExpected, (Object[]) aActual); @@ -104,7 +108,8 @@ public final class AssertionUtils { * @param aActual * Actual result. */ - public static void assertEquals(String aMsg, Map aExpectedMap, Map aActual) { + public static void assertEquals(String aMsg, + Map aExpectedMap, Map aActual) { TestCase.assertEquals("Map sizes differ", aExpectedMap.size(), aActual .size()); @@ -132,6 +137,7 @@ public final class AssertionUtils { public static void assertException(ErroneousCode aObject, Class aType) { try { aObject.run(); + throw new RuntimeException("No exception occurred"); } catch (Throwable t) { if ( aType.isInstance(t)) { return; // ok