30 lines
617 B
Java
30 lines
617 B
Java
package org.gcube.accounting.datamodel.validators;
|
|
|
|
import java.io.Serializable;
|
|
|
|
import org.gcube.accounting.datamodel.annotations.ValidLong;
|
|
|
|
|
|
public class ValidLongValidator implements FieldValidator<ValidLong>{
|
|
|
|
public Class<ValidLong> annotation() {
|
|
return ValidLong.class;
|
|
}
|
|
|
|
public boolean isValid(Serializable 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());
|
|
}
|
|
|
|
}
|