0

I have the following enum, trait and a class.

enum FileFormat {
    V2, V3
}

trait FileSet {
    int fileSetId
    List<DataFile> srcFiles = Collections.emptyList()
    boolean header = false
    boolean mixedPack = false
    FileFormat format

    List<String> getSrcFileNames() {
        srcFiles.collect { it -> it.getSrcFileName() }
    }

    int getFileCount() {
        srcFiles.size()
    }

    abstract boolean isValid()

    def addFile(HeaderFileType hdrType) {
        def f = DataFile()
    }
}

@Builder(builderMethodName = "builder", buildMethodName = "build", prefix = "with", excludes = "srcFileNames, valid, fileCount")
class VolumeFileSet implements FileSet {

    @Override
    boolean isValid() {
        //TODO implement based on VolumeFileSet validation rules
        return true
    }
}

When I try to use builder to set the format enum, I am getting the error

groovy.lang.MissingMethodException: No signature of method: static com.tccc.bia.testdrive.nsr.VolumeFileSet.witFormat() is applicable for argument types: (com.tccc.bia.testdrive.nsr.FileFormat) values: [V3]
Possible solutions: setFormat(com.tccc.bia.testdrive.nsr.FileFormat), getFormat()

Here is the test

class TestSpec extends Specification {

    def setupSpec() {
        def volumeFileSet = VolumeFileSet
                .builder()
                .withHeader(true)
                .withMixedPack(true)
                .witFormat(FileFormat.V3) //ERROR here
                .build()
    }
}
0

1 Answer 1

1

You misspelled the method name.

It should be withFormat(FileFormat.V3), not witFormat.

When corrected, the code compiles and runs just fine.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.