    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     */
    017    package org.apache.logging.log4j.core.config.plugins.util;
    018
    019
    020    import org.apache.logging.log4j.core.config.plugins.processor.PluginEntry;
    021
    022    /**
    023     * Plugin Descriptor. This is a memento object for Plugin annotations paired to their annotated classes.
    024     *
    025     * @param <T> The plug-in class, which can be any kind of class.
    026     * @see org.apache.logging.log4j.core.config.plugins.Plugin
    027     */
    028    public class PluginType<T> {
    029
    030        private final PluginEntry pluginEntry;
    031        private final Class<T> pluginClass;
    032        private final String elementName;
    033
    034        /**
    035         * @since 2.1
    036         */
    037        public PluginType(final PluginEntry pluginEntry, final Class<T> pluginClass, final String elementName) {
    038            this.pluginEntry = pluginEntry;
    039            this.pluginClass = pluginClass;
    040            this.elementName = elementName;
    041        }
    042
    043        public Class<T> getPluginClass() {
    044            return this.pluginClass;
    045        }
    046
    047        public String getElementName() {
    048            return this.elementName;
    049        }
    050
    051        /**
    052         * @since 2.1
    053         */
    054        public String getKey() {
    055            return this.pluginEntry.getKey();
    056        }
    057
    058        public boolean isObjectPrintable() {
    059            return this.pluginEntry.isPrintable();
    060        }
    061
    062        public boolean isDeferChildren() {
    063            return this.pluginEntry.isDefer();
    064        }
    065
    066        /**
    067         * @since 2.1
    068         */
    069        public String getCategory() {
    070            return this.pluginEntry.getCategory();
    071        }
    072
    073        @Override
    074        public String toString() {
    075            return "PluginType [pluginClass=" + pluginClass +
    076                    ", key=" + pluginEntry.getKey() +
    077                    ", elementName=" + pluginEntry.getName() +
    078                    ", isObjectPrintable=" + pluginEntry.isPrintable() +
    079                    ", isDeferChildren==" + pluginEntry.isDefer() +
    080                    ", category=" + pluginEntry.getCategory() +
    081                    "]";
    082        }
    083    }