27 lines
581 B
Java
27 lines
581 B
Java
package org.gcube.accounting.datamodel.validators;
|
|
|
|
import org.gcube.common.validator.annotations.FieldValidator;
|
|
|
|
public class ValidLongValidator implements FieldValidator<ValidLong>{
|
|
|
|
public Class<ValidLong> annotation() {
|
|
return ValidLong.class;
|
|
}
|
|
|
|
public boolean isValid(Object toValidate) {
|
|
if(toValidate instanceof Long){
|
|
return true;
|
|
}
|
|
Long longObj = Long.getLong((String) toValidate);
|
|
if(longObj!=null){
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public String getErrorSuffix() {
|
|
return String.format("not instace of %s", Long.class.getSimpleName());
|
|
}
|
|
|
|
}
|