Return-Path: Delivered-To: apmail-commons-dev-archive@www.apache.org Received: (qmail 31804 invoked from network); 27 Nov 2009 01:39:42 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 27 Nov 2009 01:39:42 -0000 Received: (qmail 69153 invoked by uid 500); 27 Nov 2009 01:39:41 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 69033 invoked by uid 500); 27 Nov 2009 01:39:41 -0000 Mailing-List: contact dev-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Developers List" Delivered-To: mailing list dev@commons.apache.org Received: (qmail 69023 invoked by uid 99); 27 Nov 2009 01:39:41 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Nov 2009 01:39:41 +0000 X-ASF-Spam-Status: No, hits=1.2 required=10.0 tests=SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [74.125.92.149] (HELO qw-out-1920.google.com) (74.125.92.149) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 27 Nov 2009 01:39:32 +0000 Received: by qw-out-1920.google.com with SMTP id 14so195965qwa.60 for ; Thu, 26 Nov 2009 17:39:11 -0800 (PST) MIME-Version: 1.0 Sender: jcarman@carmanconsulting.com Received: by 10.229.29.148 with SMTP id q20mr53333qcc.51.1259285951506; Thu, 26 Nov 2009 17:39:11 -0800 (PST) In-Reply-To: References: From: James Carman Date: Thu, 26 Nov 2009 20:38:51 -0500 X-Google-Sender-Auth: d674c3bf1e3349cb Message-ID: Subject: Re: [lang 3] static or dynamic type checks? To: Commons Developers List Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org Yes, but if the check passes, there's no need to create the Object[] for single-argument method invocations. On Thu, Nov 26, 2009 at 10:59 AM, Paul Benedict wrot= e: > The purpose of var-args, at least from my vantage, is to produce > detail messages that are used by java.lang.String.format. > > Paul > > On Thu, Nov 26, 2009 at 7:11 AM, James Carman > wrote: >> I just wrote a class that included... >> >> =A0 =A0public static T someMethod(T val) >> =A0 =A0{ >> =A0 =A0 =A0 =A0System.out.println("Single value method!"); >> =A0 =A0 =A0 =A0return val; >> =A0 =A0} >> >> =A0 =A0public static T[] someMethod(T... values) >> =A0 =A0{ >> =A0 =A0 =A0 =A0System.out.println("Multi-value method."); >> =A0 =A0 =A0 =A0return values; >> =A0 =A0} >> >> =A0 =A0public static void main(String[] args) >> =A0 =A0{ >> =A0 =A0 =A0 =A0someMethod("Hello"); >> =A0 =A0 =A0 =A0someMethod("Hello", "World"); >> =A0 =A0} >> >> When I ran it, it printed: >> >> Single value method! >> Multi-value method. >> >> So, what's the big deal? =A0Create a single-value method and create a >> multi-value method. =A0I must be missing something in this discussion. >> >> On Thu, Nov 26, 2009 at 12:16 AM, Paul Benedict w= rote: >>> If we want to implement LANG-508 (Validate: add message parameter >>> construction via elllipsis notation to speed up processing), I am >>> really concerned with the many overloaded versions of #validIndex() >>> and #notEmpty() that solely differ by static argument type: >>> Collection, Object, Object[], CharSequence, etc. >>> >>> Because var-args instantiate a new Object[], it won't be possible to >>> easily create one-argument optimized overloaded versions to prevent >>> the creation. Such as: >>> public static T[] notEmpty(Object array, String message, Object var= 1); >>> public static T[] notEmpty(Object array, String message, Object >>> var1, Object var2); >>> public static T[] notEmpty(Object array, String message, Object >>> var1, Object var2, Object var3); >>> public static T[] notEmpty(Object array, String message, Object >>> var1, Object var2, Object var3, Object... vars); >>> >>> I am following the good advice on Joshua Bloch on this one. It's item >>> #42 in his Effective Java book. >>> >>> I want to eliminate the overloaded versions by type and check those >>> types using instanceof instead. Thoughts? >>> >>> Paul >>> >>> --------------------------------------------------------------------- >>> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org >>> For additional commands, e-mail: dev-help@commons.apache.org >>> >>> >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org >> For additional commands, e-mail: dev-help@commons.apache.org >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org > For additional commands, e-mail: dev-help@commons.apache.org > > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org