object PosZInt
The companion object for PosZInt
that offers factory methods that
produce PosZInt
s, implicit widening conversions from PosZInt
to other numeric types, and maximum and minimum constant values for PosZInt
.
- Source
- PosZInt.scala
- Alphabetic
- By Inheritance
- PosZInt
- 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: PosZInt
The largest value representable as a non-negative
Int
, which isPosZInt(2147483647)
. - final val MinValue: PosZInt
The smallest value representable as a non-negative
Int
, which isPosZInt(0)
. - implicit macro def apply(value: Int): PosZInt
A factory method, implemented via a macro, that produces a
PosZInt
if passed a validInt
literal, otherwise a compile time error.A factory method, implemented via a macro, that produces a
PosZInt
if passed a validInt
literal, otherwise a compile time error.The macro that implements this method will inspect the specified
Int
expression at compile time. If the expression is a positiveInt
literal, i.e., with a value greater than 0, it will return aPosZInt
representing that value. Otherwise, the passedInt
expression 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
from
factory method in that this method is implemented via a macro that inspectsInt
literals at compile time, whereasfrom
inspectsInt
values at run time.- value
the
Int
literal expression to inspect at compile time, and if positive, to return wrapped in aPosZInt
at run time.- returns
the specified, valid
Int
literal value wrapped in aPosZInt
. (If the specified expression is not a validInt
literal, 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): PosZInt
A factory/assertion method that produces a
PosZInt
given a validInt
value, or throwsAssertionError
, if given an invalidInt
value.A factory/assertion method that produces a
PosZInt
given a validInt
value, or throwsAssertionError
, if given an invalidInt
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
, orrightOrElse
.This method will inspect the passed
Int
value and if it is a non-negativeInt
, it will return aPosZInt
representing that value. Otherwise, the passedInt
value is not non-negative, so this method will throwAssertionError
.This factory method differs from the
apply
factory method in thatapply
is implemented via a macro that inspectsInt
literals at compile time, whereas this method inspectsInt
values at run time. It differs from a vanillaassert
orensuring
call in that you get something you didn't already have if the assertion succeeds: a type that promises anInt
is non-negative.- value
the
Int
to inspect, and if non-negative, return wrapped in aPosZInt
.- returns
the specified
Int
value wrapped in aPosZInt
, if it is non-negative, else throwsAssertionError
.
- Exceptions thrown
AssertionError
if the passed value is not non-negative
- 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[PosZInt]
A factory method that produces an
Option[PosZInt]
given anInt
value.A factory method that produces an
Option[PosZInt]
given anInt
value.This method will inspect the passed
Int
value and if it is a non-negativeInt
, i.e., a non-negative integer value, it will return aPosZInt
representing that value, wrapped in aSome
. Otherwise, the passedInt
value is not non-negative integer value, so this method will returnNone
.This factory method differs from the
apply
factory method in thatapply
is implemented via a macro that inspectsInt
literals at compile time, whereasfrom
inspectsInt
values at run time.- value
the
Int
to inspect, and if non-negative, return wrapped in aSome[PosZInt]
.- returns
the specified
Int
value wrapped in aSome[PosZInt]
, if it is non-negative, elseNone
.
- def fromOrElse(value: Int, default: => PosZInt): PosZInt
A factory method that produces a
PosZInt
given aInt
value and a defaultPosZInt
.A factory method that produces a
PosZInt
given aInt
value and a defaultPosZInt
.This method will inspect the passed
Int
value and if it is a positiveInt
, i.e., a value greater than 0.0, it will return aPosZInt
representing that value. Otherwise, the passedInt
value is 0 or negative, so this method will return the passeddefault
value.This factory method differs from the
apply
factory method in thatapply
is implemented via a macro that inspectsInt
literals at compile time, whereasfrom
inspectsInt
values at run time.- value
the
Int
to inspect, and if positive, return.- default
the
PosZInt
to return if the passedInt
value is not positive.- returns
the specified
Int
value wrapped in aPosZInt
, if it is positive, else thedefault
PosZInt
value.
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def goodOrElse[B](value: Int)(f: (Int) => B): Or[PosZInt, B]
A factory/validation method that produces a
PosZInt
, wrapped in aGood
, given a validInt
value, or if the givenInt
is invalid, an error value of typeB
produced by passing the given invalidInt
value to the given functionf
, wrapped in aBad
.A factory/validation method that produces a
PosZInt
, wrapped in aGood
, given a validInt
value, or if the givenInt
is invalid, an error value of typeB
produced by passing the given invalidInt
value to the given functionf
, wrapped in aBad
.This method will inspect the passed
Int
value and if it is a non-negativeInt
, it will return aPosZInt
representing that value, wrapped in aGood
. Otherwise, the passedInt
value is not non-negative, so this method will return a result of typeB
obtained by passing the invalidInt
value to the given functionf
, wrapped in aBad
.This factory method differs from the
apply
factory method in thatapply
is implemented via a macro that inspectsInt
literals at compile time, whereas this method inspectsInt
values at run time.- value
the
Int
to inspect, and if non-negative, return wrapped in aGood(PosZInt)
.- returns
the specified
Int
value wrapped in aGood(PosZInt)
, if it is non-negative, 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
Int
value is non-negative.A predicate method that returns true if a given
Int
value is non-negative.- value
the
Int
to inspect, and if non-negative, return true.- returns
true if the specified
Int
is non-negative, 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[PosZInt]
Implicit Ordering instance.
- def passOrElse[E](value: Int)(f: (Int) => E): Validation[E]
A validation method that produces a
Pass
given a validInt
value, or an error value of typeE
produced by passing the given invalidInt
value to the given functionf
, wrapped in aFail
.A validation method that produces a
Pass
given a validInt
value, or an error value of typeE
produced by passing the given invalidInt
value to the given functionf
, wrapped in aFail
.This method will inspect the passed
Int
value and if it is a non-negativeInt
, it will return aPass
. Otherwise, the passedInt
value is non-negative, so this method will return a result of typeE
obtained by passing the invalidInt
value to the given functionf
, wrapped in aFail
.This factory method differs from the
apply
factory method in thatapply
is implemented via a macro that inspectsInt
literals at compile time, whereas this method inspectsInt
values at run time.- value
the
Int
to validate that it is non-negative.- returns
a
Pass
if the specifiedInt
value is non-negative, else aFail
containing an error value produced by passing the specifiedInt
to the given functionf
.
- def rightOrElse[L](value: Int)(f: (Int) => L): Either[L, PosZInt]
A factory/validation method that produces a
PosZInt
, wrapped in aRight
, given a validInt
value, or if the givenInt
is invalid, an error value of typeL
produced by passing the given invalidInt
value to the given functionf
, wrapped in aLeft
.A factory/validation method that produces a
PosZInt
, wrapped in aRight
, given a validInt
value, or if the givenInt
is invalid, an error value of typeL
produced by passing the given invalidInt
value to the given functionf
, wrapped in aLeft
.This method will inspect the passed
Int
value and if it is a non-negativeInt
, it will return aPosZInt
representing that value, wrapped in aRight
. Otherwise, the passedInt
value is not non-negative, so this method will return a result of typeL
obtained by passing the invalidInt
value to the given functionf
, wrapped in aLeft
.This factory method differs from the
apply
factory method in thatapply
is implemented via a macro that inspectsInt
literals at compile time, whereas this method inspectsInt
values at run time.- value
the
Int
to inspect, and if non-negative, return wrapped in aRight(PosZInt)
.- returns
the specified
Int
value wrapped in aRight(PosZInt)
, if it is non-negative, 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[PosZInt]
A factory/validation method that produces a
PosZInt
, wrapped in aSuccess
, given a validInt
value, or if the givenInt
is invalid, anAssertionError
, wrapped in aFailure
.A factory/validation method that produces a
PosZInt
, wrapped in aSuccess
, given a validInt
value, or if the givenInt
is invalid, anAssertionError
, wrapped in aFailure
.This method will inspect the passed
Int
value and if it is a non-negativeInt
, it will return aPosZInt
representing that value, wrapped in aSuccess
. Otherwise, the passedInt
value is not non-negative, so this method will return anAssertionError
, wrapped in aFailure
.This factory method differs from the
apply
factory method in thatapply
is implemented via a macro that inspectsInt
literals at compile time, whereas this method inspectsInt
values at run time.- value
the
Int
to inspect, and if non-negative, return wrapped in aSuccess(PosZInt)
.- returns
the specified
Int
value wrapped in aSuccess(PosZInt)
, if it is non-negative, 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: PosZInt): Double
Implicit widening conversion from
PosZInt
toDouble
.Implicit widening conversion from
PosZInt
toDouble
.- pos
the
PosZInt
to widen- returns
the
Int
value underlying the specifiedPosZInt
, widened toDouble
.
- implicit def widenToFloat(pos: PosZInt): Float
Implicit widening conversion from
PosZInt
toFloat
.Implicit widening conversion from
PosZInt
toFloat
.- pos
the
PosZInt
to widen- returns
the
Int
value underlying the specifiedPosZInt
, widened toFloat
.
- implicit def widenToInt(pos: PosZInt): Int
Implicit widening conversion from
PosZInt
toInt
.Implicit widening conversion from
PosZInt
toInt
.- pos
the
PosZInt
to widen- returns
the
Int
value underlying the specifiedPosZInt
.
- implicit def widenToLong(pos: PosZInt): Long
Implicit widening conversion from
PosZInt
toLong
.Implicit widening conversion from
PosZInt
toLong
.- pos
the
PosZInt
to widen- returns
the
Int
value underlying the specifiedPosZInt
, widened toLong
.
- implicit def widenToPosZDouble(pos: PosZInt): PosZDouble
Implicit widening conversion from
PosZInt
toPosZDouble
.Implicit widening conversion from
PosZInt
toPosZDouble
.- pos
the
PosZInt
to widen- returns
the
Int
value underlying the specifiedPosZInt
, widened toDouble
and wrapped in aPosZDouble
.
- implicit def widenToPosZFloat(pos: PosZInt): PosZFloat
Implicit widening conversion from
PosZInt
toPosZFloat
.Implicit widening conversion from
PosZInt
toPosZFloat
.- pos
the
PosZInt
to widen- returns
the
Int
value underlying the specifiedPosZInt
, widened toFloat
and wrapped in aPosZFloat
.
- implicit def widenToPosZLong(pos: PosZInt): PosZLong
Implicit widening conversion from
PosZInt
toPosZLong
.Implicit widening conversion from
PosZInt
toPosZLong
.- pos
the
PosZInt
to widen- returns
the
Int
value underlying the specifiedPosZInt
, widened toLong
and wrapped in aPosZLong
.
Deprecated Value Members
- val posZIntOrd: Ordering[PosZInt]
The formerly implicit
posZIntOrd
field has been deprecated and will be removed in a future version of ScalaTest. Please use theordering
field instead.The formerly implicit
posZIntOrd
field has been deprecated and will be removed in a future version of ScalaTest. Please use theordering
field instead.- Annotations
- @deprecated
- Deprecated
The formerly implicit posZIntOrd field has been deprecated and will be removed in a future version of ScalaTest. Please use the ordering field instead.