从Kotlin访问JavaBean属性
我使用标准bean约定导入了WSED Java类:从Kotlin访问JavaBean属性,kotlin,Kotlin,我使用标准bean约定导入了WSED Java类: public class Request { protected String vin; public String getVin() { return vin; } public void setVin(String value) { this.vin = value; } } 我希望在Kotlin中使用nice属性语法使用此类: override fun sear
public class Request {
protected String vin;
public String getVin() {
return vin;
}
public void setVin(String value) {
this.vin = value;
}
}
我希望在Kotlin中使用nice属性语法使用此类:
override fun search(request: Request): Response {
log.info("search(vin={})", request.vin);
...
但此代码不编译:
Error:(59, 64) Kotlin: Cannot access 'vin': it is 'protected/*protected and package*/' in 'SmvSearchRequest'
request.getVin()
当然可以工作,但这看起来并不比Java好。有没有办法将这些类视为属性持有者?这是M13之前缺少的,现在已在M13中修复,请参见这不是一个真正的bug。更新:引用的问题(KT-400)已经解决,问题中的代码现在应该可以正常工作了。你能更新一下答案吗。