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

sttp.model.Header.scala Maven / Gradle / Ivy

There is a newer version: 2.0.0-RC4
Show newest version
package sttp.model

import scala.util.hashing.MurmurHash3

class Header(val name: String, val value: String) {
  def is(otherName: String): Boolean = name.equalsIgnoreCase(otherName)

  override def toString: String = s"$name: $value"
  override def hashCode(): Int = MurmurHash3.mixLast(name.toLowerCase.hashCode, value.hashCode)
  override def equals(that: Any): Boolean = that match {
    case h: AnyRef if this.eq(h) => true
    case h: Header               => is(h.name) && (value == h.value)
    case _                       => false
  }
}

object Header {
  def apply(name: String, value: String) = new Header(name, value)
  def unapply(h: Header): Option[(String, String)] = Some((h.name, h.value))
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy