Class OptionalInjectCheck

java.lang.Object
dagger.hilt.android.migration.OptionalInjectCheck

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

    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 Details

    • wasInjectedByHilt

      public static boolean wasInjectedByHilt(@NonNull androidx.activity.ComponentActivity activity)
      Returns true if the Activity was injected by Hilt.
      Throws:
      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:
      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:
      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:
      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:
      IllegalArgumentException - if the given instance is not an AndroidEntryPoint nor is annotated with OptionalInject.