forked from D-Net/dnet-hadoop
added check for empty(null) values
This commit is contained in:
parent
457c07a522
commit
a708652093
|
@ -3,6 +3,9 @@ package eu.dnetlib.dhp.oa.graph.clean.authorpids.constraints;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
|
||||
@ConstraintClass("longer")
|
||||
public class LongerThanConstraints implements Serializable, Selection {
|
||||
|
||||
|
@ -12,7 +15,8 @@ public class LongerThanConstraints implements Serializable, Selection {
|
|||
this.param = param;
|
||||
}
|
||||
|
||||
public LongerThanConstraints(){};
|
||||
public LongerThanConstraints() {
|
||||
};
|
||||
|
||||
public String getParam() {
|
||||
return param;
|
||||
|
@ -24,6 +28,10 @@ public class LongerThanConstraints implements Serializable, Selection {
|
|||
|
||||
@Override
|
||||
public boolean apply(String value) {
|
||||
if (StringUtils.isEmpty(value)) {
|
||||
return false;
|
||||
}
|
||||
return value.length() > Integer.valueOf(param);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,12 +3,15 @@ package eu.dnetlib.dhp.oa.graph.clean.authorpids.constraints;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
@ConstraintClass("shorter")
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@ConstraintClass("shorterorequal")
|
||||
public class ShorterThanOrEqualToConstraints implements Serializable, Selection {
|
||||
|
||||
private String param;
|
||||
|
||||
public ShorterThanOrEqualToConstraints(){};
|
||||
public ShorterThanOrEqualToConstraints() {
|
||||
};
|
||||
|
||||
public ShorterThanOrEqualToConstraints(String param) {
|
||||
this.param = param;
|
||||
|
@ -24,6 +27,9 @@ public class ShorterThanOrEqualToConstraints implements Serializable, Selection
|
|||
|
||||
@Override
|
||||
public boolean apply(String value) {
|
||||
if (StringUtils.isEmpty(value))
|
||||
return true;
|
||||
return value.length() <= Integer.valueOf(param);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue