30 lines
641 B
Java
30 lines
641 B
Java
package org.gcube.accounting.datamodel.validators;
|
|
|
|
import java.io.Serializable;
|
|
|
|
import org.gcube.accounting.datamodel.annotations.ValidLong;
|
|
|
|
|
|
public class ValidIntegerValidator implements FieldValidator<ValidLong>{
|
|
|
|
public Class<ValidLong> annotation() {
|
|
return ValidLong.class;
|
|
}
|
|
|
|
public boolean isValid(Serializable toValidate) {
|
|
if(toValidate instanceof Integer){
|
|
return true;
|
|
}
|
|
Integer integerObj = Integer.getInteger((String) toValidate);
|
|
if(integerObj!=null){
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public String getErrorSuffix() {
|
|
return String.format("not instace of %s", Integer.class.getSimpleName());
|
|
}
|
|
|
|
}
|