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.processors;
8   
9   import org.mule.config.spring.parsers.assembly.configuration.PropertyConfiguration;
10  
11  import org.w3c.dom.Element;
12  
13  /**
14   * All attributes from at least one set must be provided when there are no child
15   * elements with the name specified present.
16   */
17  public class CheckRequiredAttributesWhenNoChildren extends CheckRequiredAttributes
18  {
19      private String elementName;
20  
21      public CheckRequiredAttributesWhenNoChildren(String[][] attributeNames, String elementName)
22      {
23          super(attributeNames);
24          this.elementName = elementName;
25      }
26  
27      public void preProcess(PropertyConfiguration config, Element element)
28      {
29          // If there are child elements we skip this check
30          if (element.getElementsByTagName(elementName).getLength() > 0)
31          {
32              return;
33          }
34          super.preProcess(config, element);
35      }
36  }