private void validateDefaultValue(Pattern validationPattern, ConfigProperty p) throws ConfigBuilderException { if (!validationPattern.matcher(p.defaultValue()).matches()) { throw new ConfigBuilderException( String.format("The default value [%s] did not match the validation pattern [%s], for %s", p.defaultValue(), validationPattern.pattern(), getAnnotationDescription(p) ) ); } }
private ConfigBuilderTypeConverter getConverterFunction(ConfigProperty p, Class javaType) throws ConfigBuilderException { ConfigBuilderTypeConverter f; try { Class<? extends ConfigBuilderTypeConverter> c = p.valueConverter(); f = c.newInstance(); } catch (Exception e) { throw new ConfigBuilderException("Failed to instantiate converter class " + p.valueConverter().getClass().getName() + " for " + getAnnotationDescription(p), e); } return f; }
private Pattern compilePattern(ConfigProperty p) throws ConfigBuilderException { Pattern pattern; try { pattern = Pattern.compile(p.validationPattern()); } catch (PatternSyntaxException e) { throw new ConfigBuilderException("The validation pattern '" + p.validationPattern() + "' could not be compiled, for " + getAnnotationDescription(p)); } return pattern; }
throw new ConfigBuilderException( "A config bean can only annotate a setter method (the method " + method.getName() + " does not start with 'set'), for " + getAnnotationDescription(p)); "The annotated method must take a single argument, for " + getAnnotationDescription(p) ); throw new ConfigBuilderException("Default value \"" + p.defaultValue() + "\" was converted to a type " + defaultValue.getClass().getName() + " which did not match the expected class type " + javaType.getName() + " for " + getAnnotationDescription(p));