MentaContainer

Rev

Blame | Last modification | View Log | RSS feed

package org.mentacontainer;

import java.lang.reflect.Method;

/**
 * A dependency used to setup auto-wiring based on name (target) and type. You also provide the source which is
 * the name of a component configured in the container that will be injected as a dependency.
 *
 * @author sergio.oliveira.jr@gmail.com
 */

public interface Dependency {
       
        /**
         * The target, in other words, the name of the property which depends on something.
         *
         * @return The name of the property that needs to receive a dependency
         */

        public String getTarget();
       
        /**
         * The type, in other words, the type of the property which depends on something.
         *
         * @return The type of the property that needs to receive a dependency
         */

        public Class<? extends Object> getType();
       
        /**
         * The source component that will be used to fulfill the dependency, in other words,
         * a component with this name will be fetched from the container and inserted in the target.
         *
         * @return The name of the component from the container that will fulfill the dependency
         */

        public String getSource();
       
        /**
         * Check whether the given class has this dependency, in other words, whether it has a property
         * with the name <i>'target'</i> and the type <i>'type'</i>.
         *
         * @param targetClass The class to be checked for this dependency
         * @return A method, in this case a setter, that can be used to insert the dependency, or null if the class does not have this dependency
         */

        public Method check(Class<? extends Object> targetClass);
}