All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.apache.juli.logging.ch.qos.logback.core.joran.util.beans.BeanDescription Maven / Gradle / Ivy

There is a newer version: 9.0.88
Show newest version
package org.apache.juli.logging.ch.qos.logback.core.joran.util.beans;

import java.lang.reflect.Method;
import java.util.Collections;
import java.util.Map;

/**
 * Lightweight pendant to the java.beans.BeanInfo class. An instance of this
 * class encapsulates the properties of a certain class. The properties are the
 * public setters and getters. In addition the 'add-er'-methods are included,
 * which are the public methods which start with the prefix 'add'.
 *
 * @author urechm
 *
 */
public class BeanDescription {

    private final Class clazz;

    private final Map propertyNameToGetter;

    private final Map propertyNameToSetter;

    private final Map propertyNameToAdder;

    /**
     * Scope protected since only the {@link BeanDescriptionFactory} must create
     * BeanDescriptions in order to guarantee consistency between the given
     * parameters.
     *
     * @param clazz                of the bean.
     * @param propertyNameToGetter map of property names to the associated getter.
     * @param propertyNameToSetter map of property names to the associated setter.
     * @param propertyNameToAdder  map of property names to the associated adder.
     */
    protected BeanDescription(Class clazz, Map propertyNameToGetter,
            Map propertyNameToSetter, Map propertyNameToAdder) {
        this.clazz = clazz;
        this.propertyNameToGetter = Collections.unmodifiableMap(propertyNameToGetter);
        this.propertyNameToSetter = Collections.unmodifiableMap(propertyNameToSetter);
        this.propertyNameToAdder = Collections.unmodifiableMap(propertyNameToAdder);
    }

    public Class getClazz() {
        return clazz;
    }

    public Map getPropertyNameToGetter() {
        return propertyNameToGetter;
    }

    public Map getPropertyNameToSetter() {
        return propertyNameToSetter;
    }

    public Method getGetter(String propertyName) {
        return propertyNameToGetter.get(propertyName);
    }

    public Method getSetter(String propertyName) {
        return propertyNameToSetter.get(propertyName);
    }

    public Map getPropertyNameToAdder() {
        return propertyNameToAdder;
    }

    public Method getAdder(String propertyName) {
        return propertyNameToAdder.get(propertyName);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy