java.lang.Object
io.github.sugarcubes.cloner.enhancement.LanguageInfo

public final class LanguageInfo extends Object
What a class file tells about Kotlin and Scala: the kind of the class from kotlin.Metadata, the static final fields holding instances of classes, among them the instance of a Kotlin object (INSTANCE) or of a Scala object (MODULE$), and the enclosing class. The same facts by which the cloner recognizes singletons at runtime (io.github.sugarcubes.cloner.engine.LanguageTypes), read from bytecode.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Kind of kotlin.Metadata for classes, the default value of k.
    static final LanguageInfo
    Neither a Kotlin class nor a Scala object.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Returns the kind of kotlin.Metadata: 1 for classes, including objects, other values for file facades and synthetic classes, which have no instances.
    Returns the enclosing class.
    boolean
    Tells whether the class has a static final field of the type: the type is its companion object.
    boolean
    Tells whether the class holds its instance in public static final INSTANCE: a Kotlin object, if the class is a Kotlin one.
    boolean
    Tells whether the class file carries kotlin.Metadata.
    boolean
    Tells whether the class holds its instance in static final MODULE$: a Scala object.
    of(ClassStructure structure)
    Returns the information of the structure of a class file.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • NONE

      public static final LanguageInfo NONE
      Neither a Kotlin class nor a Scala object.
    • CLASS_KIND

      public static final int CLASS_KIND
      Kind of kotlin.Metadata for classes, the default value of k.
      See Also:
  • Method Details

    • isKotlin

      public boolean isKotlin()
      Tells whether the class file carries kotlin.Metadata.
      Returns:
      true for Kotlin classes
    • getKind

      public int getKind()
      Returns the kind of kotlin.Metadata: 1 for classes, including objects, other values for file facades and synthetic classes, which have no instances.
      Returns:
      kind, 0 for other classes
    • holdsItself

      public boolean holdsItself()
      Tells whether the class holds its instance in public static final INSTANCE: a Kotlin object, if the class is a Kotlin one.
      Returns:
      true for an object
    • isScalaObject

      public boolean isScalaObject()
      Tells whether the class holds its instance in static final MODULE$: a Scala object.
      Returns:
      true for a Scala object
    • holdsConstantOf

      public boolean holdsConstantOf(String type)
      Tells whether the class has a static final field of the type: the type is its companion object.
      Parameters:
      type - internal name of the type
      Returns:
      true if the class holds a constant of the type
    • getOuter

      public String getOuter()
      Returns the enclosing class.
      Returns:
      internal name or null for a top level class
    • of

      public static LanguageInfo of(ClassStructure structure)
      Returns the information of the structure of a class file.
      Parameters:
      structure - structure of the class file
      Returns:
      information, NONE for a class which is neither of Kotlin nor a Scala object