[英]Supercsv example doesn't compile
This example straight from the docs at http://super-csv.github.io/super-csv/examples_reading.html doesn't compile. 这个示例直接来自http://super-csv.github.io/super-csv/examples_reading.html上的文档,无法编译。 All lines in the new CellProcessor[]{...} generate the error "Incompatible types. Required: CellProcessor Found:org.supercsv.cellprocessor.constraint.UniqueHashCode"
新的CellProcessor [] {...}中的所有行均生成错误“类型不兼容。必需:找到的CellProcessor: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;
}
}
I just tried this in IntelliJ, the only thing wrong is that you are missing the import for CellProcessor
. 我只是在IntelliJ中尝试过,唯一的错误是您缺少
CellProcessor
的导入。
add 加
import org.supercsv.cellprocessor.ift.CellProcessor;
and everything should work. 一切都会正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.