1

This example straight from the docs at http://super-csv.github.io/super-csv/examples_reading.html doesn't compile. All lines in the new CellProcessor[]{...} generate the error "Incompatible types. Required: CellProcessor Found:org.supercsv.cellprocessor.constraint.UniqueHashCode"

What am I missing?

import org.supercsv.cellprocessor.Optional;
import org.supercsv.cellprocessor.ParseBool;
import org.supercsv.cellprocessor.ParseDate;
import org.supercsv.cellprocessor.ParseInt;
import org.supercsv.cellprocessor.constraint.LMinMax;
import org.supercsv.cellprocessor.constraint.NotNull;
import org.supercsv.cellprocessor.constraint.StrRegEx;
import org.supercsv.cellprocessor.constraint.UniqueHashCode;

public class Foo {


    private static CellProcessor[] getProcessors() {

        final String emailRegex = "[a-z0-9\\._]+@[a-z0-9\\.]+"; // just an example, not very robust!
        StrRegEx.registerMessage(emailRegex, "must be a valid email address");

        final CellProcessor[] processors = new CellProcessor[] {
                new UniqueHashCode(), // customerNo (must be unique)
                new NotNull(), // firstName
                new NotNull(), // lastName
                new ParseDate("dd/MM/yyyy"), // birthDate
                new NotNull(), // mailingAddress
                new Optional(new ParseBool()), // married
                new Optional(new ParseInt()), // numberOfKids
                new NotNull(), // favouriteQuote
                new StrRegEx(emailRegex), // email
                new LMinMax(0L, LMinMax.MAX_LONG) // loyaltyPoints
        };

        return processors;
    }

}
fred
  • 1,812
  • 3
  • 37
  • 57

1 Answers1

1

I just tried this in IntelliJ, the only thing wrong is that you are missing the import for CellProcessor.

add

import org.supercsv.cellprocessor.ift.CellProcessor;

and everything should work.

Epicblood
  • 1,167
  • 2
  • 10
  • 29
  • 1
    Thanks. I may be an idiot but I'll still just mention how important it can be to, where applicable, include all imports in docs and examples. – fred Jul 30 '15 at 23:41
  • 1
    Yeah I don't usually put imports in examples because they take up too much space. But you'll notice that there's a [link to the full source](http://super-csv.github.io/super-csv/xref-test/org/supercsv/example/Reading.html) of those examples at the top of page. – James Bassett Jul 31 '15 at 11:18