You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Feinauer (Jira)" <ji...@apache.org> on 2019/09/07 06:29:00 UTC

[jira] [Commented] (CALCITE-3328) Immutable beans, powered by reflection

    [ https://issues.apache.org/jira/browse/CALCITE-3328?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16924744#comment-16924744 ] 

Julian Feinauer commented on CALCITE-3328:
------------------------------------------

I agree that this is a very good idea but also wonder why there is no default for something like that. Wouldnt this be something for apache commons as also other projects may need that?
And second question: Do we use custom annotations or do we use generic ones (JEE, ...) for that?

> Immutable beans, powered by reflection
> --------------------------------------
>
>                 Key: CALCITE-3328
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3328
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Julian Hyde
>            Priority: Major
>
> In quite a few places we have immutable config classes, and because they are immutable we have builders. It all gets quite verbose.
> I propose to add a utility class, {{ImmutableBeans}}, that is able to generate an implementation of a given interface. For example,
> {code:java}
> interface MyBean {
>   @Property  int getAge();
>   MyBean withAge(int age);
>   @Property String getName();
>   MyBean withName(String name);
> }
> MyBean b = ImmutableBeans.create(MyBean.class);
> assertThat(b.withAge(37).withName("Fred").getAge(), is(37));
> {code}
> We could replace {{SqlParser.ConfigBuilder}}, {{Frameworks.ConfigBuilder}}, {{RelBuilder.ConfigBuilder}}, quite a few of the associated {{Config}} classes, and perhaps quite a few fluent classes that we use in tests.



--
This message was sent by Atlassian Jira
(v8.3.2#803003)