Return-Path: Delivered-To: apmail-commons-dev-archive@www.apache.org Received: (qmail 4699 invoked from network); 18 Oct 2009 20:22:10 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 18 Oct 2009 20:22:10 -0000 Received: (qmail 54163 invoked by uid 500); 18 Oct 2009 20:22:10 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 54028 invoked by uid 500); 18 Oct 2009 20:22:10 -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 54018 invoked by uid 99); 18 Oct 2009 20:22:10 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 18 Oct 2009 20:22:10 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of flamefew@gmail.com designates 209.85.221.183 as permitted sender) Received: from [209.85.221.183] (HELO mail-qy0-f183.google.com) (209.85.221.183) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 18 Oct 2009 20:22:01 +0000 Received: by qyk13 with SMTP id 13so775065qyk.27 for ; Sun, 18 Oct 2009 13:21:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=LUTozRyQQJKX4TRNqQgkw5Z5i7/keU+KyGOdCASn2w4=; b=FQaxzJwlpIOrx7/8Lm9bdm50JqWdMA16LtzoUaGu0u+nu5b0fYWzCXcucVw6EwVD3W c9j/Q/L5eMp4cOtLJ970zN8NWyPSKGCSDg5tRt5yUdYXg8Nq9kOsMrnwnDv7Jj6aPXnW Y9nYiBslepkPaBMTBf8X6ZhjgGF3qNPcndZTo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=m0rjns0mPN8fGtm7gnz21xpq3iujJU31X+5Q8wUQkPljHKocBsBuA42PODqBxEjFZV hIu+OmGH8gPkPtF5lRf6heljzzqpf0DozmM5IfRaS9CbL2Qy+Z9bx8yzr/Xr9PFrS01y WuAJyLZ86Mz+Jl1ojPQqKPVb30GSr5zmNirt4= MIME-Version: 1.0 Received: by 10.229.33.201 with SMTP id i9mr591409qcd.83.1255897300918; Sun, 18 Oct 2009 13:21:40 -0700 (PDT) In-Reply-To: <31cc37360910181304x2bf429a8hb445af2aec961e4f@mail.gmail.com> References: <20091018072600.884C62388904@eris.apache.org> <25aac9fc0910180428s6e670f60x14f4a24e30391533@mail.gmail.com> <31cc37360910181249n4059e101ifa22594003c2b3a4@mail.gmail.com> <31cc37360910181304x2bf429a8hb445af2aec961e4f@mail.gmail.com> Date: Sun, 18 Oct 2009 13:21:40 -0700 Message-ID: <31cc37360910181321r6d4c9d2ar33fecacaaf7f4e86@mail.gmail.com> Subject: Re: svn commit: r826370 - in /commons/proper/lang/trunk/src: java/org/apache/commons/lang/text/translate/UnicodeUnescaper.java test/org/apache/commons/lang/text/translate/UnicodeUnescaperTest.java From: Henri Yandell 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 Which ended up looking like: public static enum PARAM { escapePlus }; private EnumSet params; public UnicodeUnescaper(PARAM... params) { if(params.length > 0) { this.params =3D EnumSet.copyOf(Arrays.asList(params)); } } public boolean isSet(PARAM p) { return (params =3D=3D null) ? false : params.contains(p); } Opinions very, very much desired. Tempted to extend EnumSet to simplify a little of the null protection etc. ParamSet

and protecting against empty arrays and null params. Maybe looking like: public static enum PARAM { escapePlus }; private ParamSet params =3D new ParamSet(); public UnicodeUnescaper(PARAM... parameters) { this.params.add(parameters); } public boolean isSet(PARAM p) { return params.contains(p); } To a user this looks like: uu =3D new UnicodeUnescaper(UnicodeUnescaper.PARAM.escapePlus); with the advantage for us being that we can add options to a class without API problems. Hen On Sun, Oct 18, 2009 at 1:04 PM, Henri Yandell wrote: > On Sun, Oct 18, 2009 at 12:49 PM, Henri Yandell wrot= e: > >> Fair enough on the threading though. I'll move to constructor as I >> can't think of anything better. > > Rambling out loud. > > Better (for API scaling): > > enum FooParam { various PARAM options} > > constructor: =A0Foo(FooParam... fp) { =A0this.options =3D > EnumSet.copyOf(Collections.asList(fp)); } > > That would work quite nicely to replace all the painful boolean > constructor parameters. That leaves us then needing a way to scale > this for a single initial parameter: > > With a recompile, you could have an Object called PARAM and replace it > with a FooParam.PARAM later on of type enum:FooParam, but I'm assuming > that would be an error at runtime. So for runtime API scaling you > would need to set the enum up from the start. Ideally it wants to be > in the same class/file though, which means an inner class so you can > make it public. So: > > new Foo(Foo.PARAM.escapingPlus) > > You could also have a single argument constructor to start with, but > again runtime is probably unhappy when you switch (or overload - > compile error?) with varargs. > > Is it a worthwhile pattern to avoid rampant booleanism in a minority > of classes? Not convinced. > > Hen > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org