Module io.github.sugarcubes.cloner
Class LanguageInfo
java.lang.Object
io.github.sugarcubes.cloner.enhancement.LanguageInfo
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
FieldsModifier and TypeFieldDescriptionstatic final intKind ofkotlin.Metadatafor classes, the default value ofk.static final LanguageInfoNeither a Kotlin class nor a Scala object. -
Method Summary
Modifier and TypeMethodDescriptionintgetKind()Returns the kind ofkotlin.Metadata:1for classes, including objects, other values for file facades and synthetic classes, which have no instances.getOuter()Returns the enclosing class.booleanholdsConstantOf(String type) Tells whether the class has a static final field of the type: the type is its companion object.booleanTells whether the class holds its instance inpublic static final INSTANCE: a Kotlinobject, if the class is a Kotlin one.booleanisKotlin()Tells whether the class file carrieskotlin.Metadata.booleanTells whether the class holds its instance instatic final MODULE$: a Scalaobject.static LanguageInfoof(ClassStructure structure) Returns the information of the structure of a class file.
-
Field Details
-
NONE
Neither a Kotlin class nor a Scala object. -
CLASS_KIND
public static final int CLASS_KINDKind ofkotlin.Metadatafor classes, the default value ofk.- See Also:
-
-
Method Details
-
isKotlin
public boolean isKotlin()Tells whether the class file carrieskotlin.Metadata.- Returns:
truefor Kotlin classes
-
getKind
public int getKind()Returns the kind ofkotlin.Metadata:1for classes, including objects, other values for file facades and synthetic classes, which have no instances.- Returns:
- kind,
0for other classes
-
holdsItself
public boolean holdsItself()Tells whether the class holds its instance inpublic static final INSTANCE: a Kotlinobject, if the class is a Kotlin one.- Returns:
truefor an object
-
isScalaObject
public boolean isScalaObject()Tells whether the class holds its instance instatic final MODULE$: a Scalaobject.- Returns:
truefor a Scala object
-
holdsConstantOf
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:
trueif the class holds a constant of the type
-
getOuter
Returns the enclosing class.- Returns:
- internal name or
nullfor a top level class
-
of
Returns the information of the structure of a class file.- Parameters:
structure- structure of the class file- Returns:
- information,
NONEfor a class which is neither of Kotlin nor a Scala object
-