<commit_before>package im.mange.little.amount

import java.text.DecimalFormat

import im.mange.little.percentage.Percentage

object Amount {
  val Zero = Amount("0")
  val MinusOne = Amount("-1")
}

case class Amount(private val value: String) {
  //TODO: this should probably be in AmountFactory and have options for strict = true
  private val trimmed = if (value == null) "" else value.trim
  private val internal = BigDecimal(if (trimmed.isEmpty) "0" else trimmed)

  def +(that: Amount)     = Amount((internal + that.internal).toString())
  def -(that: Amount)     = Amount((internal - that.internal).toString())
  def *(that: Amount)     = Amount((internal * that.internal).toString())
  def *(that: Int)        = Amount((internal * that).toString())
  def *(that: Long)       = Amount((internal * that).toString())
  def *(that: Percentage) = Amount((internal * that.internal).toString())
  def /(that: Amount)     = Amount((internal / that.internal).toString())

  def >(that: Amount)  = internal > that.internal
  def <(that: Amount)  = internal < that.internal
  def >=(that: Amount) = internal >= that.internal
  def <=(that: Amount) = internal <= that.internal

  def format(formatter: DecimalFormat) = formatter.format(internal)
  def abs = Amount(internal.abs.toString())
  def underlyingValue = internal.toString()
}
<commit_msg>add isZero and nonZero to Amount<commit_after>package im.mange.little.amount

import java.text.DecimalFormat

import im.mange.little.percentage.Percentage

object Amount {
  val Zero = Amount("0")
  val MinusOne = Amount("-1")
}

case class Amount(private val value: String) {
  //TODO: this should probably be in AmountFactory and have options for strict = true
  private val trimmed = if (value == null) "" else value.trim
  private val internal = BigDecimal(if (trimmed.isEmpty) "0" else trimmed)

  def +(that: Amount)     = Amount((internal + that.internal).toString())
  def -(that: Amount)     = Amount((internal - that.internal).toString())
  def *(that: Amount)     = Amount((internal * that.internal).toString())
  def *(that: Int)        = Amount((internal * that).toString())
  def *(that: Long)       = Amount((internal * that).toString())
  def *(that: Percentage) = Amount((internal * that.internal).toString())
  def /(that: Amount)     = Amount((internal / that.internal).toString())

  def >(that: Amount)  = internal > that.internal
  def <(that: Amount)  = internal < that.internal
  def >=(that: Amount) = internal >= that.internal
  def <=(that: Amount) = internal <= that.internal

  def format(formatter: DecimalFormat) = formatter.format(internal)
  def abs = Amount(internal.abs.toString())
  def underlyingValue = internal.toString()
  def isZero = this.equals(Amount.Zero)
  def nonZero = !this.equals(Amount.Zero)
}

{'fraction_non_alphanumeric': 0.1444962352097526, 'fraction_numerical': 0.002151308712800287, 'mean_word_length': 4.072727272727272, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '670416', 'n_tokens_mistral': 870, 'n_tokens_neox': 849, 'n_words': 239}