Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 4695 invoked from network); 23 Oct 2002 08:21:27 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 23 Oct 2002 08:21:27 -0000 Received: (qmail 27234 invoked by uid 97); 23 Oct 2002 08:22:27 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@jakarta.apache.org Received: (qmail 27218 invoked by uid 97); 23 Oct 2002 08:22:26 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 27206 invoked by uid 98); 23 Oct 2002 08:22:26 -0000 X-Antivirus: nagoya (v4218 created Aug 14 2002) Message-ID: <057801c27a6d$3eff7c30$3f1ea8c0@ports.local> From: "Ola Berg" To: "Jakarta Commons Developers List" References: <004101c27936$687e55a0$296178d5@oemcomputer> <035f01c27998$bdbec060$3f1ea8c0@ports.local> <008c01c27a14$74a68580$618327d9@oemcomputer> Subject: Re: [Lang] Validate Date: Wed, 23 Oct 2002 10:21:54 +0200 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N > Anyway, the class is hardly tough to write from scratch. (Mine doesn't = have > the fancy array/list checking methods) Of course. I just want some sort of interface spec to build from, and as = I know that you are good at naming things, I thought that you already = had coined excellent names for the methods. Initial interface spec: //contains static utility methods that throws IAE,=20 class Validate //throws if false: general utility isTrue( boolean) //most common, most other methods calls this as well before other checks notNull( Object) //throws if Object can't be assigned to a variable of type isOfType( Object, Class type) //throws if the array is empty notEmpty( Object[]) //throws if the array contains null elements noNullElements( Object []) end class Validate --- Other possible methods * relevant checks for Strings and other common classes in java.lang (and = primitives) such as notEmpty( String s) isPositive( int i) isPositive( Number) //is Number good for this or do we need * relevant checks for Collection classes (so that arrays and collections = behaves the same) such as notEmpty( Collection c) noNullElements( Collection c) * relevant checks for other common java.util classes too (Date etc) * relevant checks for other common java classes (io and net, few = javaprogs manages without lang, util, io and net) ---- Personally, I think that the two last points are overkill, but they = raises a question: should we have some kind of (naming/design) pattern = for creating validation utilities for other type, in order to promote = consistency? ---- Important issue: Exception messages Should each method have a String argument containing the messages? Or = should each method exist in two versions, one that throws a default = message and one that can take a provided message: public static void noNullElements( Object[] array){ .... } public static void noNullElements( Object[] array, String message){ .... } What do you think? /O -- To unsubscribe, e-mail: For additional commands, e-mail: