简体   繁体   中英

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.

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

But when I use Wrapper class it works fine. 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

Check this for more details https://www.baeldung.com/lombok-getter-boolean

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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