All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.scalautils.AbstractStringUniformity.scala Maven / Gradle / Ivy

The newest version!
/*
 * Copyright 2001-2013 Artima, Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.scalautils

/**
 * 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. *

*/ trait AbstractStringUniformity extends Uniformity[String] { /** * Returns true if the passed Any is a String. * * @return true if the passed Any is a String. */ final def normalizedCanHandle(b: Any): Boolean = b.isInstanceOf[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 *

    * * @return a normalized form of any passed String, or the same object if not a String. */ final def normalizedOrSame(b: Any) = b match { case s: String => normalized(s) case _ => b } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy