Package smile.util

Record Class Bytes

Record Components:
array - the array buffer of bytes.

public record Bytes(byte[] array) extends Record
Byte string.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Bytes(byte[] array)
    Creates an instance of a Bytes record class.
    Constructor with a string input.
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    Returns the value of the array record component.
    boolean
    equals(Object other)
    Indicates whether some other object is "equal to" this one.
    int
    Returns a hash code value for this object.
    int
    Returns the length of byte string.
    slice(int start, int end)
    Returns a copy of byte string slice.
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

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

    • Bytes

      public Bytes(String s)
      Constructor with a string input.
      Parameters:
      s - the UTF8 encoding of string will be stored.
    • Bytes

      public Bytes(byte[] array)
      Creates an instance of a Bytes record class.
      Parameters:
      array - the value for the array record component
  • Method Details

    • length

      public int length()
      Returns the length of byte string.
      Returns:
      the length of byte string.
    • slice

      public Bytes slice(int start, int end)
      Returns a copy of byte string slice.
      Parameters:
      start - the initial index of the range to be copied, inclusive
      end - the final index of the range to be copied, exclusive.
      Returns:
      a copy of byte string slice.
    • toString

      public 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 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 boolean equals(Object other)
      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:
      other - the object with which to compare
      Returns:
      true if this object is the same as the other argument; false otherwise.
    • array

      public byte[] array()
      Returns the value of the array record component.
      Returns:
      the value of the array record component