[
https://issues.apache.org/jira/browse/CALCITE-4787?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17418895#comment-17418895
]
Julian Hyde commented on CALCITE-4787:
--------------------------------------
{quote}the base Config interface with* methods are not parameterized
{quote}
Yeah, there's an automatic (and unwanted) upcast when you invoke a withXxx
method from a base class. E.g. given
{code:java}
interface Vehicle {
Vehicle withWheelCount(int x);
}
interface Plane extends Vehicle {
Plane withWingLength(int x);
}
{code}
the code {{plane.withWheelCount(2).withWingLength(30)}} will fail because
{{withWheelCount}} returns a {{Vehicle}} not a {{Plane}}. Parameterization is
one solution. Another is for us to define an overriding withXxx method each
time a method is inherited. E.g.
{code:java}
interface Vehicle {
Vehicle withWheelCount(int x);
}
interface Plane extends Vehicle {
Plane withWingLength(int x);
@Override Plane withWheelCount(int x);
}
{code}
Assuming Immutables could handle this pattern, it wouldn't be too onerous to
add these overriding methods to the existing code. And dependent projects don't
need to follow the pattern if they don't want to.
> Evaluate use of Immutables instead of ImmutableBeans
> ----------------------------------------------------
>
> Key: CALCITE-4787
> URL: https://issues.apache.org/jira/browse/CALCITE-4787
> Project: Calcite
> Issue Type: Improvement
> Reporter: Jacques Nadeau
> Assignee: Jacques Nadeau
> Priority: Major
> Labels: pull-request-available
> Time Spent: 4h 20m
> Remaining Estimate: 0h
>
> In the creation of CALCITE-3328, [Immutables|https://immutables.github.io/]
> was discussed as an alternative to a custom implementation. This ticket is to
> evaluate the impact to the codebase of changing. Ideally, introduction of
> immutables would both add flexibility and reduce the amount of code
> associated with these classes.
> Immutables works via annotation processor which means that it is should be
> relatively seamless to build systems and IDEs.
> The switch would also make it easier to work with these objects types in the
> context of aot compilation tools like GraalVM.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)