Class OptionalInjectCheck


  • public final class OptionalInjectCheck
    extends java.lang.Object
    Utility methods for validating if an AndroidEntryPoint-annotated class that is also annotated with OptionalInject was injected by Hilt.
    See Also:
    OptionalInject
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean wasInjectedByHilt​(android.app.Service service)
      Returns true if the Service was injected by Hilt.
      static boolean wasInjectedByHilt​(android.content.BroadcastReceiver broadcastReceiver)
      Returns true if the BroadcastReceiver was injected by Hilt.
      static boolean wasInjectedByHilt​(android.view.View view)
      Returns true if the View was injected by Hilt.
      static boolean wasInjectedByHilt​(androidx.activity.ComponentActivity activity)
      Returns true if the Activity was injected by Hilt.
      static boolean wasInjectedByHilt​(androidx.fragment.app.Fragment fragment)
      Returns true if the Fragment was injected by Hilt.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • wasInjectedByHilt

        public static boolean wasInjectedByHilt​(@NonNull
                                                androidx.activity.ComponentActivity activity)
        Returns true if the Activity was injected by Hilt.
        Throws:
        java.lang.IllegalArgumentException - if the given instance is not an AndroidEntryPoint nor is annotated with OptionalInject.
      • wasInjectedByHilt

        public static boolean wasInjectedByHilt​(@NonNull
                                                android.content.BroadcastReceiver broadcastReceiver)
        Returns true if the BroadcastReceiver was injected by Hilt.
        Throws:
        java.lang.IllegalArgumentException - if the given instance is not an AndroidEntryPoint nor is annotated with OptionalInject.
      • wasInjectedByHilt

        public static boolean wasInjectedByHilt​(@NonNull
                                                androidx.fragment.app.Fragment fragment)
        Returns true if the Fragment was injected by Hilt.
        Throws:
        java.lang.IllegalArgumentException - if the given instance is not an AndroidEntryPoint nor is annotated with OptionalInject.
      • wasInjectedByHilt

        public static boolean wasInjectedByHilt​(@NonNull
                                                android.app.Service service)
        Returns true if the Service was injected by Hilt.
        Throws:
        java.lang.IllegalArgumentException - if the given instance is not an AndroidEntryPoint nor is annotated with OptionalInject.
      • wasInjectedByHilt

        public static boolean wasInjectedByHilt​(@NonNull
                                                android.view.View view)
        Returns true if the View was injected by Hilt.
        Throws:
        java.lang.IllegalArgumentException - if the given instance is not an AndroidEntryPoint nor is annotated with OptionalInject.