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 Hyde (Jira)" <ji...@apache.org> on 2020/09/12 22:55:00 UTC

[jira] [Updated] (CALCITE-4254) ImmutableBeans should make an immutable copy of property values of type List, Set, or Map

     [ https://issues.apache.org/jira/browse/CALCITE-4254?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Julian Hyde updated CALCITE-4254:
---------------------------------
    Summary: ImmutableBeans should make an immutable copy of property values of type List, Set, or Map  (was: ImmutableBeans should make an immutable copy of lists, sets, maps)

> ImmutableBeans should make an immutable copy of property values of type List, Set, or Map
> -----------------------------------------------------------------------------------------
>
>                 Key: CALCITE-4254
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4254
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Julian Hyde
>            Assignee: Julian Hyde
>            Priority: Major
>
> {{ImmutableBeans}} should make an immutable copy of values of type {{List}}, {{Set}} or {{Map}} when they are provided via a setter method. For example, this is how it should work:
> {code:java}
> MyBean bean = ImmutableBeans.create(MyBean.class);
> List<Integer> evens = Arrays.asList(2, 4, 6);
> bean = bean.withNumbers(evens);
> assertThat(bean.getNumbers(), equalTo(evens));
> assertThat(bean.getNumbers(), isInstanceOf(ImmutableList.class));
> {code}
> Note that {{evens}} has been converted to an {{ImmutableList}} with the same contents.
> You can control this behavior by setting {{makeImmutable = false}} when you declare the property:
> {code:java}
> interface MyBean {
>   @ImmutableBean.Property(makeImmutable = false)
>   List<Integer> getNumbers();
>   MyBean withNumbers(List<Integer> numbers);
> }
> {code}
> By default, {{makeImmutable}} is true. This will change behavior of a very few existing beans that were assuming that the value that was put in would be the value that came out (see a couple of changes in {{VolcanoPlannerTest}}), but for the vast majority, immutability is the desired behavior.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)