com.scalacraft.domain.v2.country

unconstrained

package unconstrained

Visibility
  1. Public
  2. All

Type Members

  1. case class CountryCodeA2(countryCode: String) extends Product with Serializable

    A CountryCodeA2 represents an ISO 3166 alpha-2 country code.

    A CountryCodeA2 represents an ISO 3166 alpha-2 country code.

    This class does not constrain the value of the code in anyway.

    Details of the ISO 3166-1 alpha 2 codes can be found here: http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2

    Pattern Matching

    Pattern matching is supported as illustrated by the following examples,

    "SC" match {
    case CountryCodeA2(code) => code  // "SC"
    case _ => None
    }

    Invalid country codes will be matched.

    "GBR" match {
    case CountryCodeA2(code) => code // "GBR"
    case _ => None
    }
    Implicit Conversions

    An implicit conversion is provided which allows an instance of CountryCodeA2 to be used when a String is required.

    def logCode(code: String) = println(s"code: $code")
    
    val cc = CountryCodeA2("TV")
    logCode(cc) // "code: TV"

    An implicit conversion to the constrained version of this class is also available.

    countryCode

    A value which can be a valid or invalid alpha 2 country code

  2. case class CountryCodeA3(countryCode: String) extends Product with Serializable

    A CountryCodeA3 represents an ISO 3166 alpha-3 country code.

    A CountryCodeA3 represents an ISO 3166 alpha-3 country code.

    This class does not constrain the value of the code in anyway.

    Details of the ISO 3166-1 alpha 3 codes can be found here: http://en.wikipedia.org/wiki/ISO_3166-1_alpha-3

    Pattern Matching

    Pattern matching is supported as illustrated by the following examples,

    "GBR" match {
    case CountryCodeA3(code) => code  // "GBR"
    case _ => None
    }

    Invalid country codes will be matched.

    "GBRT" match {
    case CountryCodeA3(code) => code // "GBRT"
    case _ => None
    }
    Implicit Conversions

    An implicit conversion is provided which allows an instance of CountryCodeA3 to be used when a String is required.

    def logCode(code: String) = println(s"code: $code")
    
    val cc = CountryCodeA3("TVU")
    logCode(cc) // "code: TVU"

    An implicit conversion to the constrained version of this class is also available.

    countryCode

    A value which can be a valid or invalid alpha 3 country code

  3. case class CountryCodeNumeric(countryCode: String) extends Product with Serializable

    A CountryCodeNumeric represents an ISO 3166 numeric country code.

    A CountryCodeNumeric represents an ISO 3166 numeric country code.

    This class does not constrain the value of the code in anyway.

    Details of the ISO 3166-1 numberic codes can be found here: http://en.wikipedia.org/wiki/ISO_3166-1_numeric

    Pattern Matching

    Pattern matching is supported as illustrated by the following examples,

    "419" match {
    case CountryCodeNumeric(code) => code  // "419"
    case _ => None
    }

    Invalid country codes will be matched.

    "B*" match {
    case CountryCodeNumeric(code) => code // "B*"
    case _ => None
    }
    Implicit Conversions

    An implicit conversion is provided which allows an instance of CountryCodeNumeric to be used when a String is required.

    def logCode(code: String) = println(s"code: $code")
    
    val cc = CountryCodeNumeric("415")
    logCode(cc) // "code: 415"

    An implicit conversion to the constrained version of this class is also available.

    countryCode

    A value which can be a valid or invalid numeric country code

Value Members

  1. object CountryCodeA2 extends Serializable

    This object provides a set of operations needed to create and convert instances of CountryCodeA2

  2. object CountryCodeA3 extends Serializable

    This object provides a set of operations needed to create and convert instances of CountryCodeA3

  3. object CountryCodeNumeric extends Serializable

    This object provides a set of operations needed to create and convert instances of CountryCodeNumeric

Ungrouped