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
- Alphabetic
- By Inheritance
- Normalization
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Abstract Value Members
-   abstract  def normalized(a: A): AReturns 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
-   final  def !=(arg0: Any): Boolean- Definition Classes
- AnyRef → Any
 
-   final  def ##: Int- Definition Classes
- AnyRef → Any
 
-   final  def ==(arg0: Any): Boolean- Definition Classes
- AnyRef → Any
 
-   final  def and(other: Normalization[A]): Normalization[A]Returns a new Normalizationthat composes this and the passedNormalization.Returns a new Normalizationthat composes this and the passedNormalization.The normalizedmethod of theNormalizationreturned by this method returns a normalized form of the passed object obtained by forwarding the passed value first to thisNormalization'snormalizedmethod, then passing that result to the otherNormalization'snormalizedmethod. Essentially, the body of the composednormalizedmethod is:normalizationPassedToAnd.normalized(normalizationOnWhichAndWasInvoked.normalized(a)) - other
- a - Normalizationto 'and' with this one
- returns
- a - Normalizationrepresenting the composition of this and the passed- Normalization
 
-   final  def asInstanceOf[T0]: T0- Definition Classes
- Any
 
-    def clone(): AnyRef- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
 
-   final  def eq(arg0: AnyRef): Boolean- Definition Classes
- AnyRef
 
-    def equals(arg0: AnyRef): Boolean- Definition Classes
- AnyRef → Any
 
-    def finalize(): Unit- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
 
-   final  def getClass(): Class[_ <: AnyRef]- Definition Classes
- AnyRef → Any
- Annotations
- @native()
 
-    def hashCode(): Int- Definition Classes
- AnyRef → Any
- Annotations
- @native()
 
-   final  def isInstanceOf[T0]: Boolean- Definition Classes
- Any
 
-   final  def ne(arg0: AnyRef): Boolean- Definition Classes
- AnyRef
 
-   final  def notify(): Unit- Definition Classes
- AnyRef
- Annotations
- @native()
 
-   final  def notifyAll(): Unit- Definition Classes
- AnyRef
- Annotations
- @native()
 
-   final  def synchronized[T0](arg0: => T0): T0- Definition Classes
- AnyRef
 
-   final  def toEquivalence(implicit equivalence: Equivalence[A]): NormalizingEquivalence[A]Converts this Normalizationto aNormalizingEquivalence[A]whosenormalizedmethod delegates to thisNormalization[A]and whoseafterNormalizationEquivalencefield returns the implicitly passedEquivalence[A].Converts this Normalizationto aNormalizingEquivalence[A]whosenormalizedmethod delegates to thisNormalization[A]and whoseafterNormalizationEquivalencefield returns the implicitly passedEquivalence[A].- equivalence
- the - Equivalencethat the returned- NormalizingEquivalencewill delegate to determine equality after normalizing both left and right (if appropriate) sides.
 
-    def toString(): String- Definition Classes
- AnyRef → Any
 
-   final  def wait(): Unit- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
 
-   final  def wait(arg0: Long, arg1: Int): Unit- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
 
-   final  def wait(arg0: Long): Unit- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()