All Downloads are FREE. Search and download functionalities are using the official Maven repository.

o-deps.proto-syntax_2.11.2.1.3.source-code.bytes.scala Maven / Gradle / Ivy

package proto

final class Bytes private (a: Array[Byte]) {
  lazy val length: Int = a.length
  lazy val isEmpty: Boolean = a.isEmpty
  lazy val nonEmpty: Boolean = a.nonEmpty
  lazy val mkString: String = new String(a, "utf8")
  val unsafeArray: Array[Byte] = a
  override def equals(other: Any): Boolean = {
    if (!other.isInstanceOf[Bytes]) false
    else java.util.Arrays.equals(a, other.asInstanceOf[Bytes].unsafeArray)
  }
  override def hashCode(): Int = java.util.Arrays.hashCode(a)
}

object Bytes {
  val empty = new Bytes(Array.emptyByteArray)
  def unsafeWrap(a: Array[Byte]): Bytes = new Bytes(a)
  def apply(bs: Byte*): Bytes = new Bytes(bs.toArray)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy