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 java.io.Serializable;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
|
||||||
@ConstraintClass("longer")
|
@ConstraintClass("longer")
|
||||||
public class LongerThanConstraints implements Serializable, Selection {
|
public class LongerThanConstraints implements Serializable, Selection {
|
||||||
|
|
||||||
|
@ -12,7 +15,8 @@ public class LongerThanConstraints implements Serializable, Selection {
|
||||||
this.param = param;
|
this.param = param;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LongerThanConstraints(){};
|
public LongerThanConstraints() {
|
||||||
|
};
|
||||||
|
|
||||||
public String getParam() {
|
public String getParam() {
|
||||||
return param;
|
return param;
|
||||||
|
@ -24,6 +28,10 @@ public class LongerThanConstraints implements Serializable, Selection {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(String value) {
|
public boolean apply(String value) {
|
||||||
|
if (StringUtils.isEmpty(value)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return value.length() > Integer.valueOf(param);
|
return value.length() > Integer.valueOf(param);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,12 +3,15 @@ package eu.dnetlib.dhp.oa.graph.clean.authorpids.constraints;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
@ConstraintClass("shorter")
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|
||||||
|
@ConstraintClass("shorterorequal")
|
||||||
public class ShorterThanOrEqualToConstraints implements Serializable, Selection {
|
public class ShorterThanOrEqualToConstraints implements Serializable, Selection {
|
||||||
|
|
||||||
private String param;
|
private String param;
|
||||||
|
|
||||||
public ShorterThanOrEqualToConstraints(){};
|
public ShorterThanOrEqualToConstraints() {
|
||||||
|
};
|
||||||
|
|
||||||
public ShorterThanOrEqualToConstraints(String param) {
|
public ShorterThanOrEqualToConstraints(String param) {
|
||||||
this.param = param;
|
this.param = param;
|
||||||
|
@ -24,6 +27,9 @@ public class ShorterThanOrEqualToConstraints implements Serializable, Selection
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(String value) {
|
public boolean apply(String value) {
|
||||||
|
if (StringUtils.isEmpty(value))
|
||||||
|
return true;
|
||||||
return value.length() <= Integer.valueOf(param);
|
return value.length() <= Integer.valueOf(param);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue