Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-3328

Immutable beans, powered by reflection

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.22.0
    • None
    • None

    Description

      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,

      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));
      

      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.

      Work in progress: https://github.com/julianhyde/calcite/tree/3328-immutable-beans

      Attachments

        Activity

          People

            julianhyde Julian Hyde
            julianhyde Julian Hyde
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: