有什么方法可以与Lombok访问器进行Android绑定吗? [英] Any way to do Android binding with Lombok accessors?

查看:101
本文介绍了有什么方法可以与Lombok访问器进行Android绑定吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始玩Android绑定游戏.标准的(单向)绑定对于与我闲逛的人来说已经足够好了.

I'm starting to play with Android binding. The standard (1-way) binding is to the point of being good enough for the people I hang out with.

但是,我发现没有Could not find accessor错误,我不能使用Lombok访问器.您是否找到了解决此问题的方法,而又不愿手动编写像某种对龙目岛一无所知的野兽那样的吸气剂和吸气剂呢?

However, I find that I can't use Lombok accessors without a Could not find accessor error. Have you found a way around this, shy of manually writing getters and setters like some kind of Lombok-ignorant cavebeast?

@Bindable
@Getter @Setter
private String stringField;

//Must uncomment hand-coded accessors to compile!
//public String getStringField() { return stringField;}
//public void setStringField(String s) { stringField = s;}

为后代,我的原始示例代码使用的是布尔值,这使问题有点模糊:

For posterity, my original sample code was using a boolean, which clouds the issue a little:

    @Bindable 
    @Getter @Setter private boolean showpassword = false;

/*  This only compiles if the handcoded accessors are uncommented.

    public boolean getShowpassword() {
        return showpassword;
    }
    public void setShowpassword(boolean b) {
        showpassword = b;
    }
*/

推荐答案

对于boolean,默认情况下,遵循beanspec的生成的"getter"为isShowpassword.生成的设置者"为setShowPassword.错误消息表明它是找不到的吸气剂".

For boolean, by default the generated "getter" is isShowpassword, following the beanspec. The generated "setter" is setShowPassword. The error message suggests it is the "getter" that cannot be found.

您可以使用配置键来更改此行为.根据文档,如果您在

You can use a configuration key to change this behavior. According to the documentation, if you include the following in lombok.config your program should work without the hand written getter and setter:

lombok.getter.noIsPrefix = true

这篇关于有什么方法可以与Lombok访问器进行Android绑定吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆