object NonZeroInt
The companion object for NonZeroInt that offers factory methods that
produce NonZeroInts, implicit widening conversions from NonZeroInt
to other numeric types, and maximum and minimum constant values for NonZeroInt.
- Source
- NonZeroInt.scala
- Alphabetic
- By Inheritance
- NonZeroInt
- 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
- final val MaxValue: NonZeroInt
The largest value representable as a non-zero
Int, which isNonZeroInt(2147483647). - final val MinValue: NonZeroInt
The smallest value representable as a non-zero
Int, which isNonZeroInt(-2147483648). - implicit macro def apply(value: Int): NonZeroInt
A factory method, implemented via a macro, that produces a
NonZeroIntif passed a validIntliteral, otherwise a compile time error.A factory method, implemented via a macro, that produces a
NonZeroIntif passed a validIntliteral, otherwise a compile time error.The macro that implements this method will inspect the specified
Intexpression at compile time. If the expression is a positiveIntliteral, i.e., with a value greater than 0, it will return aNonZeroIntrepresenting that value. Otherwise, the passedIntexpression is either a literal that is 0 or negative, 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 inspectsIntliterals at compile time, whereasfrominspectsIntvalues at run time.- value
the
Intliteral expression to inspect at compile time, and if positive, to return wrapped in aNonZeroIntat run time.- returns
the specified, valid
Intliteral value wrapped in aNonZeroInt. (If the specified expression is not a validIntliteral, 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: Int): NonZeroInt
A factory/assertion method that produces a
NonZeroIntgiven a validIntvalue, or throwsAssertionError, if given an invalidIntvalue.A factory/assertion method that produces a
NonZeroIntgiven a validIntvalue, or throwsAssertionError, if given an invalidIntvalue.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
Intvalue and if it is a non-zeroInt, it will return aNonZeroIntrepresenting that value. Otherwise, the passedIntvalue is not non-zero, so this method will throwAssertionError.This factory method differs from the
applyfactory method in thatapplyis implemented via a macro that inspectsIntliterals at compile time, whereas this method inspectsIntvalues 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 anIntis non-zero.- value
the
Intto inspect, and if non-zero, return wrapped in aNonZeroInt.- returns
the specified
Intvalue wrapped in aNonZeroInt, if it is non-zero, else throwsAssertionError.
- Exceptions thrown
AssertionErrorif the passed value is not non-zero
- 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: Int): Option[NonZeroInt]
A factory method that produces an
Option[NonZeroInt]given anIntvalue.A factory method that produces an
Option[NonZeroInt]given anIntvalue.This method will inspect the passed
Intvalue and if it is a non-zeroInt, i.e., a non-zero integer value, it will return aNonZeroIntrepresenting that value, wrapped in aSome. Otherwise, the passedIntvalue is not non-zero integer value, so this method will returnNone.This factory method differs from the
applyfactory method in thatapplyis implemented via a macro that inspectsIntliterals at compile time, whereasfrominspectsIntvalues at run time.- value
the
Intto inspect, and if non-zero, return wrapped in aSome[NonZeroInt].- returns
the specified
Intvalue wrapped in aSome[NonZeroInt], if it is non-zero, elseNone.
- def fromOrElse(value: Int, default: => NonZeroInt): NonZeroInt
A factory method that produces a
NonZeroIntgiven aIntvalue and a defaultNonZeroInt.A factory method that produces a
NonZeroIntgiven aIntvalue and a defaultNonZeroInt.This method will inspect the passed
Intvalue and if it is a positiveInt, i.e., a value greater than 0.0, it will return aNonZeroIntrepresenting that value. Otherwise, the passedIntvalue is 0 or negative, so this method will return the passeddefaultvalue.This factory method differs from the
applyfactory method in thatapplyis implemented via a macro that inspectsIntliterals at compile time, whereasfrominspectsIntvalues at run time.- value
the
Intto inspect, and if positive, return.- default
the
NonZeroIntto return if the passedIntvalue is not positive.- returns
the specified
Intvalue wrapped in aNonZeroInt, if it is positive, else thedefaultNonZeroIntvalue.
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def goodOrElse[B](value: Int)(f: (Int) => B): Or[NonZeroInt, B]
A factory/validation method that produces a
NonZeroInt, wrapped in aGood, given a validIntvalue, or if the givenIntis invalid, an error value of typeBproduced by passing the given invalidIntvalue to the given functionf, wrapped in aBad.A factory/validation method that produces a
NonZeroInt, wrapped in aGood, given a validIntvalue, or if the givenIntis invalid, an error value of typeBproduced by passing the given invalidIntvalue to the given functionf, wrapped in aBad.This method will inspect the passed
Intvalue and if it is a non-zeroInt, it will return aNonZeroIntrepresenting that value, wrapped in aGood. Otherwise, the passedIntvalue is not non-zero, so this method will return a result of typeBobtained by passing the invalidIntvalue to the given functionf, wrapped in aBad.This factory method differs from the
applyfactory method in thatapplyis implemented via a macro that inspectsIntliterals at compile time, whereas this method inspectsIntvalues at run time.- value
the
Intto inspect, and if non-zero, return wrapped in aGood(NonZeroInt).- returns
the specified
Intvalue wrapped in aGood(NonZeroInt), if it is non-zero, else aBad(f(value)).
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def isValid(value: Int): Boolean
A predicate method that returns true if a given
Intvalue is non-zero.A predicate method that returns true if a given
Intvalue is non-zero.- value
the
Intto inspect, and if non-zero, return true.- returns
true if the specified
Intis non-zero, 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()
- implicit val ordering: Ordering[NonZeroInt]
Implicit Ordering instance.
- def passOrElse[E](value: Int)(f: (Int) => E): Validation[E]
A validation method that produces a
Passgiven a validIntvalue, or an error value of typeEproduced by passing the given invalidIntvalue to the given functionf, wrapped in aFail.A validation method that produces a
Passgiven a validIntvalue, or an error value of typeEproduced by passing the given invalidIntvalue to the given functionf, wrapped in aFail.This method will inspect the passed
Intvalue and if it is a non-zeroInt, it will return aPass. Otherwise, the passedIntvalue is non-zero, so this method will return a result of typeEobtained by passing the invalidIntvalue to the given functionf, wrapped in aFail.This factory method differs from the
applyfactory method in thatapplyis implemented via a macro that inspectsIntliterals at compile time, whereas this method inspectsIntvalues at run time.- value
the
Intto validate that it is non-zero.- returns
a
Passif the specifiedIntvalue is non-zero, else aFailcontaining an error value produced by passing the specifiedIntto the given functionf.
- def rightOrElse[L](value: Int)(f: (Int) => L): Either[L, NonZeroInt]
A factory/validation method that produces a
NonZeroInt, wrapped in aRight, given a validIntvalue, or if the givenIntis invalid, an error value of typeLproduced by passing the given invalidIntvalue to the given functionf, wrapped in aLeft.A factory/validation method that produces a
NonZeroInt, wrapped in aRight, given a validIntvalue, or if the givenIntis invalid, an error value of typeLproduced by passing the given invalidIntvalue to the given functionf, wrapped in aLeft.This method will inspect the passed
Intvalue and if it is a non-zeroInt, it will return aNonZeroIntrepresenting that value, wrapped in aRight. Otherwise, the passedIntvalue is not non-zero, so this method will return a result of typeLobtained by passing the invalidIntvalue to the given functionf, wrapped in aLeft.This factory method differs from the
applyfactory method in thatapplyis implemented via a macro that inspectsIntliterals at compile time, whereas this method inspectsIntvalues at run time.- value
the
Intto inspect, and if non-zero, return wrapped in aRight(NonZeroInt).- returns
the specified
Intvalue wrapped in aRight(NonZeroInt), if it is non-zero, else aLeft(f(value)).
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- def tryingValid(value: Int): Try[NonZeroInt]
A factory/validation method that produces a
NonZeroInt, wrapped in aSuccess, given a validIntvalue, or if the givenIntis invalid, anAssertionError, wrapped in aFailure.A factory/validation method that produces a
NonZeroInt, wrapped in aSuccess, given a validIntvalue, or if the givenIntis invalid, anAssertionError, wrapped in aFailure.This method will inspect the passed
Intvalue and if it is a non-zeroInt, it will return aNonZeroIntrepresenting that value, wrapped in aSuccess. Otherwise, the passedIntvalue is not non-zero, so this method will return anAssertionError, wrapped in aFailure.This factory method differs from the
applyfactory method in thatapplyis implemented via a macro that inspectsIntliterals at compile time, whereas this method inspectsIntvalues at run time.- value
the
Intto inspect, and if non-zero, return wrapped in aSuccess(NonZeroInt).- returns
the specified
Intvalue wrapped in aSuccess(NonZeroInt), if it is non-zero, 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()
- implicit def widenToDouble(pos: NonZeroInt): Double
Implicit widening conversion from
NonZeroInttoDouble.Implicit widening conversion from
NonZeroInttoDouble.- pos
the
NonZeroIntto widen- returns
the
Intvalue underlying the specifiedNonZeroInt, widened toDouble.
- implicit def widenToFloat(pos: NonZeroInt): Float
Implicit widening conversion from
NonZeroInttoFloat.Implicit widening conversion from
NonZeroInttoFloat.- pos
the
NonZeroIntto widen- returns
the
Intvalue underlying the specifiedNonZeroInt, widened toFloat.
- implicit def widenToInt(pos: NonZeroInt): Int
Implicit widening conversion from
NonZeroInttoInt.Implicit widening conversion from
NonZeroInttoInt.- pos
the
NonZeroIntto widen- returns
the
Intvalue underlying the specifiedNonZeroInt.
- implicit def widenToLong(pos: NonZeroInt): Long
Implicit widening conversion from
NonZeroInttoLong.Implicit widening conversion from
NonZeroInttoLong.- pos
the
NonZeroIntto widen- returns
the
Intvalue underlying the specifiedNonZeroInt, widened toLong.
- implicit def widenToNonZeroDouble(pos: NonZeroInt): NonZeroDouble
Implicit widening conversion from
NonZeroInttoNonZeroDouble.Implicit widening conversion from
NonZeroInttoNonZeroDouble.- pos
the
NonZeroIntto widen- returns
the
Intvalue underlying the specifiedNonZeroInt, widened toDoubleand wrapped in aNonZeroDouble.
- implicit def widenToNonZeroFloat(pos: NonZeroInt): NonZeroFloat
Implicit widening conversion from
NonZeroInttoNonZeroFloat.Implicit widening conversion from
NonZeroInttoNonZeroFloat.- pos
the
NonZeroIntto widen- returns
the
Intvalue underlying the specifiedNonZeroInt, widened toFloatand wrapped in aNonZeroFloat.
- implicit def widenToNonZeroLong(pos: NonZeroInt): NonZeroLong
Implicit widening conversion from
NonZeroInttoNonZeroLong.Implicit widening conversion from
NonZeroInttoNonZeroLong.- pos
the
NonZeroIntto widen- returns
the
Intvalue underlying the specifiedNonZeroInt, widened toLongand wrapped in aNonZeroLong.