Uploaded image for project: 'DeltaSpike'
  1. DeltaSpike
  2. DELTASPIKE-1295

Make @ConfigProperty.converter optional when there is only one possible converter for the considered injected type

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • 1.8.0
    • None
    • Configuration
    • None

    Description

      Currently, @ConfigProperty can be used to inject members of types String, Boolean, Class, Integer, Long, Float and Double.

      Other types can be injected as well if a ConfigResolver.Converter<T> class is given in the annotation (@ConfigProperty(name = "...", converter = MyTypeConverter.class)).

      The actual instance of the converter will be resolved through the BeanManager.

      If there exists only one converter for the target type, it should be possible to resolve the instance to be used with beanManager.resolveBean(new ParameterizedTypeImpl(Converter.class, targetType)).

      So you would only need to specify the ConfigProperty.converter attribute:

      • if the field type does not directly match the parameter T in your Converter<T> or
      • if there are more than one eligible converter for that type.

      The logic should be changed to: is a converter specified in the annotation? (!= default value)

      • yes: proceed with that converter
      • no: is the target type one of the default supported types?
        • yes: proceed without converter
        • no: try to resolve the possible unique resolver for that type and use that converter, throw an exception if there are multiple converters for that type

      What do you think?

      Attachments

        Activity

          People

            Unassigned Unassigned
            kalgon Xavier Dury
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: