Class BaseLocalVariable

All Implemented Interfaces:
io.github.mmm.code.api.expression.CodeExpression, io.github.mmm.code.api.expression.CodeVariable, io.github.mmm.code.api.item.CodeItem, io.github.mmm.code.api.item.CodeItemWithDeclaration, io.github.mmm.code.api.item.CodeItemWithModifiers, io.github.mmm.code.api.item.CodeItemWithName, io.github.mmm.code.api.item.CodeItemWithType, io.github.mmm.code.api.item.CodeItemWithVariables, io.github.mmm.code.api.statement.CodeAssignment, io.github.mmm.code.api.statement.CodeAtomicStatement, io.github.mmm.code.api.statement.CodeLocalVariable, io.github.mmm.code.api.statement.CodeStatement

public class BaseLocalVariable extends BaseAtomicStatement implements io.github.mmm.code.api.statement.CodeLocalVariable
Base implementation of CodeLocalVariable.
Since:
1.0.0
Author:
Joerg Hohwiller (hohwille at users.sourceforge.net)
  • Field Summary

    Fields inherited from interface io.github.mmm.code.api.item.CodeItem

    DEFAULT_INDENT, DEFAULT_NEWLINE
  • Constructor Summary

    Constructors
    Constructor
    Description
    BaseLocalVariable(BaseSource source, String name, io.github.mmm.code.api.type.CodeGenericType type, io.github.mmm.code.api.expression.CodeExpression expression, boolean finalFlag)
    The constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    doWrite(Appendable sink, String newline, String defaultIndent, String currentIndent, io.github.mmm.code.api.language.CodeLanguage language)
     
    io.github.mmm.code.api.expression.CodeConstant
     
    io.github.mmm.code.api.expression.CodeExpression
     
     
    io.github.mmm.code.api.type.CodeGenericType
     
    io.github.mmm.code.api.statement.CodeLocalVariable
    getVariable(String variableName)
     
    boolean
     

    Methods inherited from class BaseItem

    getOwningType, getSourceCode, getSpaces, toString, write

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface io.github.mmm.code.api.item.CodeItem

    getLanguage, getSourceCode, write, write, write, write, write, write

    Methods inherited from interface io.github.mmm.code.api.item.CodeItemWithDeclaration

    writeReference

    Methods inherited from interface io.github.mmm.code.api.statement.CodeLocalVariable

    getModifiers, getVariable

    Methods inherited from interface io.github.mmm.code.api.expression.CodeVariable

    writeReference
  • Constructor Details

    • BaseLocalVariable

      public BaseLocalVariable(BaseSource source, String name, io.github.mmm.code.api.type.CodeGenericType type, io.github.mmm.code.api.expression.CodeExpression expression, boolean finalFlag)
      The constructor.
      Parameters:
      source - the BaseSource defining this variable.
      name - the name.
      type - the type.
      expression - the assignment expression.
      finalFlag - the final flag.
  • Method Details

    • getName

      public String getName()
      Specified by:
      getName in interface io.github.mmm.code.api.item.CodeItemWithName
    • getType

      public io.github.mmm.code.api.type.CodeGenericType getType()
      Specified by:
      getType in interface io.github.mmm.code.api.item.CodeItemWithType
    • isFinal

      public boolean isFinal()
      Specified by:
      isFinal in interface io.github.mmm.code.api.statement.CodeLocalVariable
    • getExpression

      public io.github.mmm.code.api.expression.CodeExpression getExpression()
      Specified by:
      getExpression in interface io.github.mmm.code.api.statement.CodeAssignment
      Specified by:
      getExpression in interface io.github.mmm.code.api.statement.CodeLocalVariable
    • getVariable

      public io.github.mmm.code.api.statement.CodeLocalVariable getVariable(String variableName)
      Specified by:
      getVariable in interface io.github.mmm.code.api.item.CodeItemWithVariables
      Overrides:
      getVariable in class BaseStatement
    • evaluate

      public io.github.mmm.code.api.expression.CodeConstant evaluate()
      Specified by:
      evaluate in interface io.github.mmm.code.api.expression.CodeExpression
    • doWrite

      protected void doWrite(Appendable sink, String newline, String defaultIndent, String currentIndent, io.github.mmm.code.api.language.CodeLanguage language) throws IOException
      Specified by:
      doWrite in class BaseItem
      Parameters:
      sink - the Appendable where to append the code from this CodeItem.
      newline - the newline String.
      defaultIndent - the String used for indentation (e.g. a number of spaces to insert per indent level).
      currentIndent - the current indent (number of spaces). Initially the empty string (""). Before a recursion the defaultIndent will be appended.
      language - the CodeLanguage to use.
      Throws:
      IOException - if thrown by Appendable.
      See Also:
      • CodeItem.write(Appendable, String, String)