我有带有标准 bean 约定的 wsimport-ed 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 更好。有什么方法可以将这些类视为属性(property)持有者吗?
最佳答案
此问题在 M13 之前缺失,现已在 M13 中修复,请参阅 Youtrack
关于kotlin - 从 Kotlin 访问 Java bean 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31647854/