Commons Configuration
  1. Commons Configuration
  2. CONFIGURATION-117

[configuration] MapConfiguration doesn't support multiple-valued properties

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.1
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:

      Operating System: other
      Platform: Other

      Description

      The MapConfiguration addPropertyDirect method does not support multiple-valued properties. The following implementation is what I used to fix the problem.

      protected void addPropertyDirect(String key, Object obj) {
      Object currentValue = getProperty(key);
      if (currentValue == null)

      { getMap().put(key, obj); }

      else if (List.class.isAssignableFrom(currentValue.getClass()))

      { ((List) currentValue).add(obj); }

      else

      { List values = new ArrayList(); values.add(currentValue); values.add(obj); getMap().put(key, values); }

      }

        Activity

        Hide
        Emmanuel Bourg added a comment -

        Thank you Steve, it's now fixed.

        Show
        Emmanuel Bourg added a comment - Thank you Steve, it's now fixed.

          People

          • Assignee:
            Unassigned
            Reporter:
            Steve Bate
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development