001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache license, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the license for the specific language governing permissions and 015 * limitations under the license. 016 */ 017package org.apache.logging.log4j.core.config.builder.api; 018 019import org.apache.logging.log4j.Level; 020import org.apache.logging.log4j.core.config.Configuration; 021import org.apache.logging.log4j.core.util.Builder; 022 023/** 024 * Builds arbitrary components and is the base type for the provided components. 025 * @param <T> The ComponentBuilder's own type for fluent APIs. 026 * @since 2.4 027 */ 028public interface ComponentBuilder<T extends ComponentBuilder<T>> extends Builder<Component> { 029 030 /** 031 * Adds a String attribute. 032 * @param key The attribute key. 033 * @param value The value of the attribute. 034 * @return This ComponentBuilder. 035 */ 036 T addAttribute(String key, String value); 037 038 /** 039 * Adds a logging Level attribute. 040 * @param key The attribute key. 041 * @param level The logging Level. 042 * @return This ComponentBuilder. 043 */ 044 T addAttribute(String key, Level level); 045 046 /** 047 * Adds an enumeration attribute. 048 * @param key The attribute key. 049 * @param value The enumeration. 050 * @return This ComponentBuilder. 051 */ 052 T addAttribute(String key, Enum<?> value); 053 054 /** 055 * Adds an integer attribute. 056 * @param key The attribute key. 057 * @param value The integer value. 058 * @return This ComponentBuilder. 059 */ 060 T addAttribute(String key, int value); 061 062 /** 063 * Adds a boolean attribute. 064 * @param key The attribute key. 065 * @param value The boolean value. 066 * @return This ComponentBuilder. 067 */ 068 T addAttribute(String key, boolean value); 069 070 /** 071 * Adds an Object attribute. 072 * @param key The attribute key. 073 * @param value The object value. 074 * @return This ComponentBuilder. 075 */ 076 T addAttribute(String key, Object value); 077 078 /** 079 * Adds a sub component. 080 * @param builder The Assembler for the subcomponent with all of its attributes and sub-components set. 081 * @return This ComponentBuilder (<em>not</em> the argument). 082 */ 083 T addComponent(ComponentBuilder<?> builder); 084 085 /** 086 * Returns the name of the component, if any. 087 * @return The components name or null if it doesn't have one. 088 */ 089 String getName(); 090 091 /** 092 * Retrieves the ConfigurationBuilder. 093 * @return The ConfigurationBuilder. 094 */ 095 ConfigurationBuilder<? extends Configuration> getBuilder(); 096}