All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.opencsv.bean.processor.ConvertEmptyOrBlankStringsToDefault Maven / Gradle / Ivy

There is a newer version: 5.9
Show newest version
package com.opencsv.bean.processor;

/**
 * StringProcessor that converts the empty or blank strings to a desired value string.
 * This is useful when you want a default value.
 * 

* A sample of this can be found in the unit test ProcessorTestBean and is annotated as follows. *

*

 *     @PreAssignmentProcessor(processor = ConvertEmptyOrBlankStringsToDefault.class, paramString = "-1")
 *     @CsvBindByName(column = "id")
 *     private int beanId;
 * 
* * @author Scott Conway * @since 5.4 */ public class ConvertEmptyOrBlankStringsToDefault implements StringProcessor { String defaultValue; /** * Default constructor */ public ConvertEmptyOrBlankStringsToDefault() { } @Override public String processString(String value) { if (value == null || value.trim().isEmpty()) { return defaultValue; } return value; } @Override public void setParameterString(String value) { defaultValue = value; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy