Klasse TypeNode

java.lang.Object
de.svws_nrw.transpiler.typescript.TypeNode

public class TypeNode extends Object
This class is used to handle java type information and transpiles it.
  • Konstruktordetails

    • TypeNode

      public TypeNode(TranspilerTypeScriptPlugin plugin, Tree node, boolean decl, boolean notNull)
      Creates a new variable with transpiled variable information.
      Parameter:
      plugin - the TranspilerTypeScriptPlugin used
      node - the Tree object of the java compiler
      decl - specifies whether the type is used during type declaration
      notNull - true if the declaration has a not null annotation
    • TypeNode

      public TypeNode(TranspilerTypeScriptPlugin plugin, TypeMirror typeMirror, boolean decl, boolean notNull, Map<String,TypeMirror> resolved)
      Creates a new variable with transpiled variable information.
      Parameter:
      plugin - the TranspilerTypeScriptPlugin used
      typeMirror - the TypeMirror object of the java compiler
      decl - specifies whether the type is used during type declaration
      notNull - true if the declaration has a not null annotation
      resolved - a map with a mapping from a type variable to its resolved type
  • Methodendetails

    • getNoDeclarationType

      public TypeNode getNoDeclarationType()
      Returns a copy of this type without the flag that indicates that this type is used during declaration
      Gibt zurück:
      a copy of this type without the flag that indicates that this type is used during declaration
    • setIsVarArg

      public void setIsVarArg()
      Sets the internal flag that this type is used as a type for variable arguments.
    • isNotNull

      public boolean isNotNull()
      Returns whether this type node has a not null annotation or not.
      Gibt zurück:
      true if the node has a not null annotation or not.
    • isPrimitive

      public boolean isPrimitive()
      Returns whether this type is a primitive type or not
      Gibt zurück:
      true if this is a primitive type
    • isPrimitveInteger

      public boolean isPrimitveInteger()
      Returns whether this type is a primitive integer type or not
      Gibt zurück:
      true if this is a primitive integer type
    • isPrimitveFloat

      public boolean isPrimitveFloat()
      Returns whether this type is a primitive floating point number type or not
      Gibt zurück:
      true if this is a primitive floating point number type
    • isPrimitveBoolean

      public boolean isPrimitveBoolean()
      Returns whether this type is a primitive boolean type or not
      Gibt zurück:
      true if this is a primitive boolean type
    • isPrimitveChar

      public boolean isPrimitveChar()
      Returns whether this type is a primitive char type or not
      Gibt zurück:
      true if this is a primitive char type
    • isString

      public boolean isString()
      Returns whether the type is java.lang.String.
      Gibt zurück:
      true if the type is java.lang.String
    • isBoolean

      public boolean isBoolean()
      Returns whether the type is java.lang.Boolean.
      Gibt zurück:
      true if the type is java.lang.Boolean
    • isNumberClass

      public boolean isNumberClass()
      Returns whether the type is a number class type (e.g. java.lang.Long).
      Gibt zurück:
      true if the type is a number class type
    • isCollectionType

      public boolean isCollectionType()
      Returns whether the type is a Java collection type (e.g. java.util.ArrayList).
      Gibt zurück:
      true if the type is a Java collection type
    • getParameterType

      public TypeNode getParameterType(int i, boolean decl)
      Returns the type of the i-th type parameter.
      Parameter:
      i - the number of the type parameter
      decl - specifies whether the type is used during type declaration
      Gibt zurück:
      the type of the i-th type parameter or null if this type no parameterized type or i is invalid
    • isArrayType

      public boolean isArrayType()
      Returns whether the type is a Java array type
      Gibt zurück:
      true if the type is a Java array type
    • getArrayContentType

      public TypeNode getArrayContentType(Transpiler transpiler)
      Returns a type node for the array content type
      Parameter:
      transpiler - the transpiler used for checking the annotation
      Gibt zurück:
      the type node for the array content type
    • transpileTypeParametersOnly

      public String transpileTypeParametersOnly()
      Returns the transpiled code for the type parameters of this node
      Gibt zurück:
      the transpiled code
    • transpile

      public String transpile(boolean noTypeArgs)
      Returns the transpiled code of this node.
      Parameter:
      noTypeArgs - if set to true the type arguments of parameterized types are not transpiled. This feature is used e.g. for the instanceof operator.
      Gibt zurück:
      the transpiled code
    • transpile

      public String transpile(boolean noTypeArgs, boolean noBounds)
      Returns the transpiled code of this node.
      Parameter:
      noTypeArgs - if set to true the type arguments of parameterized types are not transpiled. This feature is used e.g. for the instanceof operator.
      noBounds - if set to true the bounds for type arguments of parameterized types are not transpiled
      Gibt zurück:
      the transpiled code
    • getInstanceOf

      public String getInstanceOf(String obj)
      Returns the transpiled code for checking whether the specified object is an instance of this type.
      Parameter:
      obj - the object to be checked
      Gibt zurück:
      the transpiled instanceof code
    • getTypeCheck

      public String getTypeCheck(String identifier)
      Returns transpiled code to check whether the specified identifier matches this type.
      Parameter:
      identifier - the identifier to be checked
      Gibt zurück:
      the type check code
    • getTypeCast

      public String getTypeCast(String identifier)
      Returns transpiled code for casting the specified identifier to this type. Casting is only used for Java object types.
      Parameter:
      identifier - the identifier
      Gibt zurück:
      the transpiled code