All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.squareup.inject.assisted.processor.NamedKey.kt Maven / Gradle / Ivy

There is a newer version: 0.8.1
Show newest version
package com.squareup.inject.assisted.processor

import javax.lang.model.element.VariableElement
import javax.lang.model.type.TypeMirror

private val namedKeyComparator = compareBy({ it.key }, { it.name })

/** Represents a [Key] associated with a name. */
data class NamedKey(
  val key: Key,
  val name: String
) : Comparable {
  override fun toString() = "$key $name"
  override fun compareTo(other: NamedKey) = namedKeyComparator.compare(this, other)
}

/** Create a [NamedKey] from this type, any qualifier annotation, and the name. */
fun VariableElement.asNamedKey(mirror: TypeMirror = asType()) = NamedKey(asKey(mirror), simpleName.toString())




© 2015 - 2024 Weber Informatics LLC | Privacy Policy