简体   繁体   English

包装布尔值 VS 原始布尔值

[英]Wrapper Boolean VS Primitive boolean

I am using Lombok.我正在使用龙目岛。

This is how my Metadata file looks like.这就是我的元数据文件的样子。

package com.some.test.check.meta;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

@NoArgsConstructor
@AllArgsConstructor
@Getter
public class CSVSourceProbeMetaData {
    private boolean backupEnabled;
    private String streamingDir;
    private String filePattern;
}

But when I try to access backupEnabled from here in the class file, it doesn't give me suggestions and it is red.但是当我尝试从类文件中的此处访问backupEnabled ,它没有给我建议并且它是红色的。

public Object execute() {
        boolean backupEnabled = csvSourceProbeMetaData.get_______();
        String streamingDir = csvSourceProbeMetaData.getStreamingDir();

But when I use Wrapper class it works fine.但是当我使用 Wrapper 类时它工作正常。 Is this because I cannot use primitive boolean here or any other reason?这是因为我不能在这里使用原始布尔值还是其他任何原因?

The getter method name for boolean will start with is not get so try isBackupEnabled this will work with you布尔值的 getter 方法名称将以不是 get 开头,因此请尝试 isBackupEnabled 这将与您一起使用

Check this for more details https://www.baeldung.com/lombok-getter-boolean查看更多详细信息https://www.baeldung.com/lombok-getter-boolean

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM