Package net.sf.jguiraffe.di.impl
Class ClassDependency
- java.lang.Object
-
- net.sf.jguiraffe.di.impl.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 Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object obj)
Compares this object with another one.ClassDescription
getDependentClass()
Returns the description of the class of this dependency.static ClassDependency
getInstance(Class<?> cls)
Returns aClassDependency
instance for the specified class.static ClassDependency
getInstance(ClassDescription clsdsc)
Returns aClassDependency
instance for the specifiedClassDescription
.int
hashCode()
Returns a hash code for this object.BeanProvider
resolve(BeanStore store, DependencyProvider depProvider)
Resolves this dependency on the specified bean store.String
toString()
Returns a string representation of this object.
-
-
-
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 interfaceDependency
- Parameters:
store
- the bean store to be searcheddepProvider
- 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.
-
hashCode
public int hashCode()
Returns a hash code for this object.
-
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.
-
getInstance
public static ClassDependency getInstance(Class<?> cls)
Returns aClassDependency
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 aClassDependency
instance for the specifiedClassDescription
.- Parameters:
clsdsc
- the class description- Returns:
- an instance pointing to the specified class
- Throws:
IllegalArgumentException
- if the class description is null
-
-