Comments (1)
My current idea is this:
class A {
public void test() {}
}
@NMS
class B extends A {
protected void _myTest() {
}
@NMSMethod("test")
public void myTest() {
this._myTest();
}
}
//Generated
class B$NMS extends B {
@Override
protected void _myTest() {
super.test();
}
@Override
public void test() {
this.myTest();
}
}
The user would have to provide an empty method with the same signature and same name (just prefixed with an underscore) that will be overridden by the NMS wrapper implementation to call the original method.
The upsides of this solution is that the class can still be used without the generated NMS wrapper and everything is perfectly visible to the user.
The downside is that you have to have another method inside your class that just clutters it up.
The alternative would be that the user needs to define an interface with all the methods he wants to use to override others (here: myTest
) and, like my other solution, another method with the same signature and name, again prefixed, for the original method. The user would only implement the former and therefor would make the class abstract. The processor would then generate a subclass and implement the missing method for the super call. But this seems to be less usable because you now have an abstract class that you cannot directly instantiate and you have another interface that you need to update.
An unlikely, but possible, solution would be to do something similar to lombok by adding the method at compile time to the existing class (i.e. the class from the user, so B
in the above example). But this would require way more work to get done for, in my eyes, little gain.
from nmsmapper.
Related Issues (3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nmsmapper.