Record Class MultilineString

java.lang.Object
java.lang.Record
smile.util.ipynb.MultilineString
Record Components:
lines - the individual lines that make up the string, each line retaining its trailing \n except possibly the last one.

public record MultilineString(List<String> lines) extends Record
A notebook multiline string value. The nbformat specification allows a field such as source or output text to be stored either as a single string or as an array of strings (each line retaining its trailing newline). This wrapper transparently handles both forms during (de)serialization and exposes the content as a single concatenated String.

Serialization always produces an array of strings (one entry per line), matching the canonical nbformat 4 representation.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an instance of a MultilineString record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    Returns the value of the lines record component.
    of(String text)
    Creates a MultilineString from a plain string by splitting on newline boundaries while keeping the delimiter at the end of each line.
    final String
    Returns a string representation of this record class.
    Returns the full content as a single concatenated string.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • MultilineString

      public MultilineString(List<String> lines)
      Creates an instance of a MultilineString record class.
      Parameters:
      lines - the value for the lines record component
  • Method Details

    • value

      public String value()
      Returns the full content as a single concatenated string.
      Returns:
      the joined string.
    • of

      public static MultilineString of(String text)
      Creates a MultilineString from a plain string by splitting on newline boundaries while keeping the delimiter at the end of each line.
      Parameters:
      text - the source text.
      Returns:
      a new MultilineString.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • lines

      public List<String> lines()
      Returns the value of the lines record component.
      Returns:
      the value of the lines record component