title: Hilt Injection in Companion Objects
body: <p>I am new to Hilt/Dagger and I have not found a good example of injecting in a companion object. Here is my singleton and data class below. I am trying to use the TargetNumber manager in the create() function. I am looking for syntax help and explaination of why.</p>
  <pre><code>@InstallIn(SingletonComponent::class)
  @Module
  data class TargetNumberManager(
  val maxNumber: Int = 3, val prefix: String = &quot;ZZ&quot;) : ITargetNumberManager {
  private var currentNumber = 0
  
  @Singleton
  @Provides
  override fun getNextTargetNumber(): String {
      val targetNumberBuilder: StringBuilder = java.lang.StringBuilder()
  
      targetNumberBuilder.append(prefix)
  
      val lengthOfNumber = currentNumber.toString().length
  
      for (i in lengthOfNumber..maxNumber step 1) {
          targetNumberBuilder.append(0)
      }
  
      targetNumberBuilder.append(currentNumber++)
  
      return targetNumberBuilder.toString()
  }
  }
  </code></pre>
  <p>//Data Class</p>
  <pre><code>data class Target(
  @PrimaryKey
  val targetNumber: String,
  val targetType: TargetType?,
  val numOfElement: Int?,
  val location: Coordinate?
  ) : java.io.Serializable {
  
  @AndroidEntryPoint
  companion object {
      fun create(): Target {
          @Inject var targetNumberManager : TargetNumberManager
          val nextNumber = targetNumberManager.getNextTargetNumber()
          return Target(nextNumber, null, null, null)
      }
  }
  </code></pre>
  <p>}</p>