Class ClassDependency

  • All Implemented Interfaces:
    Dependency

    public final class ClassDependency
    extends Object
    implements Dependency

    An implementation of the Dependency interface that allows to define a dependency based on a bean class.

    Version:
    $Id: ClassDependency.java 205 2012-01-29 18:29:57Z oheger $
    Author:
    Oliver Heger
    • Method Detail

      • getDependentClass

        public ClassDescription getDependentClass()
        Returns the description of the class of this dependency.
        Returns:
        the class of this dependency
      • resolve

        public BeanProvider resolve​(BeanStore store,
                                    DependencyProvider depProvider)
        Resolves this dependency on the specified bean store. This implementation iterates over the beans defined in the store. If a bean provider is found whose bean class is either the same or a sub class of the class defined in this dependency, it is returned. Otherwise the parent bean store will be searched recursively.
        Specified by:
        resolve in interface Dependency
        Parameters:
        store - the bean store to be searched
        depProvider - the dependency provider
        Returns:
        the found bean provider
        Throws:
        InjectionException - if no fitting bean provider can be found
      • equals

        public boolean equals​(Object obj)
        Compares this object with another one. Two class dependencies are considered equal if and only if they refer to the same class.
        Overrides:
        equals in class Object
        Parameters:
        obj - the object to compare to
        Returns:
        a flag whether the objects are equal
      • hashCode

        public int hashCode()
        Returns a hash code for this object.
        Overrides:
        hashCode in class Object
        Returns:
        a hash code
      • toString

        public String toString()
        Returns a string representation of this object. This string will contain the name of the class referred to by this dependency.
        Overrides:
        toString in class Object
        Returns:
        a string for this object
      • getInstance

        public static ClassDependency getInstance​(Class<?> cls)
        Returns a ClassDependency instance for the specified class.
        Parameters:
        cls - the class of the dependency (must not be null)
        Returns:
        an instance pointing to the specified class
        Throws:
        IllegalArgumentException - if the class is null
      • getInstance

        public static ClassDependency getInstance​(ClassDescription clsdsc)
        Returns a ClassDependency instance for the specified ClassDescription.
        Parameters:
        clsdsc - the class description
        Returns:
        an instance pointing to the specified class
        Throws:
        IllegalArgumentException - if the class description is null