I have an array of String which I will be receiving from an arbitrary function. I want to use the elements of the array to create a new class at runtime (not a new object of an existing class). Let me give you an example
val keyCounts = Array[String]
def newDomainPartioner(keyCounts : Array[Strings]) : DomainPartitioner{
    return class DomainPartitioner with Serializable {
        def getPartition(key: Any): Int = key match {
          case <first element of keyCount> => 
            1
          case <second element of keyCount> =>
            1
          case <third element of keyCount> =>  
            1
          case <forth element of keyCount> => 
            1
          case _ => 0
        }
      }
}
Is there a way to achieve the intended functionality ?
 
     
    