Return-Path: X-Original-To: apmail-commons-dev-archive@www.apache.org Delivered-To: apmail-commons-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0E4D310BA1 for ; Tue, 22 Oct 2013 17:38:02 +0000 (UTC) Received: (qmail 61684 invoked by uid 500); 22 Oct 2013 17:38:00 -0000 Delivered-To: apmail-commons-dev-archive@commons.apache.org Received: (qmail 61575 invoked by uid 500); 22 Oct 2013 17:38:00 -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 61553 invoked by uid 99); 22 Oct 2013 17:37:59 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Oct 2013 17:37:59 +0000 X-ASF-Spam-Status: No, hits=0.3 required=5.0 tests=FREEMAIL_REPLY,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of sebbaz@gmail.com designates 74.125.82.46 as permitted sender) Received: from [74.125.82.46] (HELO mail-wg0-f46.google.com) (74.125.82.46) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 22 Oct 2013 17:37:50 +0000 Received: by mail-wg0-f46.google.com with SMTP id m15so8144291wgh.1 for ; Tue, 22 Oct 2013 10:37:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=ofpzkJFIaifNzgyQCbtYaCCoL211plZxUlDHIJy2qxE=; b=B91KulmS2dav3OT6T6KMlqs2yScJuAXHxzwy9eNrnEb6/goPt0P10C0rqY7z1pcul/ XqSEPJcNXlOgndzzYHNbSgsSJyc4AwtloU42977IZvltCQw3n4hf1Bfy4nYWIgtFqCKa nBnwV5sIaLOe+EjY8zVKggBT11ffM80m2vx510cTwBkMvUKi2F2iAvGahtJWiK6FWKP/ RzuGJ/o2fIOXQ/skaprpU9Hkx47tjNN9RpsUtSK+HpvcaAYOdmCR++0BDhrePRB/WBIf Ijf0Kij4ctbIjdxuiPjOIYe0iNdW7s9XiUxfwhyDI1fEh2//QZ9i/gNXY/ZIvt29/iD4 c3bg== MIME-Version: 1.0 X-Received: by 10.180.11.37 with SMTP id n5mr15542355wib.25.1382463448877; Tue, 22 Oct 2013 10:37:28 -0700 (PDT) Received: by 10.194.24.99 with HTTP; Tue, 22 Oct 2013 10:37:28 -0700 (PDT) In-Reply-To: References: Date: Tue, 22 Oct 2013 18:37:28 +0100 Message-ID: Subject: Re: [lang] ImmutablePair is final From: sebb To: Commons Developers List Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Checked: Checked by ClamAV on apache.org On 22 October 2013 18:33, Gary Gregory wrote: > On Tue, Oct 22, 2013 at 1:22 PM, Paul Benedict wrote: > >> If you can subclass, the class will likely be mutable somehow (accessing >> protected or package-private data?) -- even introducing new variables >> exclusive to the subclass. The "final" keyword is used well here. >> > > Here is my use case for which I've cloned ImmutablePair into my own package > (yuck): Composition (rather than extension) would work better here surely? > public final class ImmutableFooImmutableBarPair extends > ImmutablePair { > > private static final long serialVersionUID = 123L; > > public ImmutableFooImmutableBarPair (final ImmutableFoo foo, final > ImmutableBar bar) { > super(Validate.notNull(nameMatch), Validate.notNull(article)); > } > > public ImmutableFoo getImmutableFoo() { > return this.getValue(); > } > > public ImmutableBar getImmutableBar() { > return this.getKey(); > } > ... > ImmutableFooImmutableBarPair pair = new ImmutableFooImmutableBarPair(myFoo, > myBar); > ... > pair.getImmutableFoo(); > ... > pair.getImmutableBar(); > > Gary > > >> >> On Tue, Oct 22, 2013 at 12:15 PM, sebb wrote: >> >> > On 22 October 2013 18:10, Gary Gregory wrote: >> > > Hi All: >> > > >> > > Is there any reason we would want to keep ImmutablePair final? >> > >> > To stop mutable subclasses from being created? >> > >> > BTW, it's unfortunate that the fields are public; they should have >> > been private (there are public getters). >> > >> > > Gary >> > > >> > > -- >> > > E-Mail: garydgregory@gmail.com | ggregory@apache.org >> > > Java Persistence with Hibernate, Second Edition< >> > http://www.manning.com/bauer3/> >> > > JUnit in Action, Second Edition >> > > Spring Batch in Action >> > > Blog: http://garygregory.wordpress.com >> > > Home: http://garygregory.com/ >> > > Tweet! http://twitter.com/GaryGregory >> > >> > --------------------------------------------------------------------- >> > To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org >> > For additional commands, e-mail: dev-help@commons.apache.org >> > >> > >> >> >> -- >> Cheers, >> Paul >> > > > > -- > E-Mail: garydgregory@gmail.com | ggregory@apache.org > Java Persistence with Hibernate, Second Edition > JUnit in Action, Second Edition > Spring Batch in Action > Blog: http://garygregory.wordpress.com > Home: http://garygregory.com/ > Tweet! http://twitter.com/GaryGregory --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org For additional commands, e-mail: dev-help@commons.apache.org