use of org.supercsv.cellprocessor.constraint.Equals in project apex-malhar by apache.
the class CellProcessorBuilder method getDoubleCellProcessor.
/**
* Method to get cellprocessor for Float/Double with constraints. These
* constraints are evaluated against the Float/Double field for which this
* cellprocessor is defined.
*
* @param constraints
* map of constraints applicable to Float/Double
* @return CellProcessor
*/
private static CellProcessor getDoubleCellProcessor(Map<String, Object> constraints) {
Boolean required = constraints.get(DelimitedSchema.REQUIRED) == null ? null : Boolean.parseBoolean((String) constraints.get(DelimitedSchema.REQUIRED));
Double equals = constraints.get(DelimitedSchema.EQUALS) == null ? null : Double.parseDouble((String) constraints.get(DelimitedSchema.EQUALS));
Double minValue = constraints.get(DelimitedSchema.MIN_VALUE) == null ? null : Double.parseDouble((String) constraints.get(DelimitedSchema.MIN_VALUE));
Double maxValue = constraints.get(DelimitedSchema.MAX_VALUE) == null ? null : Double.parseDouble((String) constraints.get(DelimitedSchema.MAX_VALUE));
CellProcessor cellProcessor = null;
if (equals != null) {
cellProcessor = new Equals(equals);
cellProcessor = addParseDouble(cellProcessor);
} else if (minValue != null || maxValue != null) {
cellProcessor = addDoubleMinMax(minValue, maxValue);
} else {
cellProcessor = addParseDouble(null);
}
if (required == null || !required) {
cellProcessor = addOptional(cellProcessor);
}
return cellProcessor;
}
use of org.supercsv.cellprocessor.constraint.Equals in project apex-malhar by apache.
the class CellProcessorBuilder method getLongCellProcessor.
/**
* Method to get cellprocessor for Long with constraints. These constraints
* are evaluated against the Long field for which this cellprocessor is
* defined.
*
* @param constraints
* map of constraints applicable to Long
* @return CellProcessor
*/
private static CellProcessor getLongCellProcessor(Map<String, Object> constraints) {
Boolean required = constraints.get(DelimitedSchema.REQUIRED) == null ? null : Boolean.parseBoolean((String) constraints.get(DelimitedSchema.REQUIRED));
Long equals = constraints.get(DelimitedSchema.EQUALS) == null ? null : Long.parseLong((String) constraints.get(DelimitedSchema.EQUALS));
Long minValue = constraints.get(DelimitedSchema.MIN_VALUE) == null ? null : Long.parseLong((String) constraints.get(DelimitedSchema.MIN_VALUE));
Long maxValue = constraints.get(DelimitedSchema.MAX_VALUE) == null ? null : Long.parseLong((String) constraints.get(DelimitedSchema.MAX_VALUE));
CellProcessor cellProcessor = null;
if (equals != null) {
cellProcessor = new Equals(equals);
cellProcessor = addParseLong(cellProcessor);
} else if (minValue != null || maxValue != null) {
cellProcessor = addLongMinMax(minValue, maxValue);
} else {
cellProcessor = addParseLong(null);
}
if (required == null || !required) {
cellProcessor = addOptional(cellProcessor);
}
return cellProcessor;
}
use of org.supercsv.cellprocessor.constraint.Equals in project apex-malhar by apache.
the class CellProcessorBuilder method getCharCellProcessor.
/**
* Method to get cellprocessor for Char with constraints. These constraints
* are evaluated against the Char field for which this cellprocessor is
* defined.
*
* @param constraints
* map of constraints applicable to Char
* @return CellProcessor
*/
private static CellProcessor getCharCellProcessor(Map<String, Object> constraints) {
Boolean required = constraints.get(DelimitedSchema.REQUIRED) == null ? null : Boolean.parseBoolean((String) constraints.get(DelimitedSchema.REQUIRED));
Character equals = constraints.get(DelimitedSchema.EQUALS) == null ? null : ((String) constraints.get(DelimitedSchema.EQUALS)).charAt(0);
CellProcessor cellProcessor = null;
if (equals != null) {
cellProcessor = new Equals(equals);
}
cellProcessor = addParseChar(cellProcessor);
if (required == null || !required) {
cellProcessor = addOptional(cellProcessor);
}
return cellProcessor;
}
use of org.supercsv.cellprocessor.constraint.Equals in project apex-malhar by apache.
the class CellProcessorBuilder method getIntegerCellProcessor.
/**
* Method to get cellprocessor for Integer with constraints. These constraints
* are evaluated against the Integer field for which this cellprocessor is
* defined.
*
* @param constraints
* map of constraints applicable to Integer
* @return CellProcessor
*/
private static CellProcessor getIntegerCellProcessor(Map<String, Object> constraints) {
Boolean required = constraints.get(DelimitedSchema.REQUIRED) == null ? null : Boolean.parseBoolean((String) constraints.get(DelimitedSchema.REQUIRED));
Integer equals = constraints.get(DelimitedSchema.EQUALS) == null ? null : Integer.parseInt((String) constraints.get(DelimitedSchema.EQUALS));
Integer minValue = constraints.get(DelimitedSchema.MIN_VALUE) == null ? null : Integer.parseInt((String) constraints.get(DelimitedSchema.MIN_VALUE));
Integer maxValue = constraints.get(DelimitedSchema.MAX_VALUE) == null ? null : Integer.parseInt((String) constraints.get(DelimitedSchema.MAX_VALUE));
CellProcessor cellProcessor = null;
if (equals != null) {
cellProcessor = new Equals(equals);
cellProcessor = addParseInt(cellProcessor);
} else if (minValue != null || maxValue != null) {
cellProcessor = addIntMinMax(minValue, maxValue);
} else {
cellProcessor = addParseInt(null);
}
if (required == null || !required) {
cellProcessor = addOptional(cellProcessor);
}
return cellProcessor;
}
use of org.supercsv.cellprocessor.constraint.Equals in project apex-malhar by apache.
the class CellProcessorBuilder method getStringCellProcessor.
/**
* Method to get cellprocessor for String with constraints. These constraints
* are evaluated against the String field for which this cellprocessor is
* defined.
*
* @param constraints
* map of constraints applicable to String
* @return CellProcessor
*/
private static CellProcessor getStringCellProcessor(Map<String, Object> constraints) {
Boolean required = constraints.get(DelimitedSchema.REQUIRED) == null ? null : Boolean.parseBoolean((String) constraints.get(DelimitedSchema.REQUIRED));
Integer strLen = constraints.get(DelimitedSchema.LENGTH) == null ? null : Integer.parseInt((String) constraints.get(DelimitedSchema.LENGTH));
Integer minLength = constraints.get(DelimitedSchema.MIN_LENGTH) == null ? null : Integer.parseInt((String) constraints.get(DelimitedSchema.MIN_LENGTH));
Integer maxLength = constraints.get(DelimitedSchema.MAX_LENGTH) == null ? null : Integer.parseInt((String) constraints.get(DelimitedSchema.MAX_LENGTH));
String equals = constraints.get(DelimitedSchema.EQUALS) == null ? null : (String) constraints.get(DelimitedSchema.EQUALS);
String pattern = constraints.get(DelimitedSchema.REGEX_PATTERN) == null ? null : (String) constraints.get(DelimitedSchema.REGEX_PATTERN);
CellProcessor cellProcessor = null;
if (StringUtils.isNotBlank(equals)) {
cellProcessor = new Equals(equals);
} else if (StringUtils.isNotBlank(pattern)) {
cellProcessor = new StrRegEx(pattern);
} else if (strLen != null) {
cellProcessor = new Strlen(strLen);
} else if (maxLength != null || minLength != null) {
Long min = minLength == null ? 0L : minLength;
Long max = maxLength == null ? LMinMax.MAX_LONG : maxLength;
cellProcessor = new StrMinMax(min, max);
}
if (required == null || !required) {
cellProcessor = addOptional(cellProcessor);
}
return cellProcessor;
}
Aggregations