2015-05-28 13:19:25 +02:00
|
|
|
package org.gcube.accounting.datamodel.validators;
|
|
|
|
|
|
|
|
import org.gcube.common.validator.annotations.FieldValidator;
|
|
|
|
|
2015-06-03 11:57:38 +02:00
|
|
|
public class ValidIntegerValidator implements FieldValidator<ValidLong>{
|
2015-05-28 13:19:25 +02:00
|
|
|
|
2015-06-03 11:57:38 +02:00
|
|
|
public Class<ValidLong> annotation() {
|
|
|
|
return ValidLong.class;
|
2015-05-28 13:19:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isValid(Object toValidate) {
|
2015-06-03 11:57:38 +02:00
|
|
|
if(toValidate instanceof Integer){
|
2015-05-28 13:19:25 +02:00
|
|
|
return true;
|
|
|
|
}
|
2015-06-05 11:06:17 +02:00
|
|
|
Integer integerObj = Integer.getInteger((String) toValidate);
|
|
|
|
if(integerObj!=null){
|
|
|
|
return true;
|
|
|
|
}
|
2015-05-28 13:19:25 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getErrorSuffix() {
|
2015-06-03 11:57:38 +02:00
|
|
|
return String.format("not instace of %s", Integer.class.getSimpleName());
|
2015-05-28 13:19:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|