object NumericString

The companion object for NumericString that offers factory methods that produce NumericStrings.

Source
NumericString.scala
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. NumericString
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. macro def apply(value: String): NumericString

    A factory method, implemented via a macro, that produces a NumericString if passed a valid String literal, otherwise a compile time error.

    A factory method, implemented via a macro, that produces a NumericString if passed a valid String literal, otherwise a compile time error.

    The macro that implements this method will inspect the specified String expression at compile time. If the expression is a numeric String literal, i.e., it doesn't contain any non-digit characters (0-9), it will return a NumericString representing that value. Otherwise, the passed String expression is either a literal that contains non-digit characters, or is not a literal, so this method will give a compiler error.

    This factory method differs from the from factory method in that this method is implemented via a macro that inspects String literals at compile time, whereas from inspects String values at run time.

    value

    the String literal expression to inspect at compile time, and if it is a numeric string, to return wrapped in a NumericString at run time.

    returns

    the specified, valid String literal value wrapped in a NumericString. (If the specified expression is not a valid String literal, the invocation of this method will not compile.)

  5. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  6. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  7. def ensuringValid(value: String): NumericString

    A factory/assertion method that produces a NumericString given a valid String value, or throws AssertionError, if given an invalid String value.

    A factory/assertion method that produces a NumericString given a valid String value, or throws AssertionError, if given an invalid String value.

    Note: you should use this method only when you are convinced that it will always succeed, i.e., never throw an exception. It is good practice to add a comment near the invocation of this method indicating why you think it will always succeed to document your reasoning. If you are not sure an ensuringValid call will always succeed, you should use one of the other factory or validation methods provided on this object instead: isValid, tryingValid, passOrElse, goodOrElse, or rightOrElse.

    This method will inspect the passed String value and if it is a valid numeric string, it will return a NumericString representing that value. Otherwise, the passed String value is not a valid numeric string, so this method will throw AssertionError.

    This factory method differs from the apply factory method in that apply is implemented via a macro that inspects String literals at compile time, whereas this method inspects String values at run time. It differs from a vanilla assert or ensuring call in that you get something you didn't already have if the assertion succeeds: a type that promises a String is numeric.

    value

    the String to inspect, and if numeric, return wrapped in a NumericString.

    returns

    the specified String value wrapped in a NumericString, if it is numeric, else throws AssertionError.

    Exceptions thrown

    AssertionError if the passed value is not numeric

  8. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  9. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  10. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  11. def from(value: String): Option[NumericString]

    A factory method that produces an Option[NumericString] given a String value.

    A factory method that produces an Option[NumericString] given a String value.

    This method will inspect the passed String value and if it is a numeric String, i.e., one that doesn't contain any non-digit characters, it will return a NumericString representing that value, wrapped in a Some. Otherwise, the passed String value is not a numeric string value, so this method will return None.

    This factory method differs from the apply factory method in that apply is implemented via a macro that inspects String literals at compile time, whereas from inspects String values at run time.

    value

    the String to inspect, and if numeric, return wrapped in a Some[NumericString].

    returns

    the specified String value wrapped in a Some[NumericString], if it is numeric, else None.

  12. def fromOrElse(value: String, default: => NumericString): NumericString

    A factory method that produces a NumericString given a String value and a default NumericString.

    A factory method that produces a NumericString given a String value and a default NumericString.

    This method will inspect the passed String value and if it is a valid numeric string, i.e., a String containing only numeric digit characters (0-9), it will return a NumericString representing that value. Otherwise, the passed String value contains non-digit characters, so this method will return the passed default value.

    This factory method differs from the apply factory method in that apply is implemented via a macro that inspects String literals at compile time, whereas fromOrElse inspects String values at run time.

    value

    the String to inspect, and if numeric, return.

    default

    the NumericString to return if the passed String value is not numeric.

    returns

    the specified String value wrapped in a NumericString, if it is numeric, else the default NumericString value.

  13. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  14. def goodOrElse[B](value: String)(f: (String) => B): Or[NumericString, B]

    A factory/validation method that produces a NumericString, wrapped in a Good, given a valid String value, or if the given String is invalid, an error value of type B produced by passing the given invalid String value to the given function f, wrapped in a Bad.

    A factory/validation method that produces a NumericString, wrapped in a Good, given a valid String value, or if the given String is invalid, an error value of type B produced by passing the given invalid String value to the given function f, wrapped in a Bad.

    This method will inspect the passed String value and if it is a numeric String, it will return a NumericString representing that value, wrapped in a Good. Otherwise, the passed String value is NOT numeric, so this method will return a result of type B obtained by passing the invalid String value to the given function f, wrapped in a Bad.

    This factory method differs from the apply factory method in that apply is implemented via a macro that inspects String literals at compile time, whereas this method inspects String values at run time.

    value

    the String to inspect, and if numeric, return wrapped in a Good(NumericString).

    returns

    the specified String value wrapped in a Good(NumericString), if it is numeric, else a Bad(f(value)).

  15. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  16. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  17. def isValid(value: String): Boolean

    A predicate method that returns true if a given String value contains only numeric digit characters (0-9).

    A predicate method that returns true if a given String value contains only numeric digit characters (0-9).

    value

    the String to inspect, and if numeric, return true.

    returns

    true if the specified String is numeric, else false.

  18. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  19. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  20. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  21. def passOrElse[E](value: String)(f: (String) => E): Validation[E]

    A validation method that produces a Pass given a valid String value, or an error value of type E produced by passing the given invalid String value to the given function f, wrapped in a Fail.

    A validation method that produces a Pass given a valid String value, or an error value of type E produced by passing the given invalid String value to the given function f, wrapped in a Fail.

    This method will inspect the passed String value and if it is a numeric String, it will return a Pass. Otherwise, the passed String value is non-numeric, so this method will return a result of type E obtained by passing the invalid String value to the given function f, wrapped in a Fail.

    This factory method differs from the apply factory method in that apply is implemented via a macro that inspects String literals at compile time, whereas this method inspects String values at run time.

    value

    the String to validate that it is numeric.

    returns

    a Pass if the specified String value is numeric, else a Fail containing an error value produced by passing the specified String to the given function f.

  22. def rightOrElse[L](value: String)(f: (String) => L): Either[L, NumericString]

    A factory/validation method that produces a NumericString, wrapped in a Right, given a valid String value, or if the given String is invalid, an error value of type L produced by passing the given invalid String value to the given function f, wrapped in a Left.

    A factory/validation method that produces a NumericString, wrapped in a Right, given a valid String value, or if the given String is invalid, an error value of type L produced by passing the given invalid String value to the given function f, wrapped in a Left.

    This method will inspect the passed String value and if it is a numeric String, it will return a NumericString representing that value, wrapped in a Right. Otherwise, the passed String value is NOT numeric, so this method will return a result of type L obtained by passing the invalid String value to the given function f, wrapped in a Left.

    This factory method differs from the apply factory method in that apply is implemented via a macro that inspects String literals at compile time, whereas this method inspects String values at run time.

    value

    the String to inspect, and if numeric, return wrapped in a Right(NumericString).

    returns

    the specified String value wrapped in a Right(NumericString), if it is numeric, else a Left(f(value)).

  23. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  24. def toString(): String
    Definition Classes
    AnyRef → Any
  25. def tryingValid(value: String): Try[NumericString]

    A factory/validation method that produces a NumericString, wrapped in a Success, given a valid String value, or if the given String is invalid, an AssertionError, wrapped in a Failure.

    A factory/validation method that produces a NumericString, wrapped in a Success, given a valid String value, or if the given String is invalid, an AssertionError, wrapped in a Failure.

    This method will inspect the passed String value and if it represents a numeric value, it will return a NumericString representing that value, wrapped in a Success. Otherwise, the passed String value is not numeric, so this method will return an AssertionError, wrapped in a Failure.

    This factory method differs from the apply factory method in that apply is implemented via a macro that inspects String literals at compile time, whereas this method inspects String values at run time.

    value

    the String to inspect, and if numeric, return wrapped in a Success(NumericString).

    returns

    the specified String value wrapped in a Success(NumericString), if it is numeric, else a Failure(AssertionError).

  26. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  27. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  28. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Inherited from AnyRef

Inherited from Any

Ungrouped