
@H_404_8@
例如,这个@H_404_8@
@H_404_8@
@Immutablepublic MyClass { String property1 MyOtherClass property2 List myList} 和@H_404_8@
@H_404_8@
public final MyClass { final String property1 final MyOtherClass property2 final List myList}解决方法 The @Immutable annotation instructs the compiler to execute an AST transformation which adds the necessary getters,constructors,equals,hashCode and other helper methods that are typically written when creating immutable classes with the defined propertIEs.
[1]@H_404_8@
因此,@ Immrange会生成辅助功能,类似于Scala中的“case classes”.
final关键字指示编译器特定变量是不可变的,就像在Java中一样.@H_404_8@
第一个类等同于具有多个辅助函数的第二个类.@H_404_8@
[1] http://groovy.codehaus.org/gapi/groovy/transform/Immutable.html@H_404_8@ 总结
以上是内存溢出为你收集整理的groovy – 不可变和最终之间的区别全部内容,希望文章能够帮你解决groovy – 不可变和最终之间的区别所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)