org.scalautils

AbstractStringUniformity

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.scalautils._ import org.scalautils._

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.scalautils.Uniformity[String] = $anon$1@65601e00

scala> "Hello" should equal ("hello") (after being capitalized)

Linear Supertypes
Uniformity[String], Normalization[String], AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. AbstractStringUniformity
  2. Uniformity
  3. Normalization
  4. AnyRef
  5. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Abstract Value Members

  1. 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

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. final def and(other: Uniformity[String]): Uniformity[String]

    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:

    uniformityPassedToAnd.normalized(uniformityOnWhichAndWasInvoked.normalized(a))
    

    And the body of the composed normalizedOrSame method is:

    uniformityPassedToAnd.normalizedOrSame(uniformityOnWhichAndWasInvoked.normalizedOrSame(a))
    

    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:

    uniformityOnWhichAndWasInvoked.normalizeCanHandle(a) && uniformityPassedToAnd.normalizeCanHandle(a)
    

    other

    a Uniformity to 'and' with this one

    returns

    a Uniformity representing the composition of this and the passed Uniformity

    Definition Classes
    Uniformity
  7. final def and(other: Normalization[String]): Normalization[String]

    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:

    normalizationPassedToAnd.normalized(normalizationOnWhichAndWasInvoked.normalized(a))
    

    other

    a Normalization to 'and' with this one

    returns

    a Normalization representing the composition of this and the passed Normalization

    Definition Classes
    Normalization
  8. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  9. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  10. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  11. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  12. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  13. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  14. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  15. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  16. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  17. final def normalizedCanHandle(b: Any): Boolean

    Returns true if the passed Any is a String.

    Returns true if the passed Any is a String.

    returns

    true if the passed Any is a String.

    Definition Classes
    AbstractStringUniformityUniformity
  18. 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 to normalized
    • 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 a String.

    Definition Classes
    AbstractStringUniformityUniformity
  19. final def notify(): Unit

    Definition Classes
    AnyRef
  20. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  21. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  22. def toString(): String

    Definition Classes
    AnyRef → Any
  23. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  24. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  25. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()

Inherited from Uniformity[String]

Inherited from Normalization[String]

Inherited from AnyRef

Inherited from Any

Ungrouped