Coverage Report - org.mule.config.spring.parsers.specific.properties.NestedListDefinitionParser
 
Classes in this File Line Coverage Branch Coverage Complexity
NestedListDefinitionParser
0%
0/4
N/A
1
 
 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.AbstractMuleBeanDefinitionParser;
 10  
 import org.mule.config.spring.parsers.assembly.MapEntryCombiner;
 11  
 import org.mule.config.spring.parsers.collection.ChildListEntryDefinitionParser;
 12  
 import org.mule.config.spring.parsers.collection.ChildSingletonMapDefinitionParser;
 13  
 import org.mule.config.spring.parsers.delegate.AbstractSingleParentFamilyDefinitionParser;
 14  
 import org.mule.config.spring.parsers.processors.AddAttribute;
 15  
 
 16  
 /**
 17  
  * This extends a list that is itself a property (with key mapKey).  It does not have any
 18  
  * container element.
 19  
  *
 20  
  * This could also be achieved with
 21  
  * new ChildSingletonMapDefinitionParser("properties")
 22  
  * .registerPreProcessor(new AddAttribute(MapEntryCombiner.KEY, "soap11Transports"))
 23  
  * .addCollection(MapEntryCombiner.VALUE)
 24  
  * .addCollection("properties");
 25  
  * I think, but the following avoids worries about special attribute names.
 26  
  */
 27  
 public class NestedListDefinitionParser extends AbstractSingleParentFamilyDefinitionParser
 28  
 {
 29  
 
 30  
     // we use this so that they can be used as the attribute name!
 31  
     public static final String HIDDEN_KEY = "hiddenKey";
 32  
     public static final String HIDDEN_VALUE = "hiddenValue";
 33  
 
 34  
     public NestedListDefinitionParser(String mapSetter, String mapKey, String attribute)
 35  0
     {
 36  0
         addDelegate(new ChildSingletonMapDefinitionParser(mapSetter))
 37  
                 .registerPreProcessor(new AddAttribute(HIDDEN_KEY, mapKey))
 38  
                 .addCollection(mapSetter)
 39  
                 .setIgnoredDefault(true)
 40  
                 .addAlias(HIDDEN_KEY, MapEntryCombiner.KEY)
 41  
                 .removeIgnored(HIDDEN_KEY)
 42  
                 .addIgnored(AbstractMuleBeanDefinitionParser.ATTRIBUTE_NAME);
 43  0
         addChildDelegate(new ChildListEntryDefinitionParser(HIDDEN_VALUE, attribute))
 44  
                 .addAlias(HIDDEN_VALUE, MapEntryCombiner.VALUE)
 45  
                 .addCollection(HIDDEN_VALUE);
 46  0
     }
 47  
 
 48  
 }