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

org.scaladebugger.api.dsl.info.ValueInfoDSLWrapper.scala Maven / Gradle / Ivy

package org.scaladebugger.api.dsl.info

import org.scaladebugger.api.profiles.traits.info.{ObjectInfoProfile, ValueInfoProfile}
import org.scaladebugger.api.virtualmachines.ObjectCache

/**
 * Wraps a profile, providing DSL-like syntax.
 *
 * @param valueInfo The profile to wrap
 */
class ValueInfoDSLWrapper private[dsl] (
  private val valueInfo: ValueInfoProfile
) {
  /**
   * Caches this value in its associated JVM cache.
   *
   * @param objectCache The JVM cache to store this value
   * @return The stored value
   */
  def cache()(
    implicit objectCache: ObjectCache = valueInfo.scalaVirtualMachine.cache
  ): ValueInfoProfile = {
    import org.scaladebugger.api.dsl.Implicits.ObjectInfoDSL
    valueInfo match {
      case obj: ObjectInfoProfile => obj.cache()
      case _                      =>
    }
    valueInfo
  }

  /**
   * Removes this value from its associated JVM cache.
   *
   * @param objectCache The JVM cache to remove this value
   * @return The removed value
   */
  def uncache()(
    implicit objectCache: ObjectCache = valueInfo.scalaVirtualMachine.cache
  ): ValueInfoProfile = {
    import org.scaladebugger.api.dsl.Implicits.ObjectInfoDSL
    valueInfo match {
      case obj: ObjectInfoProfile => obj.uncache()
      case _                      =>
    }
    valueInfo
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy