add support for class extension and interface in Java generator
See original GitHub issuehi i would like to have the generated java class to extend or implement an interface. the generated class should look something like
package com.acme.ml;
public class MyClassifier implements com.acme.domain.MyInterface {
public double[] getScore(double[] input) {
}
}
notice the need to remove the static
modifier from the method getScore
the need is to have multiple models running via calling the interface.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Generator (Oracle Fusion Middleware Java API Reference for ...
The interface implemented by all Class Generators. A Generator is responsible for generating custom code for specific class types. The Generator is expected ......
Read more >Extending Classes And Interfaces - NativeScript Docs
Learn how NativeScript supports the native Android development scenarios which involve inheriting and extending existing classes or implementing interfaces.
Read more >Java 8 add extension/default method to class - Stack Overflow
Now I have been reading about Java 8's default methods, but as far as I can see, I can only add these to...
Read more >Add extension to force generated classes to implement ...
Fixed for 0.3.7. There is now a new extension property "javaInterfaces" that takes an array of strings, where each string is the fully...
Read more >JavaGenerator (PegaRULES Java Engine v7.4.0 - PUBLIC)
The JavaGenerator interface identifies the code fragments required to specify how a defining Rule- instance is to be implemented.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hey @yarix thank you so much for reporting this as well as for you PR!
Perhaps I’m missing the point but it seems like this functionality is somewhat redundant in
m2cgen
and goes beyond what this library is suppose to do.I’d argue that the manual modification of the generated code is not required either. In OOP world the problem of adapting one interface to another has been long solved by the Adapter (aka Wrapper) design patter.
For example in the application code it’s fairly easy to do the following:
This entity has to be created once and can never be revisited even if the model changes.
Alternatively this can be solved in an even more straightforward way if the
MyInterface
is a SAM (Single Abstract Method) interface and you’re using Java >=8:This is even less verbose.
Given the last example, I don’t see much value in bringing interface support to
m2cgen
.Please let us know what you think!
I’m going to close this issue according to the following statements:
Thanks a lot for using
m2cgen
and for bringing this discussion up!