从Kotlin访问Java bean属性
我使用标准bean约定来管理Java类:
public class Request { protected String vin; public String getVin() { return vin; } public void setVin(String value) { this.vin = value; } }
我希望使用好的属性语法在Kotlin中使用这个类:
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,见Youtrack