com.github.skjolber.stcsv.column.bi.BooleanCsvColumnValueConsumer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of databinder Show documentation
Show all versions of databinder Show documentation
High-performance CSV databinding library
package com.github.skjolber.stcsv.column.bi;
public class BooleanCsvColumnValueConsumer implements CsvColumnValueConsumer {
protected final ObjBooleanConsumer setter;
public BooleanCsvColumnValueConsumer(ObjBooleanConsumer setter) {
this.setter = setter;
}
@Override
public void consume(T object, char[] array, int start, int end) {
setter.accept(object,
parseBoolean(array, start, end)
);
}
public static boolean parseBoolean(char[] array, int start, int end) {
return end - start == 4 &&
(array[start] == 't' || array[start] == 'T') &&
(array[++start] == 'r' || array[start] == 'R') &&
(array[++start] == 'u' || array[start] == 'U') &&
(array[++start] == 'e' || array[start] == 'E');
}
}