[
https://issues.apache.org/jira/browse/THRIFT-297?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12669045#action_12669045
]
Bryan Duxbury commented on THRIFT-297:
--------------------------------------
Yes, I can see how this would be really useful. However, there are some
barriers. Currently, non-beans generated code doesn't contain the abstract
getter and setter. This is because the internal implementation of those methods
rely on beans-generated getters and setters for simplicity. As a result, we
can't make getFieldValue and setFieldValue abstract on TBase, because non-beans
code wouldn't meet that interface.
We could do one of a few things. One approach would be to always generate the
generic getters and setters, but in non-beans mode, just throw
UnsupportedOperationExceptions. This would suck a bit, because then it's only a
part-time interface.
We could also always define the generic accesors, but have different code paths
internally depending on beans and non-beans mode. This would be kind of ugly
and verbose, so I don't really prefer this approach.
Another approach would be to always generate the beans-style getters and
setters, whether or not we're in beans mode. That would essentially make
beans/non-beans into private/public members, and that's it. This would let
existing code continue to work the way it does, but allow us to extend the
TBase interface nicely.
Finally, an option I've suggested before to pretty tepid acceptance is doing
away with non-beans altogether. I think a very valid argument could be made
that non-beans generated code is at best a partial implementation of the Thrift
functionality, and isn't the best face to put forward. While we're still
pre-release, this would be a much easier change to make, and it would slim down
the complexity of the Java code generator quite noticeably.
> getFieldValue and setFieldValue should be abstract TBase methods
> ----------------------------------------------------------------
>
> Key: THRIFT-297
> URL: https://issues.apache.org/jira/browse/THRIFT-297
> Project: Thrift
> Issue Type: Improvement
> Components: Compiler (Java), Library (Java)
> Reporter: Nathan Marz
>
> Since these methods can be called on every TBase instance, they should be
> part of the TBase API. These methods are useful in conjunction with the meta
> data features.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.