This trait defines a normalizedCanHandle method that returns true if the passed Any is a String and a normalizedOrSame method that normalizes any passed Strings via the normalized method, which is left abstract for subclasses to fill in.
Here's an example in which AbstractStringUniformity is used to normalize strings by ensuring the first character, if any, is capitalized:
val capitalized: Uniformity[String] =
new AbstractStringUniformity {
def normalized(s: String): String =
if (s.isEmpty) "" else s.charAt(0).toUpper + s.substring(1)
}
Here's an example of using the capitalizedUniformity with a Matcher expression:
Returns a new Uniformity that combines this and the passed Uniformity.
Returns a new Uniformity that combines this and the passed Uniformity.
The normalized and normalizedOrSame methods of the Uniformity returned by this method return a result obtained by forwarding the passed value first to this Uniformity's implementation of the method, then passing that result to the other Uniformity's implementation of the method, respectively. Essentially, the body of the composed normalized method is:
The normalizeCanHandle method of the Uniformity returned by this method returns a result obtained by anding the result of forwarding the passed value to this Uniformity'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:
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:
Converts this Uniformity to a NormalizingEquality[A] whose normalized, normalizedCanHandle, and normalizedOrSame methods delegate to this Uniformity[A] and whose afterNormalizationEquality field returns the implicitly passed Equality[A].
Converts this Uniformity to a NormalizingEquality[A] whose normalized, normalizedCanHandle, and normalizedOrSame methods delegate to this Uniformity[A] and whose afterNormalizationEquality field returns the implicitly passed Equality[A].
Value parameters
equality
the Equality that the returned NormalizingEquality will delegate to determine equality after normalizing both left and right (if appropriate) sides.
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].
Value parameters
equivalence
the Equivalence that the returned NormalizingEquivalence will delegate to determine equality after normalizing both left and right (if appropriate) sides.