Usage
@MethodScope
Create a custom scope annotation using @MethodScope
annotation.
@MethodScope
public @interface MyScope {
}
Here is the kotlin code example.
@MethodScope
annotation class MyScope
Attach the custom scope annotation on top of a class.
All of the public methods are the base method for the scoped like the init()
method.
And designate scoping method using @Scoped
annotation with the naming rule what startWith the base method’s name.
@MyScope
public class MyClass {
private String scope;
public void init() { // this is the base method of the scoped methods.
this.scope = “initialized”;
}
@Scoped(MyScope.class)
public void initMyScope() { // this is a scoped method for @MyScope.
this.scope = “initialized by @MyScope”;
}
}
After build the project, MyClass_MyScope
class will be auto-generated.
MyClass_MyScope myClass_myScope = new MyClass_MyScope();
myClass_myScope.init(); // calls init() and initMyScope() methods.
myClass_myScope.initMyScope(); // calls only initMyScope() method.
Multiple Scoping
Here is how to create multiple scoped class.
@MyScope
@HisScope
@YourScope
public class MyClass {
private String scope;
public void init() { // this is the base method of the scoped methods.
this.scope = “initialized”;
}
@Scoped(MyScope.class)
public void initMyScope() { // this is a scoped method for @MyScope.
this.scope = “initialized by @MyScope”;
}
@Scoped(YourScope.class)
public void initMineScopeNotYours() { // this is a scoped method for @YourScope.
this.scope = “initialized by @YourScope”;
}
}
After build the project, MyClass_MyScope
, MyClass_HisScope
, MyClass_YourScope
classes will be auto-generated.
Scoping with a return type and parameters
Methods that have a return type and parameters can be scoped method.
The base method’s return type and parameters are must be the same as the scoped method’s one.
@MyScope
abstract public class MyClass {
private String scope;
public String init(String text) { // this is the base method of the scoped methods.
this.scope += text;
return this.scope;
}
学习分享
在当下这个信息共享的时代,很多资源都可以在网络上找到,只取决于你愿不愿意找或是找的方法对不对了
很多朋友不是没有资料,大多都是有几十上百个G,但是杂乱无章,不知道怎么看从哪看起,甚至是看后就忘
如果大家觉得自己在网上找的资料非常杂乱、不成体系的话,我也分享一套给大家,比较系统,我平常自己也会经常研读。
2021最新上万页的大厂面试真题
七大模块学习资料:如NDK模块开发、Android框架体系架构…
只有系统,有方向的学习,才能在段时间内迅速提高自己的技术。
这份体系学习笔记,适应人群:
**第一,**学习知识比较碎片化,没有合理的学习路线与进阶方向。
**第二,**开发几年,不知道如何进阶更进一步,比较迷茫。
**第三,**到了合适的年纪,后续不知道该如何发展,转型管理,还是加强技术研究。如果你有需要,我这里恰好有为什么,不来领取!说不定能改变你现在的状态呢!
由于文章内容比较多,篇幅不允许,部分未展示内容以截图方式展示 。如有需要获取完整的资料文档的朋友点击我的【GitHub】免费获取。
文档的朋友点击我的【GitHub】免费获取。