How to define private getter method in Groovy Bean?

不问归期 提交于 2019-11-28 08:55:01

问题


I used following code.

class Bike{
 def manufacturer;

 private getManufacturer(){
  manufacturer
 }

}

But I was able invoke getter method from another class.


回答1:


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


来源:https://stackoverflow.com/questions/3819794/how-to-define-private-getter-method-in-groovy-bean

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!