Silk DI 0.6


se.jbee.inject
Class Instance<T>

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

public final class Instance<T>
extends Object
implements Named, Parameter<T>, PreciserThan<Instance<?>>

Used to tell that we don#t want just one singleton at a time but multiple distinguished by the Name used.

Author:
Jan Bernitt (jan@jbee.se)

Field Summary
static Instance<? extends Object> ANY
          When a wildcard-type is used as bound instance type the bind will be added to all concrete binds of matching types.
 
Method Summary
static
<T> Instance<T>
anyOf(Class<T> type)
           
static Instance<?>[] anyOf(Type<?>... types)
           
static
<T> Instance<T>
anyOf(Type<T> type)
           
static
<T> Instance<T>
defaultInstanceOf(Type<T> type)
           
 Instance<T> discriminableBy(Name name)
           
 boolean equalTo(Instance<?> other)
           
 Name getName()
           
 Type<T> getType()
           
static
<T> Instance<T>
instance(Name name, Type<T> type)
           
 boolean isAny()
           
 boolean isAssignableTo(Type<?> type)
           
 boolean morePreciseThan(Instance<?> other)
           
 String toString()
           
<E> Instance<E>
typed(Type<E> type)
           
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ANY

public static final Instance<? extends Object> ANY
When a wildcard-type is used as bound instance type the bind will be added to all concrete binds of matching types. There is also a set of wildcard binds that are tried if no bind has been made for a type.

Method Detail

defaultInstanceOf

public static <T> Instance<T> defaultInstanceOf(Type<T> type)

anyOf

public static <T> Instance<T> anyOf(Class<T> type)

anyOf

public static <T> Instance<T> anyOf(Type<T> type)

anyOf

public static Instance<?>[] anyOf(Type<?>... types)

instance

public static <T> Instance<T> instance(Name name,
                                       Type<T> type)

equalTo

public boolean equalTo(Instance<?> other)

discriminableBy

public Instance<T> discriminableBy(Name name)

getType

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

typed

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

getName

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

toString

public String toString()
Overrides:
toString in class Object

isAny

public boolean isAny()

morePreciseThan

public boolean morePreciseThan(Instance<?> other)
Specified by:
morePreciseThan in interface PreciserThan<Instance<?>>
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.

isAssignableTo

public boolean isAssignableTo(Type<?> type)
Specified by:
isAssignableTo in interface Parameter<T>

Silk DI 0.6