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

encrywm.backend.Compare.scala Maven / Gradle / Ivy

There is a newer version: 0.3.2
Show newest version
package encrywm.backend

import encrywm.backend.env.ESObject
import encrywm.backend.executor.error.UnsupportedOperationError

object Compare {

  def eq(op1: Any, op2: Any): Boolean = {
    (op1, op2) match {
      case (o1: Int, o2: Int) => o1 == o2
      case (o1: Int, o2: Long) => o1 == o2
      case (o1: Int, o2: Float) => o1 == o2
      case (o1: Int, o2: Double) => o1 == o2
      case (o1: Long, o2: Int) => o1 == o2
      case (o1: Long, o2: Long) => o1 == o2
      case (o1: Long, o2: Float) => o1 == o2
      case (o1: Long, o2: Double) => o1 == o2
      case (o1: Float, o2: Int) => o1 == o2
      case (o1: Float, o2: Long) => o1 == o2
      case (o1: Float, o2: Float) => o1 == o2
      case (o1: Float, o2: Double) => o1 == o2
      case (o1: Double, o2: Int) => o1 == o2
      case (o1: Double, o2: Long) => o1 == o2
      case (o1: Double, o2: Float) => o1 == o2
      case (o1: Double, o2: Double) => o1 == o2
      case (o1: Boolean, o2: Boolean) => o1 == o2
      case (o1: Array[Byte], o2: Array[Byte]) => o1 sameElements o2
      case (o1: ESObject, o2: ESObject) => o1 == o2
      case _ => throw UnsupportedOperationError
    }
  }

  def gt(op1: Any, op2: Any): Boolean = {
    (op1, op2) match {
      case (o1: Int, o2: Int) => o1 > o2
      case (o1: Int, o2: Long) => o1 > o2
      case (o1: Int, o2: Float) => o1 > o2
      case (o1: Int, o2: Double) => o1 > o2
      case (o1: Long, o2: Int) => o1 > o2
      case (o1: Long, o2: Long) => o1 > o2
      case (o1: Long, o2: Float) => o1 > o2
      case (o1: Long, o2: Double) => o1 > o2
      case (o1: Float, o2: Int) => o1 > o2
      case (o1: Float, o2: Long) => o1 > o2
      case (o1: Float, o2: Float) => o1 > o2
      case (o1: Float, o2: Double) => o1 > o2
      case (o1: Double, o2: Int) => o1 > o2
      case (o1: Double, o2: Long) => o1 > o2
      case (o1: Double, o2: Float) => o1 > o2
      case (o1: Double, o2: Double) => o1 > o2
      case _ => throw UnsupportedOperationError
    }
  }

  def gte(op1: Any, op2: Any): Boolean = {
    (op1, op2) match {
      case (o1: Int, o2: Int) => o1 >= o2
      case (o1: Int, o2: Long) => o1 >= o2
      case (o1: Int, o2: Float) => o1 >= o2
      case (o1: Int, o2: Double) => o1 >= o2
      case (o1: Long, o2: Int) => o1 >= o2
      case (o1: Long, o2: Long) => o1 >= o2
      case (o1: Long, o2: Float) => o1 >= o2
      case (o1: Long, o2: Double) => o1 >= o2
      case (o1: Float, o2: Int) => o1 >= o2
      case (o1: Float, o2: Long) => o1 >= o2
      case (o1: Float, o2: Float) => o1 >= o2
      case (o1: Float, o2: Double) => o1 >= o2
      case (o1: Double, o2: Int) => o1 >= o2
      case (o1: Double, o2: Long) => o1 >= o2
      case (o1: Double, o2: Float) => o1 >= o2
      case (o1: Double, o2: Double) => o1 >= o2
      case _ => throw UnsupportedOperationError
    }
  }

  def lt(op1: Any, op2: Any): Boolean = {
    (op1, op2) match {
      case (o1: Int, o2: Int) => o1 < o2
      case (o1: Int, o2: Long) => o1 < o2
      case (o1: Int, o2: Float) => o1 < o2
      case (o1: Int, o2: Double) => o1 < o2
      case (o1: Long, o2: Int) => o1 < o2
      case (o1: Long, o2: Long) => o1 < o2
      case (o1: Long, o2: Float) => o1 < o2
      case (o1: Long, o2: Double) => o1 < o2
      case (o1: Float, o2: Int) => o1 < o2
      case (o1: Float, o2: Long) => o1 < o2
      case (o1: Float, o2: Float) => o1 < o2
      case (o1: Float, o2: Double) => o1 < o2
      case (o1: Double, o2: Int) => o1 < o2
      case (o1: Double, o2: Long) => o1 < o2
      case (o1: Double, o2: Float) => o1 < o2
      case (o1: Double, o2: Double) => o1 < o2
      case _ => throw UnsupportedOperationError
    }
  }

  def lte(op1: Any, op2: Any): Boolean = {
    (op1, op2) match {
      case (o1: Int, o2: Int) => o1 <= o2
      case (o1: Int, o2: Long) => o1 <= o2
      case (o1: Int, o2: Float) => o1 <= o2
      case (o1: Int, o2: Double) => o1 <= o2
      case (o1: Long, o2: Int) => o1 <= o2
      case (o1: Long, o2: Long) => o1 <= o2
      case (o1: Long, o2: Float) => o1 <= o2
      case (o1: Long, o2: Double) => o1 <= o2
      case (o1: Float, o2: Int) => o1 <= o2
      case (o1: Float, o2: Long) => o1 <= o2
      case (o1: Float, o2: Float) => o1 <= o2
      case (o1: Float, o2: Double) => o1 <= o2
      case (o1: Double, o2: Int) => o1 <= o2
      case (o1: Double, o2: Long) => o1 <= o2
      case (o1: Double, o2: Float) => o1 <= o2
      case (o1: Double, o2: Double) => o1 <= o2
      case _ => throw UnsupportedOperationError
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy