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.delegate;
8   
9   import org.mule.config.spring.parsers.MuleChildDefinitionParser;
10  import org.mule.config.spring.parsers.MuleDefinitionParser;
11  import org.mule.config.spring.parsers.MuleDefinitionParserConfiguration;
12  
13  public class SingleParentFamilyDefinitionParser extends AbstractSingleParentFamilyDefinitionParser
14  {
15  
16      public SingleParentFamilyDefinitionParser(MuleDefinitionParser parent)
17      {
18          // avoid the overriden method here
19          super.addDelegate(parent);
20          parent.setIgnoredDefault(false);
21      }
22  
23      protected MuleDefinitionParserConfiguration addDelegate(MuleDefinitionParser delegate)
24      {
25          throw new UnsupportedOperationException("Delegates must be associated with attribute names");
26      }
27  
28      public SingleParentFamilyDefinitionParser addChildDelegate(String attribute, MuleChildDefinitionParser delegate)
29      {
30          return addChildDelegate(new String[]{attribute}, delegate);
31      }
32  
33      public SingleParentFamilyDefinitionParser addChildDelegate(String[] attributes, MuleChildDefinitionParser delegate)
34      {
35          super.addChildDelegate(delegate);
36          delegate.setIgnoredDefault(true);
37          for (int i = 0; i < attributes.length; i++)
38          {
39              getDelegate(0).addIgnored(attributes[i]);
40              delegate.removeIgnored(attributes[i]);
41          }
42          return this;
43      }
44  
45  }
46