Class BaseOperator

java.lang.Object
io.github.mmm.code.base.item.BaseItem
io.github.mmm.code.base.operator.BaseOperator
All Implemented Interfaces:
io.github.mmm.code.api.item.CodeItem, io.github.mmm.code.api.operator.CodeOperator
Direct Known Subclasses:
BaseComparisonOperator, BaseNAryOperator, BaseUnaryOperator

public abstract class BaseOperator extends BaseItem implements io.github.mmm.code.api.operator.CodeOperator
Base implementation of CodeOperator.
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
    Modifier
    Constructor
    Description
    protected
    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)
     
     
    static io.github.mmm.code.api.operator.CodeOperator
    of(String name)
     
    protected static <T extends io.github.mmm.code.api.operator.CodeOperator>
    T
    of(String name, Class<T> type)
     
     

    Methods inherited from class BaseItem

    getOwningType, getSourceCode, getSpaces, 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.operator.CodeOperator

    isComparison, isNAry, isUnary
  • Constructor Details

    • BaseOperator

      protected BaseOperator(String name)
      The constructor.
      Parameters:
      name - the name.
  • Method Details

    • getName

      public String getName()
      Specified by:
      getName in interface io.github.mmm.code.api.operator.CodeOperator
    • 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)
    • toString

      public String toString()
      Overrides:
      toString in class BaseItem
    • of

      public static io.github.mmm.code.api.operator.CodeOperator of(String name)
      Parameters:
      name - the name of the requested CodeOperator.
      Returns:
      the CodeOperator or null if not found.
    • of

      protected static <T extends io.github.mmm.code.api.operator.CodeOperator> T of(String name, Class<T> type)
      Type Parameters:
      T - type of the CodeOperator.
      Parameters:
      name - the name of the requested CodeOperator.
      type - the Class reflecting the type of the requested CodeOperator.
      Returns:
      the CodeOperator or null if not found.