View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.config.spring.parsers.specific.properties;
8   
9   import org.mule.config.spring.parsers.assembly.MapEntryCombiner;
10  import org.mule.config.spring.parsers.generic.ParentDefinitionParser;
11  
12  import org.w3c.dom.Element;
13  
14  /**
15   * This allows a child element to extends a list of values, via an attribute, on a parent setter.
16   * Typically it is used with
17   * {@link org.mule.config.spring.parsers.specific.properties.ElementInNestedMapDefinitionParser}
18   * whose setter is {@link org.mule.config.spring.parsers.assembly.MapEntryCombiner#VALUE}.
19   */
20  public class ListPropertyDefinitionParser extends ParentDefinitionParser
21  {
22  
23      public ListPropertyDefinitionParser(String attribute)
24      {
25          this(MapEntryCombiner.VALUE, attribute);
26      }
27  
28      /**
29       * This method is to explain how things work.  If you need to call it, then you also need to replace
30       * override the class ({#link #getBeanClass}).
31       *
32       * @param setter
33       * @param attribute
34       */
35      protected ListPropertyDefinitionParser(String setter, String attribute)
36      {
37          setIgnoredDefault(true);
38          removeIgnored(attribute);
39          addCollection(attribute);
40          if (!setter.equals(attribute))
41          {
42              addAlias(attribute, setter);
43          }
44      }
45  
46      protected Class getBeanClass(Element element)
47      {
48          return MapEntryCombiner.class;
49      }
50  
51  }