Class NameDependency

  • All Implemented Interfaces:
    Dependency

    public final class NameDependency
    extends Object
    implements Dependency

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

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

      • getName

        public String getName()
        Returns the name of the dependent bean.
        Returns:
        the name of the bean this dependency refers to
      • resolve

        public BeanProvider resolve​(BeanStore store,
                                    DependencyProvider depProvider)
        Resolves the named dependency from the specified bean store. This is done recursively for the bean store's parent if necessary.
        Specified by:
        resolve in interface Dependency
        Parameters:
        store - the bean store
        depProvider - the dependency provider (not used here)
        Returns:
        the found bean provider
        Throws:
        InjectionException - if the provider cannot be resolved
      • equals

        public boolean equals​(Object obj)
        Tests whether this object equals another one. Two objects of this class are considered equal if and only if they refer to the same dependent bean.
        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 especially contains the name of the bean this dependency is about.
        Overrides:
        toString in class Object
        Returns:
        a string for this object
      • getInstance

        public static NameDependency getInstance​(String name)
        Returns an instance of this class for the bean with the specified name.
        Parameters:
        name - the name of the dependent bean
        Returns:
        an instance referring to the specified dependent bean