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)
- Self Type
- NormalizingEquality[A]
- Source
- NormalizingEquality.scala
- Alphabetic
- By Inheritance
- NormalizingEquality
- Equality
- Equivalence
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Abstract Value Members
-
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
-
abstract
def
normalizedCanHandle(b: Any): Boolean
Indicates whether this
NormalizingEquality
'snormalized
method can “handle” the passed object, if cast to the appropriate typeA
.Indicates whether this
NormalizingEquality
'snormalized
method can “handle” the passed object, if cast to the appropriate typeA
.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 tonormalized
. It does not mean that the object will necessarily be modified when passed tonormalizedOrSame
ornormalized
. For more information and examples, see the documentation fornormalizedCanHandle
in traitUniformity
, which has the same contract. -
abstract
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.- 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
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
-
val
afterNormalizationEquality: Equality[A]
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 invokingEquality.default[A]
. Thus defaultEquality
is the defaultafterNormalizationEquality
. This may be changed by overridingafterNormalizationEquality
in subclasses. -
final
def
and(other: Uniformity[A]): NormalizingEquality[A]
Returns a new
NormalizingEquality
that combines this and the passedUniformity
.Returns a new
NormalizingEquality
that combines this and the passedUniformity
.The
normalized
andnormalizedOrSame
methods of theNormalizingEquality
's returned by this method return a result obtained by forwarding the passed value first to thisNormalizingEquality
's implementation of the method, then passing that result to the passedUniformity
's implementation of the method, respectively. Essentially, the body of the composednormalized
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 theNormalizingEquality
returned by this method returns a result obtained by anding the result of forwarding the passed value to thisNormalizingEquality
's implementation of the method with the result of forwarding it to the passedUniformity
's implementation. Essentially, the body of the composednormalizeCanHandle
method is:normEqOnWhichAndWasInvoked.normalizeCanHandle(a) && uniformityPassedToAnd.normalizeCanHandle(a)
- other
a
Uniformity
to 'and' with this one- returns
a
NormalizingEquality
representing the composition of this and the passedUniformity
-
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 toareEqual
method ofafterNormalizationEquality
.Determines the equality of two objects by normalizing the left-hand value,
a
, and, if appropriate, the right-hand value,b
, then passing them toareEqual
method ofafterNormalizationEquality
.The left-hand value,
a
, is normalized by passing it to thenormalized
method of thisNormalizingEquality
. The right-hand value,b
, is normalized, if appropriate, by passing it to thenormalizedOrSame
method of thisNormalizingEquality
.- a
a left-hand value being compared with another (right-hand-side one) for equality (e.g.,
a == b
)- b
a right-hand value being compared with another (left-hand-side one) for equality (e.g.,
a == b
)- returns
true if the passed objects are "equal," as defined by this
Equality
instance
- Definition Classes
- NormalizingEquality → Equality
-
final
def
areEquivalent(a: A, b: A): Boolean
A final implementation of the
areEquivalent
method ofEquivalence
that just passesa
andb
toareEqual
and returns the result.A final implementation of the
areEquivalent
method ofEquivalence
that just passesa
andb
toareEqual
and returns the result.This method enables any
Equality
to be used where anEquivalence
is needed, such as the implicit enabling methods ofTypeCheckedTripleEquals
andConversionCheckedTripleEquals
.- 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 thisEquality
instance
- Definition Classes
- Equality → Equivalence
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- 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
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
toUniformity: Uniformity[A]
Converts this
NormalizingEquality
to aUniformity
.Converts this
NormalizingEquality
to aUniformity
.- returns
a
Uniformity
whosenormalized
,normalizedCanHandle
, andnormalizedOrSame
methods are implemented by the corresponding methods of thisNormalizingEquality
.
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )