t

org.scalactic

Normalization

trait Normalization[A] extends AnyRef

Defines a custom way to normalize instances of a type.

For example, to normalize Doubles by truncating off any decimal part, you might write:

import org.scalactic._

val truncated = new Normalization[Double] { def normalized(d: Double) = d.floor }

Given this definition you could use it with the Explicitly DSL like this:

import org.scalatest._
import Matchers._
import TypeCheckedTripleEquals._

(2.1 should === (2.0)) (after being truncated)

Note that to use a Normalization with the Explicitly DSL, you'll need to use TypeCheckedTripleEquals. If you're just using plain-old TripleEquals, you'll need a Uniformity, a Normalization subclass.

If you make the truncated val implicit and import or mix in the members of NormMethods, you can access the behavior by invoking .norm on Doubles.

implicit val doubleNormalization = truncated
import NormMethods._

val d = 2.1 d.norm // returns 2.0

A

the type whose normalization is being defined

Self Type
Normalization[A]
Source
Normalization.scala
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Normalization
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def normalized(a: A): A

    Returns a normalized form of the passed object.

    Returns a normalized form of the passed object.

    If the passed object is already in normal form, this method may return the same instance passed.

    a

    the object to normalize

    returns

    the normalized form of the passed object

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def and(other: Normalization[A]): Normalization[A]

    Returns a new Normalization that composes this and the passed Normalization.

    Returns a new Normalization that composes this and the passed Normalization.

    The normalized method of the Normalization returned by this method returns a normalized form of the passed object obtained by forwarding the passed value first to this Normalization's normalized method, then passing that result to the other Normalization's normalized method. Essentially, the body of the composed normalized method is:

    normalizationPassedToAnd.normalized(normalizationOnWhichAndWasInvoked.normalized(a))
    

    other

    a Normalization to 'and' with this one

    returns

    a Normalization representing the composition of this and the passed Normalization

  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  7. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  8. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  9. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  10. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  11. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  12. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  13. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  14. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  15. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  16. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  17. final def toEquivalence(implicit equivalence: Equivalence[A]): NormalizingEquivalence[A]

    Converts this Normalization to a NormalizingEquivalence[A] whose normalized method delegates to this Normalization[A] and whose afterNormalizationEquivalence field returns the implicitly passed Equivalence[A].

    Converts this Normalization to a NormalizingEquivalence[A] whose normalized method delegates to this Normalization[A] and whose afterNormalizationEquivalence field returns the implicitly passed Equivalence[A].

    equivalence

    the Equivalence that the returned NormalizingEquivalence will delegate to determine equality after normalizing both left and right (if appropriate) sides.

  18. def toString(): String
    Definition Classes
    AnyRef → Any
  19. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  20. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  21. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Inherited from AnyRef

Inherited from Any

Ungrouped