@Test public void throwsExceptionWhenPropertyAnnotationIsAppliedToParameterOtherThanString() throws Exception { when(parameter.getParameterClass()).thenReturn((Class)Object.class); thrown.expect(IllegalArgumentException.class); propertyResolver.resolve(parameter, applicationContext); }
@Override public Object resolve(Parameter parameter, ApplicationContext context) throws Exception { if (parameter.getParameterClass() != String.class) { throw new IllegalArgumentException("Only parameters and fields with string type may be annotated by @Property."); } String param = this.property.value(); Object value = context.getInitialProperties().getProperties().get(param); if (value == null) { return parameter.getDefaultValue(); } return value; }
PropertyResolver implements ParameterResolver<Property> { @Override public Object resolve(Parameter parameter, ApplicationContext context) throws Exception { if (parameter.getParameterClass() != String.class) { throw new IllegalArgumentException("Only parameters and fields with string type may be annotated by @Property."); } String param = this.property.value(); Object value = context.getInitialProperties().getProperties().get(param); if (value == null) { return parameter.getDefaultValue(); } return value; } }
PropertyResolver implements ParameterResolver<Property> { @Override public Object resolve(Parameter parameter, ApplicationContext context) throws Exception { if (parameter.getParameterClass() != String.class) { throw new IllegalArgumentException("Only parameters and fields with string type may be annotated by @Property."); } String param = this.property.value(); Object value = context.getInitialProperties().getProperties().get(param); if (value == null) { return parameter.getDefaultValue(); } return value; } PropertyResolver(Property property); }
PropertyResolver implements ParameterResolver<Property> { @Override public Object resolve(Parameter parameter, ApplicationContext context) throws Exception { if (parameter.getParameterClass() != String.class) { throw new IllegalArgumentException("Only parameters and fields with string type may be annotated by @Property."); } String param = this.property.value(); Object value = context.getInitialProperties().getProperties().get(param); if (value == null) { return parameter.getDefaultValue(); } return value; } PropertyResolver(Property property); @Override Object resolve(Parameter parameter, ApplicationContext context); }
PropertyResolver implements ParameterResolver<Property> { @Override public Object resolve(Parameter parameter, ApplicationContext context) throws Exception { if (parameter.getParameterClass() != String.class) { throw new IllegalArgumentException("Only parameters and fields with string type may be annotated by @Property."); } String param = this.property.value(); Object value = context.getInitialProperties().getProperties().get(param); if (value == null) { return parameter.getDefaultValue(); } return value; } PropertyResolver(Property property); @Override Object resolve(Parameter parameter, ApplicationContext context);  }