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 org.apache.logging.log4j.Level; 20 import org.apache.logging.log4j.core.config.Configuration; 21 import org.apache.logging.log4j.core.util.Builder; 22 23 /** 24 * Builds arbitrary components and is the base type for the provided components. 25 * @param <T> The ComponentBuilder's own type for fluent APIs. 26 * @since 2.4 27 */ 28 public interface ComponentBuilder<T extends ComponentBuilder<T>> extends Builder<Component> { 29 30 /** 31 * Adds a String attribute. 32 * @param key The attribute key. 33 * @param value The value of the attribute. 34 * @return This ComponentBuilder. 35 */ 36 T addAttribute(String key, String value); 37 38 /** 39 * Adds a logging Level attribute. 40 * @param key The attribute key. 41 * @param level The logging Level. 42 * @return This ComponentBuilder. 43 */ 44 T addAttribute(String key, Level level); 45 46 /** 47 * Adds an enumeration attribute. 48 * @param key The attribute key. 49 * @param value The enumeration. 50 * @return This ComponentBuilder. 51 */ 52 T addAttribute(String key, Enum<?> value); 53 54 /** 55 * Adds an integer attribute. 56 * @param key The attribute key. 57 * @param value The integer value. 58 * @return This ComponentBuilder. 59 */ 60 T addAttribute(String key, int value); 61 62 /** 63 * Adds a boolean attribute. 64 * @param key The attribute key. 65 * @param value The integer value. 66 * @return This ComponentBuilder. 67 */ 68 T addAttribute(String key, boolean value); 69 70 /** 71 * Adds an Object attribute. 72 * @param key The attribute key. 73 * @param value The integer value. 74 * @return This ComponentBuilder. 75 */ 76 T addAttribute(String key, Object value); 77 78 /** 79 * Adds a sub component. 80 * @param builder The Assembler for the subcomponent with all of its attributes and sub-components set. 81 * @return This ComponentBuilder (<em>not</em> the argument). 82 */ 83 T addComponent(ComponentBuilder<?> builder); 84 85 /** 86 * Returns the name of the component, if any. 87 * @return The components name or null if it doesn't have one. 88 */ 89 String getName(); 90 91 /** 92 * Retrieves the ConfigurationBuilder. 93 * @return The ConfigurationBuilder. 94 */ 95 ConfigurationBuilder<? extends Configuration> getBuilder(); 96 }