Silk DI 0.6


se.jbee.inject
Class Resource<T>

Object
  extended by se.jbee.inject.Resource<T>
All Implemented Interfaces:
Named, PreciserThan<Resource<?>>, Typed<T>

public final class Resource<T>
extends Object
implements Typed<T>, Named, PreciserThan<Resource<?>>

Describes WHAT can be injected and WHERE it can be injected. It is an Instance with added information where the bind applies.

Author:
Jan Bernitt (jan@jbee.se)

Constructor Summary
Resource(Instance<T> instance)
           
Resource(Instance<T> instance, Target target)
           
 
Method Summary
 boolean equalTo(Resource<?> other)
           
 Instance<T> getInstance()
           
 Name getName()
           
 Target getTarget()
           
 Type<T> getType()
           
 boolean isAdequateFor(Dependency<? super T> dependency)
          Does this resource provide the instance wanted by the given Dependency's Name
 boolean isApplicableFor(Dependency<? super T> dependency)
           
 boolean isAssignableTo(Dependency<? super T> dependency)
          Does the Type of this a valid argument for the one of the Dependency given ?
 boolean isAvailableFor(Dependency<? super T> dependency)
          Does the given Dependency occur in the right package and for the right target ?
 boolean isSuitableFor(Dependency<? super T> dependency)
           
 boolean morePreciseThan(Resource<?> other)
           
static
<T> Resource<T>
resource(Class<T> type)
           
 String toString()
           
<E> Resource<E>
typed(Type<E> type)
           
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Resource

public Resource(Instance<T> instance)

Resource

public Resource(Instance<T> instance,
                Target target)
Method Detail

resource

public static <T> Resource<T> resource(Class<T> type)

isApplicableFor

public boolean isApplicableFor(Dependency<? super T> dependency)

isSuitableFor

public boolean isSuitableFor(Dependency<? super T> dependency)

isAssignableTo

public boolean isAssignableTo(Dependency<? super T> dependency)
Does the Type of this a valid argument for the one of the Dependency given ?


isAvailableFor

public boolean isAvailableFor(Dependency<? super T> dependency)
Does the given Dependency occur in the right package and for the right target ?


isAdequateFor

public boolean isAdequateFor(Dependency<? super T> dependency)
Does this resource provide the instance wanted by the given Dependency's Name


getType

public Type<T> getType()
Specified by:
getType in interface Typed<T>
Returns:
The Type of this object.

morePreciseThan

public boolean morePreciseThan(Resource<?> other)
Specified by:
morePreciseThan in interface PreciserThan<Resource<?>>
Returns:
Whether or not this object or more precise than the given one. Equal objects are not more precise! Also objects that have no common context or relationship are never more precise. An example would be that two Types with no common super-type do not define one of them that is more precise.

toString

public String toString()
Overrides:
toString in class Object

getName

public Name getName()
Specified by:
getName in interface Named
Returns:
the name of an Instance / Resource.

getInstance

public Instance<T> getInstance()

getTarget

public Target getTarget()

typed

public <E> Resource<E> typed(Type<E> type)
Specified by:
typed in interface Typed<T>
Returns:
This object with the given Type.

equalTo

public boolean equalTo(Resource<?> other)

Silk DI 0.6