如何在Groovy Bean中定义私有getter方法? [英] How to define private getter method in Groovy Bean?
本文介绍了如何在Groovy Bean中定义私有getter方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
class Bike {
def制造商;
私人getManufacturer(){
制造商
}
}
但是我可以从另一个类中调用getter方法。
解决方案
t使用私人
修饰符。这是预定用于Groovy 2.0 我相信
相关问题:
I used following code.
class Bike{
def manufacturer;
private getManufacturer(){
manufacturer
}
}
But I was able invoke getter method from another class.
解决方案
You can't using the private
modifier. This is scheduled for Groovy 2.0 I believe
Related questions:
- groovy call private method in Java super class
- Groovy Parent/Child Private Field Access Weirdness With Closure
这篇关于如何在Groovy Bean中定义私有getter方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文