View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements. See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache license, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License. You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the license for the specific language governing permissions and
15   * limitations under the license.
16   */
17  package org.apache.logging.log4j.core.config.builder.api;
18  
19  import java.util.ArrayList;
20  import java.util.LinkedHashMap;
21  import java.util.List;
22  import java.util.Map;
23  
24  /**
25   * Container for building Configurations. This class is not normally directly manipulated by users
26   * of the Assembler API.
27   * @since 2.4
28   */
29  public class Component {
30  
31      private final Map<String, String> attributes = new LinkedHashMap<>();
32      private final List<Component> components = new ArrayList<>();
33      private final String pluginType;
34      private final String value;
35  
36      public Component(final String pluginType) {
37          this(pluginType, null, null);
38      }
39  
40      public Component(final String pluginType, final String name) {
41          this(pluginType, name, null);
42      }
43  
44      public Component(final String pluginType, final String name, final String value) {
45          this.pluginType = pluginType;
46          this.value = value;
47          if (name != null && name.length() > 0) {
48              attributes.put("name", name);
49          }
50      }
51  
52      public Component() {
53          this.pluginType = null;
54          this.value = null;
55      }
56  
57  
58      public String addAttribute(final String key, final String newValue) {
59          return attributes.put(key, newValue);
60      }
61  
62      public void addComponent(final Component component) {
63          components.add(component);
64      }
65  
66      public Map<String, String> getAttributes() {
67          return attributes;
68      }
69  
70      public List<Component> getComponents() {
71          return components;
72      }
73  
74      public String getPluginType() {
75          return pluginType;
76      }
77  
78      public String getValue() {
79          return value;
80      }
81   }