object NumericString
The companion object for NumericString that offers factory
methods that produce NumericStrings.
- Source
- NumericString.scala
- Alphabetic
- By Inheritance
- NumericString
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##(): Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- macro def apply(value: String): NumericString
A factory method, implemented via a macro, that produces a
NumericStringif passed a validStringliteral, otherwise a compile time error.A factory method, implemented via a macro, that produces a
NumericStringif passed a validStringliteral, otherwise a compile time error.The macro that implements this method will inspect the specified
Stringexpression at compile time. If the expression is a numericStringliteral, i.e., it doesn't contain any non-digit characters (0-9), it will return aNumericStringrepresenting that value. Otherwise, the passedStringexpression 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
fromfactory method in that this method is implemented via a macro that inspectsStringliterals at compile time, whereasfrominspectsStringvalues at run time.- value
the
Stringliteral expression to inspect at compile time, and if it is a numeric string, to return wrapped in aNumericStringat run time.- returns
the specified, valid
Stringliteral value wrapped in aNumericString. (If the specified expression is not a validStringliteral, the invocation of this method will not compile.)
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- def ensuringValid(value: String): NumericString
A factory/assertion method that produces a
NumericStringgiven a validStringvalue, or throwsAssertionError, if given an invalidStringvalue.A factory/assertion method that produces a
NumericStringgiven a validStringvalue, or throwsAssertionError, if given an invalidStringvalue.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
ensuringValidcall will always succeed, you should use one of the other factory or validation methods provided on this object instead:isValid,tryingValid,passOrElse,goodOrElse, orrightOrElse.This method will inspect the passed
Stringvalue and if it is a valid numeric string, it will return aNumericStringrepresenting that value. Otherwise, the passedStringvalue is not a valid numeric string, so this method will throwAssertionError.This factory method differs from the
applyfactory method in thatapplyis implemented via a macro that inspectsStringliterals at compile time, whereas this method inspectsStringvalues at run time. It differs from a vanillaassertorensuringcall in that you get something you didn't already have if the assertion succeeds: a type that promises aStringis numeric.- value
the
Stringto inspect, and if numeric, return wrapped in aNumericString.- returns
the specified
Stringvalue wrapped in aNumericString, if it is numeric, else throwsAssertionError.
- Exceptions thrown
AssertionErrorif the passed value is not numeric
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def from(value: String): Option[NumericString]
A factory method that produces an
Option[NumericString]given aStringvalue.A factory method that produces an
Option[NumericString]given aStringvalue.This method will inspect the passed
Stringvalue and if it is a numericString, i.e., one that doesn't contain any non-digit characters, it will return aNumericStringrepresenting that value, wrapped in aSome. Otherwise, the passedStringvalue is not a numeric string value, so this method will returnNone.This factory method differs from the
applyfactory method in thatapplyis implemented via a macro that inspectsStringliterals at compile time, whereasfrominspectsStringvalues at run time.- value
the
Stringto inspect, and if numeric, return wrapped in aSome[NumericString].- returns
the specified
Stringvalue wrapped in aSome[NumericString], if it is numeric, elseNone.
- def fromOrElse(value: String, default: => NumericString): NumericString
A factory method that produces a
NumericStringgiven aStringvalue and a defaultNumericString.A factory method that produces a
NumericStringgiven aStringvalue and a defaultNumericString.This method will inspect the passed
Stringvalue and if it is a valid numeric string, i.e., aStringcontaining only numeric digit characters (0-9), it will return aNumericStringrepresenting that value. Otherwise, the passedStringvalue contains non-digit characters, so this method will return the passeddefaultvalue.This factory method differs from the
applyfactory method in thatapplyis implemented via a macro that inspectsStringliterals at compile time, whereasfromOrElseinspectsStringvalues at run time.- value
the
Stringto inspect, and if numeric, return.- default
the
NumericStringto return if the passedStringvalue is not numeric.- returns
the specified
Stringvalue wrapped in aNumericString, if it is numeric, else thedefaultNumericStringvalue.
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def goodOrElse[B](value: String)(f: (String) => B): Or[NumericString, B]
A factory/validation method that produces a
NumericString, wrapped in aGood, given a validStringvalue, or if the givenStringis invalid, an error value of typeBproduced by passing the given invalidStringvalue to the given functionf, wrapped in aBad.A factory/validation method that produces a
NumericString, wrapped in aGood, given a validStringvalue, or if the givenStringis invalid, an error value of typeBproduced by passing the given invalidStringvalue to the given functionf, wrapped in aBad.This method will inspect the passed
Stringvalue and if it is a numericString, it will return aNumericStringrepresenting that value, wrapped in aGood. Otherwise, the passedStringvalue is NOT numeric, so this method will return a result of typeBobtained by passing the invalidStringvalue to the given functionf, wrapped in aBad.This factory method differs from the
applyfactory method in thatapplyis implemented via a macro that inspectsStringliterals at compile time, whereas this method inspectsStringvalues at run time.- value
the
Stringto inspect, and if numeric, return wrapped in aGood(NumericString).- returns
the specified
Stringvalue wrapped in aGood(NumericString), if it is numeric, else aBad(f(value)).
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def isValid(value: String): Boolean
A predicate method that returns true if a given
Stringvalue contains only numeric digit characters (0-9).A predicate method that returns true if a given
Stringvalue contains only numeric digit characters (0-9).- value
the
Stringto inspect, and if numeric, return true.- returns
true if the specified
Stringis numeric, else false.
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def passOrElse[E](value: String)(f: (String) => E): Validation[E]
A validation method that produces a
Passgiven a validStringvalue, or an error value of typeEproduced by passing the given invalidStringvalue to the given functionf, wrapped in aFail.A validation method that produces a
Passgiven a validStringvalue, or an error value of typeEproduced by passing the given invalidStringvalue to the given functionf, wrapped in aFail.This method will inspect the passed
Stringvalue and if it is a numericString, it will return aPass. Otherwise, the passedStringvalue is non-numeric, so this method will return a result of typeEobtained by passing the invalidStringvalue to the given functionf, wrapped in aFail.This factory method differs from the
applyfactory method in thatapplyis implemented via a macro that inspectsStringliterals at compile time, whereas this method inspectsStringvalues at run time.- value
the
Stringto validate that it is numeric.- returns
a
Passif the specifiedStringvalue is numeric, else aFailcontaining an error value produced by passing the specifiedStringto the given functionf.
- def rightOrElse[L](value: String)(f: (String) => L): Either[L, NumericString]
A factory/validation method that produces a
NumericString, wrapped in aRight, given a validStringvalue, or if the givenStringis invalid, an error value of typeLproduced by passing the given invalidStringvalue to the given functionf, wrapped in aLeft.A factory/validation method that produces a
NumericString, wrapped in aRight, given a validStringvalue, or if the givenStringis invalid, an error value of typeLproduced by passing the given invalidStringvalue to the given functionf, wrapped in aLeft.This method will inspect the passed
Stringvalue and if it is a numericString, it will return aNumericStringrepresenting that value, wrapped in aRight. Otherwise, the passedStringvalue is NOT numeric, so this method will return a result of typeLobtained by passing the invalidStringvalue to the given functionf, wrapped in aLeft.This factory method differs from the
applyfactory method in thatapplyis implemented via a macro that inspectsStringliterals at compile time, whereas this method inspectsStringvalues at run time.- value
the
Stringto inspect, and if numeric, return wrapped in aRight(NumericString).- returns
the specified
Stringvalue wrapped in aRight(NumericString), if it is numeric, else aLeft(f(value)).
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- def tryingValid(value: String): Try[NumericString]
A factory/validation method that produces a
NumericString, wrapped in aSuccess, given a validStringvalue, or if the givenStringis invalid, anAssertionError, wrapped in aFailure.A factory/validation method that produces a
NumericString, wrapped in aSuccess, given a validStringvalue, or if the givenStringis invalid, anAssertionError, wrapped in aFailure.This method will inspect the passed
Stringvalue and if it represents a numeric value, it will return aNumericStringrepresenting that value, wrapped in aSuccess. Otherwise, the passedStringvalue is not numeric, so this method will return anAssertionError, wrapped in aFailure.This factory method differs from the
applyfactory method in thatapplyis implemented via a macro that inspectsStringliterals at compile time, whereas this method inspectsStringvalues at run time.- value
the
Stringto inspect, and if numeric, return wrapped in aSuccess(NumericString).- returns
the specified
Stringvalue wrapped in aSuccess(NumericString), if it is numeric, else aFailure(AssertionError).
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()