Class PythonCodeAssign

All Implemented Interfaces:
net.ssehub.easy.instantiation.core.model.vilTypes.IStringValueProvider, net.ssehub.easy.instantiation.core.model.vilTypes.IVilType, IPythonCodeElement, Storable
Direct Known Subclasses:
PythonCodeEnum.PythonCodeEnumLiteral

public class PythonCodeAssign extends PythonCodeStmt
Represents a Python value assign in VTL.
Author:
Kevin Schaperjahn
  • Field Details

  • Constructor Details

    • PythonCodeAssign

      public PythonCodeAssign(IPythonCodeElement parent, String varName, String expr)
      Creates an assignment statement.
      Parameters:
      parent - the parent
      varName - the variable name
      expr - the value expression
    • PythonCodeAssign

      public PythonCodeAssign(IPythonCodeElement parent, String varName, String type, String expr)
      Creates an assignment statement.
      Parameters:
      parent - the parent
      varName - the variable name
      type - the type (for annotation)
      expr - the value expression
  • Method Details

    • toAttributes

      public PythonCodeAssign toAttributes()
      Moves this assignment to the attributes at the beginning of the containing class if there is a containing class. By default, the assignment occurs wherever it is added.
      Returns:
      this for chaining
    • toAttributes

      public PythonCodeAssign toAttributes(boolean apply)
      Moves this assignment conditionally to the attributes at the beginning of the containing class if there is a containing class. By default, the assignment occurs wherever it is added.
      Parameters:
      apply - whether this attribute shall be moved
      Returns:
      this for chaining
    • addCall

      public PythonCodeFnCall addCall(String fnName)
    • addCall

      public PythonCodeFnCall addCall(String fnName, PythonCodeImportScope scope)
    • addConstructorCall

      public PythonCodeConstructorCall addConstructorCall(String cls)
    • store

      public void store(net.ssehub.easy.instantiation.core.model.templateModel.CodeWriter out)
    • isAttribute

      public boolean isAttribute()
      Description copied from interface: IPythonCodeElement
      Returns whether this element is a (class) property/attribute.
      Returns:
      true for attribute, false else