case classDomainName extends Product with Serializable
A DomainName represents a name in the domain name system.
Unlike the example in Programming in Scala/2e the elements of the domain name are stored in the same order
as used, i.e. as www.scalacraft.com, not reversed.
This implementation is case sensitive which is at variance with the Wikipedia specification. If a convincing
use case for case insensitivity arises this could be reconsidered. Expressed in code we have,
DomainName.opt("WWW") != DomainName.opt("www")
The v2 documentation provides details of the syntactic constraints placed on domain names.
Pattern Matching
Pattern matching is supported as the following example demonstrates,
A
DomainName
represents a name in the domain name system.Unlike the example in Programming in Scala/2e the elements of the domain name are stored in the same order as used, i.e. as
www.scalacraft.com
, not reversed.This implementation is case sensitive which is at variance with the Wikipedia specification. If a convincing use case for case insensitivity arises this could be reconsidered. Expressed in code we have,
The v2 documentation provides details of the syntactic constraints placed on domain names.
Pattern Matching
Pattern matching is supported as the following example demonstrates,
Invalid domain names will not be matched.
To match an arbitrary number of domain name labels use a pattern sequence,
Implicit Conversions
Implicit conversions exist which allow an instance of
DomainName
to be used when either aString
orSeq[String]
is required.A conversion to the unconstrained version of this class is also available.