NormalizingEquality

trait NormalizingEquality[A] extends Equality[A]

An Equality[A] implementation that determines the equality of two objects by normalizing one or both objects, then comparing the results using an “after normalization” equality referenced from the afterNormalizationEquality member. By default, the afterNormalizationEquality is an instance of Equality.default[A].

NormalizingEquality is returned by the Explicitly DSL's “after being” syntax, using for the afterNormalizationEquality the implicit Equality in scope for the type of Uniformity passed to being. Here's an example:

scala> import org.scalactic._
import org.scalactic._

scala> import Explicitly._
import Explicitly._

scala> import StringNormalizations._
import StringNormalizations._

scala> after being lowerCased
res0: org.scalactic.NormalizingEquality[String] = ComposedNormalizingEquality(Equality.default,lowerCased)
Source:
NormalizingEquality.scala
trait Equality[A]
trait Equivalence[A]
class Object
trait Matchable
class Any

Value members

Abstract methods

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.

Type parameters:
A

the type of the object to normalize

Value parameters:
a

the object to normalize

Returns:

the normalized form of the passed object

Source:
NormalizingEquality.scala
def normalizedCanHandle(b: Any): Boolean

Indicates whether this NormalizingEquality's normalized method can “handle” the passed object, if cast to the appropriate type A.

Indicates whether this NormalizingEquality's normalized method can “handle” the passed object, if cast to the appropriate type A.

If this method returns true for a particular passed object, it means that if the object is passed to normalizedOrSame, that method will return the result of passing it to normalized. It does not mean that the object will necessarily be modified when passed to normalizedOrSame or normalized. For more information and examples, see the documentation for normalizedCanHandle in trait Uniformity, which has the same contract.

Source:
NormalizingEquality.scala
def normalizedOrSame(b: Any): Any

Returns either the result of passing this object to normalized, if appropriate, or the same object.

Returns either the result of passing this object to normalized, if appropriate, or the same object.

Value parameters:
b

the object to normalize, if appropriate

Returns:

a normalized form of the passed object, if this Uniformity was able to normalize it, else the same object passed

Source:
NormalizingEquality.scala

Concrete methods

final def and(other: Uniformity[A]): NormalizingEquality[A]

Returns a new NormalizingEquality that combines this and the passed Uniformity.

Returns a new NormalizingEquality that combines this and the passed Uniformity.

The normalized and normalizedOrSame methods of the NormalizingEquality's returned by this method return a result obtained by forwarding the passed value first to this NormalizingEquality's implementation of the method, then passing that result to the passed Uniformity's implementation of the method, respectively. Essentially, the body of the composed normalized method is:

uniformityPassedToAnd.normalized(uniformityOnWhichAndWasInvoked.normalized(a))

And the body of the composed normalizedOrSame method is:

uniformityPassedToAnd.normalizedOrSame(uniformityOnWhichAndWasInvoked.normalizedOrSame(a))

The normalizeCanHandle method of the NormalizingEquality returned by this method returns a result obtained by anding the result of forwarding the passed value to this NormalizingEquality's implementation of the method with the result of forwarding it to the passed Uniformity's implementation. Essentially, the body of the composed normalizeCanHandle method is:

normEqOnWhichAndWasInvoked.normalizeCanHandle(a) && uniformityPassedToAnd.normalizeCanHandle(a)
Value parameters:
other

a Uniformity to 'and' with this one

Returns:

a NormalizingEquality representing the composition of this and the passed Uniformity

Source:
NormalizingEquality.scala
final def areEqual(a: A, b: Any): Boolean

Determines the equality of two objects by normalizing the left-hand value, a, and, if appropriate, the right-hand value, b, then passing them to areEqual method of afterNormalizationEquality.

Determines the equality of two objects by normalizing the left-hand value, a, and, if appropriate, the right-hand value, b, then passing them to areEqual method of afterNormalizationEquality.

The left-hand value, a, is normalized by passing it to the normalized method of this NormalizingEquality. The right-hand value, b, is normalized, if appropriate, by passing it to the normalizedOrSame method of this NormalizingEquality.

Source:
NormalizingEquality.scala
final def toUniformity: Uniformity[A]

Converts this NormalizingEquality to a Uniformity.

Converts this NormalizingEquality to a Uniformity.

Returns:

a Uniformity whose normalized, normalizedCanHandle, and normalizedOrSame methods are implemented by the corresponding methods of this NormalizingEquality.

Source:
NormalizingEquality.scala

Inherited methods

final def areEquivalent(a: A, b: A): Boolean

A final implementation of the areEquivalent method of Equivalence that just passes a and b to areEqual and returns the result.

A final implementation of the areEquivalent method of Equivalence that just passes a and b to areEqual and returns the result.

This method enables any Equality to be used where an Equivalence is needed, such as the implicit enabling methods of TypeCheckedTripleEquals and ConversionCheckedTripleEquals.

Value parameters:
a

a left-hand value being compared with another, right-hand, value for equality (e.g., a == b)

b

a right-hand value being compared with another, left-hand, value for equality (e.g., a == b)

Returns:

true if the passed objects are "equal," as defined by the areEqual method of this Equality instance

Inherited from:
Equality
Source:
Equality.scala

Concrete fields

The Equality with which to determine equality after normalizing the left-hand and, if appropriate, the right-hand values.

The Equality with which to determine equality after normalizing the left-hand and, if appropriate, the right-hand values.

In this trait's implementation, this val is initialized with the result of invoking Equality.default[A]. Thus default Equality is the default afterNormalizationEquality. This may be changed by overriding afterNormalizationEquality in subclasses.

Source:
NormalizingEquality.scala