Return-Path: X-Original-To: apmail-zest-dev-archive@minotaur.apache.org Delivered-To: apmail-zest-dev-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 6506D18952 for ; Sun, 8 Nov 2015 08:32:47 +0000 (UTC) Received: (qmail 30529 invoked by uid 500); 8 Nov 2015 08:32:47 -0000 Delivered-To: apmail-zest-dev-archive@zest.apache.org Received: (qmail 30489 invoked by uid 500); 8 Nov 2015 08:32:47 -0000 Mailing-List: contact dev-help@zest.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@zest.apache.org Delivered-To: mailing list dev@zest.apache.org Received: (qmail 30477 invoked by uid 99); 8 Nov 2015 08:32:47 -0000 Received: from Unknown (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 08 Nov 2015 08:32:47 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 92CD91A0862 for ; Sun, 8 Nov 2015 08:32:46 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -0.121 X-Spam-Level: X-Spam-Status: No, score=-0.121 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id 73RfSII6CakU for ; Sun, 8 Nov 2015 08:32:45 +0000 (UTC) Received: from mail-lb0-f173.google.com (mail-lb0-f173.google.com [209.85.217.173]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTPS id 6598F206E8 for ; Sun, 8 Nov 2015 08:32:44 +0000 (UTC) Received: by lbbwb3 with SMTP id wb3so81348153lbb.1 for ; Sun, 08 Nov 2015 00:32:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-type:content-transfer-encoding; bh=pOX67InnRox480AiEGCU8HB2sEJxA2fA2Xw4zNv+cY8=; b=0buOdBomlvbePmKp87Ba1IWOKrPMhKJINNeb1lKw9cDOnAABXJr04QlfDk5abTq8tU 6GNtqiCCYGJf6iH+BoCoOJeCY1JI+pOQQkuWyJatBHfgRlaPubsF4436b92gEebV14u/ 0uJ3noiAa3vozv871yprUp4ZUkyORWvnZx5zUeQKUMCmhz3DDpVm89KeLJPPWYbmUX0B eOMx2b6VQOtJUCqsWM3hSVkpx6b9vlG0PJY25F2JU3SwE73Sw+dgB5pt3H8w3b3ilos1 nIcIbUFQVQvYLey70EzhQghUi4C2LUbeOg3DhcqvJXYEGvCO5YaHI0wcnYcZMacgcJWQ 9XXQ== X-Received: by 10.112.148.38 with SMTP id tp6mr11023913lbb.110.1446971558139; Sun, 08 Nov 2015 00:32:38 -0800 (PST) Received: from [192.168.1.10] (x1-6-2c-b0-5d-ac-a5-ea.cpe.webspeed.dk. [62.243.119.227]) by smtp.googlemail.com with ESMTPSA id lc3sm1411690lbc.3.2015.11.08.00.32.37 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 08 Nov 2015 00:32:37 -0800 (PST) Subject: Re: Common accessor for private State To: dev@zest.apache.org References: From: =?UTF-8?Q?Kent_S=c3=b8lvsten?= X-Enigmail-Draft-Status: N1110 Message-ID: <563F08AC.2030307@gmail.com> Date: Sun, 8 Nov 2015 09:32:44 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Hi Niclas Interesting! I have always found the syntax regarding private mixins (especially the quite large inner classes) a bit weird. So any improvements here would be great. An interesting thought: Could it be possible to create a JpaEntityAssociationStateDecorator? (not sure it is really a good idea, might be too complicated and integration might be better done by integrating the UOW with the global transaction management). Not quite convinced that core is the right place though - it probably depends on how certain we are to get the API right the first time. So a library *might* be better. Can You explain why *constuctor* injection is necessary in this case? You could be running into some chicken-and-egg-problem. Could making the State interface static help? ? Den 08-11-2015 kl. 04:17 skrev Niclas Hedhman: > Gang, > > I tend to use private state a lot, in a hidden interface within the > composite. I end up writing, > > @Mixins( PersonMixin.class ) > public interface Person > { > String name(); > Person spouse(); > > interface State > { > Property name(); > Association spouse(); > } > > class PersonMixin > { > @This State state; > > public String name() > { > return state.name().get(); > } > > public Person spouse() > { > return state.spouse().get(); > } > } > } > > > I find this being too much boilerplate and have been thinking of whether it > should be fixed. I am proposing that we create a "Decorator" (better name?) > all the way into the API to support this. > > @Mixins( PersonMixin.class ) > public interface Person > { > String name(); > Person spouse(); > > interface State > { > Property name(); > Association spouse(); > } > > class PersonMixin extends DefaultAssociationStateDecorator > { > PersonMixin( @This State state ) > { > super( state ); > } > } > } > > But then, why not expand on this and support Spring-style getter/setters as > well? > > @Mixins( PersonMixin.class ) > public interface Person > { > String getName(); > Person getSpouse(); > void setSpouse( Spouse spouse ); > > interface State > { > Property name(); > Association spouse(); > } > > class PersonMixin extends SpringBeanAssociationStateDecorator > { > PersonMixin( @This State state ) > { > super( state ); > } > } > } > > It is a relatively simple implementation, quite efficient in terms of > execution, and the main question for me is where to put it; > a. Core API (my choice) > b. In a library > c. Keep it to myself. > > WDYT?