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.annotation.JsonAutoDetect;
|
||||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
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
|
@JsonAutoDetect
|
||||||
public class SelectionCriteria implements Serializable {
|
public class SelectionCriteria implements Serializable {
|
||||||
|
@ -14,7 +18,7 @@ public class SelectionCriteria implements Serializable {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private static final long serialVersionUID = 4303936216579280542L;
|
private static final long serialVersionUID = 4303936216579280542L;
|
||||||
|
private static final Log log = LogFactory.getLog(SelectionCriteria.class);
|
||||||
private List<Constraints> criteria;
|
private List<Constraints> criteria;
|
||||||
|
|
||||||
public SelectionCriteria() {}
|
public SelectionCriteria() {}
|
||||||
|
@ -28,9 +32,13 @@ public class SelectionCriteria implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SelectionCriteria fromJson(final String json) {
|
public static SelectionCriteria fromJson(final String json) {
|
||||||
|
if(StringUtils.isEmpty(json)){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
return new ObjectMapper().readValue(json, SelectionCriteria.class);
|
return new ObjectMapper().readValue(json, SelectionCriteria.class);
|
||||||
} catch (final JsonProcessingException e) {
|
} catch (final JsonProcessingException e) {
|
||||||
|
log.error(e.getMessage());
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue