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

caliban.syntax.scala Maven / Gradle / Ivy

The newest version!
package caliban

import scala.collection.mutable

private[caliban] object syntax {
  val NullFn: () => AnyRef = () => null

  implicit class EnrichedImmutableMapOps[K, V <: AnyRef](private val self: Map[K, V]) extends AnyVal {
    def getOrElseNull(key: K): V = self.getOrElse(key, NullFn()).asInstanceOf[V]
  }

  implicit class EnrichedHashMapOps[K, V <: AnyRef](private val self: mutable.HashMap[K, V]) extends AnyVal {
    def getOrElseNull(key: K): V = self.getOrElse(key, NullFn()).asInstanceOf[V]
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy