Class ReportNodeImpl

java.lang.Object
com.powsybl.commons.report.ReportNodeImpl
All Implemented Interfaces:
ReportNode

public final class ReportNodeImpl extends Object implements ReportNode
An in-memory implementation of ReportNode.

Being an implementation of ReportNode, instances of ReportNodeImpl are not thread-safe. As such, a ReportNodeImpl is not meant to be shared with other threads. Therefore, it should not be saved as a class parameter of an object which could be used by separate threads. In those cases it should instead be passed on in methods through their arguments.

Author:
Florian Dupuy <florian.dupuy at rte-france.com>
  • Method Details

    • getMessageKey

      public String getMessageKey()
      Description copied from interface: ReportNode
      Get the message key for current node. Note that each key needs to correspond to a unique message template. This allows to build up a dictionary of message templates indexed by their key.
      Specified by:
      getMessageKey in interface ReportNode
      Returns:
      the key
    • getMessageTemplate

      public String getMessageTemplate()
      Description copied from interface: ReportNode
      Get the message template for current node.
      Specified by:
      getMessageTemplate in interface ReportNode
      Returns:
      the message template
    • getValues

      public Map<String,TypedValue> getValues()
      Description copied from interface: ReportNode
      Get the values which belong to current node (does not include the inherited values)
      Specified by:
      getValues in interface ReportNode
      Returns:
      the values unmodifiable map
    • getMessage

      public String getMessage()
      Description copied from interface: ReportNode
      Get the message of current node, replacing ${key} references in the message template with the corresponding values, either contained in current node or in one of its parents.
      Specified by:
      getMessage in interface ReportNode
      Returns:
      the message
    • getValueAsString

      public Optional<String> getValueAsString(String valueKey)
    • getValue

      public Optional<TypedValue> getValue(String valueKey)
      Description copied from interface: ReportNode
      Get the value corresponding to the given key
      Specified by:
      getValue in interface ReportNode
      Parameters:
      valueKey - the key to request
      Returns:
      the value
    • newReportNode

      public ReportNodeAdder newReportNode()
      Description copied from interface: ReportNode
      Create a new adder to create a ReportNode child.
      Specified by:
      newReportNode in interface ReportNode
      Returns:
      the created ReportNodeAdder
    • include

      public void include(ReportNode reportNode)
      Description copied from interface: ReportNode
      Add a ReportNode as a child of current ReportNode.
      Specified by:
      include in interface ReportNode
      Parameters:
      reportNode - the ReportNode to add, it needs to be a root ReportNode
    • getChildren

      public List<ReportNode> getChildren()
      Description copied from interface: ReportNode
      Get the children of current node
      Specified by:
      getChildren in interface ReportNode
      Returns:
      the children nodes
    • print

      public void print(Writer writer) throws IOException
      Description copied from interface: ReportNode
      Print to given writer the current report node and its descendants
      Specified by:
      print in interface ReportNode
      Parameters:
      writer - the writer to write to
      Throws:
      IOException
    • parseJsonNode

      public static ReportNodeImpl parseJsonNode(com.fasterxml.jackson.databind.JsonNode reportTree, com.fasterxml.jackson.core.ObjectCodec codec, ReportNodeVersion version, String dictionaryName) throws IOException
      Throws:
      IOException
    • writeJson

      public void writeJson(com.fasterxml.jackson.core.JsonGenerator generator) throws IOException
      Description copied from interface: ReportNode
      Serialize the current report node
      Specified by:
      writeJson in interface ReportNode
      Parameters:
      generator - the jsonGenerator to use for serialization
      Throws:
      IOException