trait AbstractStringUniformity extends Uniformity[String]
Convenience base trait for string Uniformity
s.
This trait defines a normalizedCanHandle
method that returns true if the passed
Any
is a String
and a normalizedOrSame
method that
normalizes any passed String
s 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 capitalized
Uniformity
with a Matcher
expression:
scala> import org.scalatest._ import org.scalatest._ scala> import Matchers._ import Matchers._ scala> import org.scalactic._ import org.scalactic._ scala> val capitalized: Uniformity[String] = | new AbstractStringUniformity { | def normalized(s: String): String = | if (s.isEmpty) "" else s.charAt(0).toUpper + s.substring(1) | } capitalized: org.scalactic.Uniformity[String] = $anon$1@65601e00 scala> "Hello" should equal ("hello") (after being capitalized)
- Alphabetic
- By Inheritance
- AbstractStringUniformity
- Uniformity
- Normalization
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Abstract Value Members
- abstract def normalized(a: String): String
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
- Definition Classes
- Normalization
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: Uniformity[String]): Uniformity[String]
Returns a new
Uniformity
that combines this and the passedUniformity
.Returns a new
Uniformity
that combines this and the passedUniformity
.The
normalized
andnormalizedOrSame
methods of theUniformity
returned by this method return a result obtained by forwarding the passed value first to thisUniformity
's implementation of the method, then passing that result to the otherUniformity
'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 theUniformity
returned by this method returns a result obtained by anding the result of forwarding the passed value to thisUniformity
's implementation of the method with the result of forwarding it to the passedUniformity
's implementation. Essentially, the body of the composednormalizeCanHandle
method is:uniformityOnWhichAndWasInvoked.normalizeCanHandle(a) && uniformityPassedToAnd.normalizeCanHandle(a)
- other
a
Uniformity
to 'and' with this one- returns
a
Uniformity
representing the composition of this and the passedUniformity
- Definition Classes
- Uniformity
- final def and(other: Normalization[String]): Normalization[String]
Returns a new
Normalization
that composes this and the passedNormalization
.Returns a new
Normalization
that composes this and the passedNormalization
.The
normalized
method of theNormalization
returned by this method returns a normalized form of the passed object obtained by forwarding the passed value first to thisNormalization
'snormalized
method, then passing that result to the otherNormalization
'snormalized
method. Essentially, the body of the composednormalized
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 passedNormalization
- Definition Classes
- 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() @HotSpotIntrinsicCandidate()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def normalizedCanHandle(b: Any): Boolean
Returns true if the passed
Any
is aString
.Returns true if the passed
Any
is aString
.- returns
true if the passed
Any
is aString
.
- Definition Classes
- AbstractStringUniformity → Uniformity
- final def normalizedOrSame(b: Any): Any
Normalizes the passed object if it is a
String
.Normalizes the passed object if it is a
String
.This method returns either:
- if the passed object is a
String
, the result of passing that string tonormalized
- else, the same exact object that was passed
- b
the object to normalize, if appropriate
- returns
a normalized form of any passed
String
, or the same object if not aString
.
- Definition Classes
- AbstractStringUniformity → Uniformity
- if the passed object is a
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- final def toEquality(implicit equality: Equality[String]): NormalizingEquality[String]
Converts this
Uniformity
to aNormalizingEquality[A]
whosenormalized
,normalizedCanHandle
, andnormalizedOrSame
methods delegate to thisUniformity[A]
and whoseafterNormalizationEquality
field returns the implicitly passedEquality[A]
.Converts this
Uniformity
to aNormalizingEquality[A]
whosenormalized
,normalizedCanHandle
, andnormalizedOrSame
methods delegate to thisUniformity[A]
and whoseafterNormalizationEquality
field returns the implicitly passedEquality[A]
.- equality
the
Equality
that the returnedNormalizingEquality
will delegate to determine equality after normalizing both left and right (if appropriate) sides.
- Definition Classes
- Uniformity
- final def toEquivalence(implicit equivalence: Equivalence[String]): NormalizingEquivalence[String]
Converts this
Normalization
to aNormalizingEquivalence[A]
whosenormalized
method delegates to thisNormalization[A]
and whoseafterNormalizationEquivalence
field returns the implicitly passedEquivalence[A]
.Converts this
Normalization
to aNormalizingEquivalence[A]
whosenormalized
method delegates to thisNormalization[A]
and whoseafterNormalizationEquivalence
field returns the implicitly passedEquivalence[A]
.- equivalence
the
Equivalence
that the returnedNormalizingEquivalence
will delegate to determine equality after normalizing both left and right (if appropriate) sides.
- Definition Classes
- Normalization
- def toString(): String
- Definition Classes
- AnyRef → Any
- 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()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated