avoid issue for empty string while trying to create selection constraints from string
This commit is contained in:
parent
96d253cfb0
commit
74af40afd0
|
@ -6,6 +6,10 @@ import java.util.List;
|
|||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
@JsonAutoDetect
|
||||
public class SelectionCriteria implements Serializable {
|
||||
|
@ -14,7 +18,7 @@ public class SelectionCriteria implements Serializable {
|
|||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 4303936216579280542L;
|
||||
|
||||
private static final Log log = LogFactory.getLog(SelectionCriteria.class);
|
||||
private List<Constraints> criteria;
|
||||
|
||||
public SelectionCriteria() {}
|
||||
|
@ -28,9 +32,13 @@ public class SelectionCriteria implements Serializable {
|
|||
}
|
||||
|
||||
public static SelectionCriteria fromJson(final String json) {
|
||||
if(StringUtils.isEmpty(json)){
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return new ObjectMapper().readValue(json, SelectionCriteria.class);
|
||||
} catch (final JsonProcessingException e) {
|
||||
log.error(e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue