title: Kotlin - attribute visibility to companion object
body: <p>So I have the code below, written in Kotlin.</p>
  
  <p>I'm getting a compilation error on the last instruction line (<code>return params.keys.containsAll(MANDATORY_PARAMS)</code>), the compiler says <code>Unsolved reference: MANDATORY_PARAMS</code>, but I don't really get why.</p>
  
  <p>I thought companion objects were supposed to have some kind of visibility into the attributes of the classes they "keep company to".</p>
  
  <p>What could I do to solve this? How could I make <code>MANDATORY_PARAMS</code> visible to both <code>MandatoryParametersValidator</code> and its companion object?</p>
  
  <p>(disclaimer: this code is being migrated from Java to Kotlin. On Java version, <code>mandatoryParametersHaveBeenProvided</code> used to be a static method on the same class.)</p>
  
  <pre><code>import javax.validation.ConstraintValidator
  import javax.validation.ConstraintValidatorContext
  
  class MandatoryParametersValidator : ConstraintValidator&lt;EnforceMandatoryParameters, Map&lt;String, String&gt;&gt; {
  
      val MANDATORY_PARAMS = arrayOf("bookingReference", "lastName")
  
      override fun initialize(constraintAnnotation: EnforceMandatoryParameters?) {
          // do nothing
      }
  
      override fun isValid(params: Map&lt;String, String&gt;, context: ConstraintValidatorContext?): Boolean {
          MANDATORY_PARAMS
                  .filter { !params.containsKey(it) }
                  .forEach { parameterName -&gt;
                      context?.disableDefaultConstraintViolation()
                      context?.buildConstraintViolationWithTemplate("Mandatory parameter $parameterName is missing.")?.addConstraintViolation()
                  }
  
          return mandatoryParametersHaveBeenProvided(params)
      }
  
      companion object {
          fun mandatoryParametersHaveBeenProvided(params: Map&lt;String, String&gt;) : Boolean {
              return params.keys.containsAll(MANDATORY_PARAMS)
          }
      }
  }
  </code></pre>
  
  <p>Thanks a lot!</p>