#1370 avoid errors when Joda is not on classpath

This commit is contained in:
sjaakd 2018-03-30 21:44:18 +02:00
parent 2d8af2960b
commit e368b34ea4
2 changed files with 8 additions and 0 deletions

View File

@ -154,6 +154,9 @@ final class DateFormatValidatorFactory {
catch ( InvocationTargetException e ) { catch ( InvocationTargetException e ) {
return invalidDateFormat( dateFormat, e.getCause() ); return invalidDateFormat( dateFormat, e.getCause() );
} }
catch ( ClassNotFoundException e ) {
return noJodaOnClassPath();
}
catch ( Exception e ) { catch ( Exception e ) {
return invalidDateFormat( dateFormat, e ); return invalidDateFormat( dateFormat, e );
} }
@ -185,4 +188,8 @@ final class DateFormatValidatorFactory {
private static DateFormatValidationResult invalidDateFormat(String dateFormat, Throwable e) { private static DateFormatValidationResult invalidDateFormat(String dateFormat, Throwable e) {
return new DateFormatValidationResult( false, Message.GENERAL_INVALID_DATE, dateFormat, e.getMessage() ); return new DateFormatValidationResult( false, Message.GENERAL_INVALID_DATE, dateFormat, e.getMessage() );
} }
private static DateFormatValidationResult noJodaOnClassPath() {
return new DateFormatValidationResult( false, Message.GENERAL_JODA_NOT_ON_CLASSPATH );
}
} }

View File

@ -95,6 +95,7 @@ public enum Message {
GENERAL_UNSUPPORTED_DATE_FORMAT_CHECK( "No dateFormat check is supported for types %s, %s" ), GENERAL_UNSUPPORTED_DATE_FORMAT_CHECK( "No dateFormat check is supported for types %s, %s" ),
GENERAL_VALID_DATE( "Given date format \"%s\" is valid.", Diagnostic.Kind.NOTE ), GENERAL_VALID_DATE( "Given date format \"%s\" is valid.", Diagnostic.Kind.NOTE ),
GENERAL_INVALID_DATE( "Given date format \"%s\" is invalid. Message: \"%s\"." ), GENERAL_INVALID_DATE( "Given date format \"%s\" is invalid. Message: \"%s\"." ),
GENERAL_JODA_NOT_ON_CLASSPATH( "Cannot validate Joda dateformat, no Joda on classpath. Consider adding Joda to the annotation processorpath.", Diagnostic.Kind.WARNING ),
GENERAL_NOT_ALL_FORGED_CREATED( "Internal Error in creation of Forged Methods, it was expected all Forged Methods to finished with creation, but %s did not" ), GENERAL_NOT_ALL_FORGED_CREATED( "Internal Error in creation of Forged Methods, it was expected all Forged Methods to finished with creation, but %s did not" ),
GENERAL_NO_SUITABLE_CONSTRUCTOR( "%s does not have an accessible parameterless constructor." ), GENERAL_NO_SUITABLE_CONSTRUCTOR( "%s does not have an accessible parameterless constructor." ),