trait AbstractStringUniformity extends Uniformity[String]
Convenience base trait for string Uniformitys.
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 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
- All
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
Uniformitythat combines this and the passedUniformity.Returns a new
Uniformitythat combines this and the passedUniformity.The
normalizedandnormalizedOrSamemethods of theUniformityreturned 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 composednormalizedmethod is:uniformityPassedToAnd.normalized(uniformityOnWhichAndWasInvoked.normalized(a))
And the body of the composed
normalizedOrSamemethod is:uniformityPassedToAnd.normalizedOrSame(uniformityOnWhichAndWasInvoked.normalizedOrSame(a))
The
normalizeCanHandlemethod of theUniformityreturned 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 composednormalizeCanHandlemethod is:uniformityOnWhichAndWasInvoked.normalizeCanHandle(a) && uniformityPassedToAnd.normalizeCanHandle(a)
- other
a
Uniformityto 'and' with this one- returns
a
Uniformityrepresenting the composition of this and the passedUniformity
- Definition Classes
- Uniformity
-
final
def
and(other: Normalization[String]): Normalization[String]
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 passedNormalization
- Definition Classes
- Normalization
-
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
normalizedCanHandle(b: Any): Boolean
Returns true if the passed
Anyis aString.Returns true if the passed
Anyis aString.- returns
true if the passed
Anyis 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()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
final
def
toEquality(implicit equality: Equality[String]): NormalizingEquality[String]
Converts this
Uniformityto aNormalizingEquality[A]whosenormalized,normalizedCanHandle, andnormalizedOrSamemethods delegate to thisUniformity[A]and whoseafterNormalizationEqualityfield returns the implicitly passedEquality[A].Converts this
Uniformityto aNormalizingEquality[A]whosenormalized,normalizedCanHandle, andnormalizedOrSamemethods delegate to thisUniformity[A]and whoseafterNormalizationEqualityfield returns the implicitly passedEquality[A].- equality
the
Equalitythat the returnedNormalizingEqualitywill 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
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 returnedNormalizingEquivalencewill 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(): 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( ... )