org.scalactic.anyvals

NumericString

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
Learn more about member selection
Visibility
  1. Public
  2. All

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

    Annotations
    @macroImpl( ... )
  7. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  8. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  9. 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

  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( classOf[java.lang.Throwable] )
  13. 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.

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

  15. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  16. 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)).

  17. def hashCode(): Int

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

    Definition Classes
    Any
  19. 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.

  20. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  21. final def notify(): Unit

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

    Definition Classes
    AnyRef
  23. 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.

  24. 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)).

  25. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  26. def toString(): String

    Definition Classes
    AnyRef → Any
  27. 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).

  28. final def wait(): Unit

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

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

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from AnyRef

Inherited from Any

Ungrouped