Class ServiceHolderImpl<T>

  • Type Parameters:
    T - type of the kept instance.
    All Implemented Interfaces:
    ServiceHolder<T>

    public class ServiceHolderImpl<T>
    extends java.lang.Object
    implements ServiceHolder<T>
    Implementation of the instance keeper which kept the instance of the class from InjectionManager and the other information about this instance.
    • Constructor Summary

      Constructors 
      Constructor Description
      ServiceHolderImpl​(T service, java.lang.Class<T> implementationClass, java.util.Set<java.lang.reflect.Type> contractTypes, int rank)
      Creates a new instance of the service holder which keeps the concrete instance and its additional information.
      ServiceHolderImpl​(T service, java.util.Set<java.lang.reflect.Type> contractTypes)
      Creates a new instance of the service holder which keeps the concrete instance and its additional information.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object o)  
      java.util.Set<java.lang.reflect.Type> getContractTypes()
      Gets all contracts which represents the kept instance.
      java.lang.Class<T> getImplementationClass()
      Gets an implementation class of the instance which is kept in this service holder.
      T getInstance()
      An instance of the service got from InjectionManager.
      int getRank()
      Gets ranking of the kept instance.
      int hashCode()  
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • service

        private final T service
      • implementationClass

        private final java.lang.Class<T> implementationClass
      • contractTypes

        private final java.util.Set<java.lang.reflect.Type> contractTypes
      • rank

        private final int rank
    • Constructor Detail

      • ServiceHolderImpl

        public ServiceHolderImpl​(T service,
                                 java.util.Set<java.lang.reflect.Type> contractTypes)
        Creates a new instance of the service holder which keeps the concrete instance and its additional information.
        Parameters:
        service - service instance kept by this holder.
        contractTypes - types which represent the given instance.
      • ServiceHolderImpl

        public ServiceHolderImpl​(T service,
                                 java.lang.Class<T> implementationClass,
                                 java.util.Set<java.lang.reflect.Type> contractTypes,
                                 int rank)
        Creates a new instance of the service holder which keeps the concrete instance and its additional information.
        Parameters:
        service - service instance kept by this holder.
        implementationClass - implementation class of the given instance.
        contractTypes - types which represent the given instance.
        rank - ranking of the given instance.
    • Method Detail

      • getImplementationClass

        public java.lang.Class<T> getImplementationClass()
        Description copied from interface: ServiceHolder
        Gets an implementation class of the instance which is kept in this service holder.
        Specified by:
        getImplementationClass in interface ServiceHolder<T>
        Returns:
        implementation class of the kept instance.
      • getContractTypes

        public java.util.Set<java.lang.reflect.Type> getContractTypes()
        Description copied from interface: ServiceHolder
        Gets all contracts which represents the kept instance.
        Specified by:
        getContractTypes in interface ServiceHolder<T>
        Returns:
        all contracts.
      • getRank

        public int getRank()
        Description copied from interface: ServiceHolder
        Gets ranking of the kept instance.
        Specified by:
        getRank in interface ServiceHolder<T>
        Returns:
        instance's ranking.
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object