object PosInt
The companion object for PosInt that offers factory methods that
produce PosInts, implicit widening conversions from PosInt
to other numeric types, and maximum and minimum constant values for PosInt.
- Source
- PosInt.scala
- Alphabetic
- By Inheritance
- PosInt
- 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: PosIntThe largest value representable as a positive Int, which isPosInt(2147483647).
-   final  val MinValue: PosIntThe smallest value representable as a positive Int, which isPosInt(1).
-   implicit macro  def apply(value: Int): PosIntA factory method, implemented via a macro, that produces a PosIntif passed a validIntliteral, otherwise a compile time error.A factory method, implemented via a macro, that produces a PosIntif 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 aPosIntrepresenting 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 a- PosIntat run time.
- returns
- the specified, valid - Intliteral value wrapped in a- PosInt. (If the specified expression is not a valid- Intliteral, 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): PosIntA factory/assertion method that produces a PosIntgiven a validIntvalue, or throwsAssertionError, if given an invalidIntvalue.A factory/assertion method that produces a PosIntgiven 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 positiveInt, it will return aPosIntrepresenting that value. Otherwise, the passedIntvalue is not positive, 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 positive.- value
- the - Intto inspect, and if positive, return wrapped in a- PosInt.
- returns
- the specified - Intvalue wrapped in a- PosInt, if it is positive, else throws- AssertionError.
 - Exceptions thrown
- AssertionErrorif the passed value is not positive
 
-   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[PosInt]A factory method that produces an Option[PosInt]given anIntvalue.A factory method that produces an Option[PosInt]given anIntvalue.This method will inspect the passed Intvalue and if it is a positiveInt, i.e., a positive integer value, it will return aPosIntrepresenting that value, wrapped in aSome. Otherwise, the passedIntvalue is not positive 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 positive, return wrapped in a- Some[PosInt].
- returns
- the specified - Intvalue wrapped in a- Some[PosInt], if it is positive, else- None.
 
-    def fromOrElse(value: Int, default: => PosInt): PosIntA factory method that produces a PosIntgiven aIntvalue and a defaultPosInt.A factory method that produces a PosIntgiven aIntvalue and a defaultPosInt.This method will inspect the passed Intvalue and if it is a positiveInt, i.e., a value greater than 0.0, it will return aPosIntrepresenting 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 - PosIntto return if the passed- Intvalue is not positive.
- returns
- the specified - Intvalue wrapped in a- PosInt, if it is positive, else the- default- PosIntvalue.
 
-   final  def getClass(): Class[_ <: AnyRef]- Definition Classes
- AnyRef → Any
- Annotations
- @native()
 
-    def goodOrElse[B](value: Int)(f: (Int) => B): Or[PosInt, B]A factory/validation method that produces a PosInt, 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 PosInt, 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 positiveInt, it will return aPosIntrepresenting that value, wrapped in aGood. Otherwise, the passedIntvalue is not positive, 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 positive, return wrapped in a- Good(PosInt).
- returns
- the specified - Intvalue wrapped in a- Good(PosInt), if it is positive, else a- Bad(f(value)).
 
-    def hashCode(): Int- Definition Classes
- AnyRef → Any
- Annotations
- @native()
 
-   final  def isInstanceOf[T0]: Boolean- Definition Classes
- Any
 
-    def isValid(value: Int): BooleanA predicate method that returns true if a given Intvalue is positive.A predicate method that returns true if a given Intvalue is positive.- value
- the - Intto inspect, and if positive, return true.
- returns
- true if the specified - Intis positive, 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[PosInt]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 positiveInt, it will return aPass. Otherwise, the passedIntvalue is positive, 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 positive.
- returns
- a - Passif the specified- Intvalue is positive, else a- Failcontaining an error value produced by passing the specified- Intto the given function- f.
 
-    def rightOrElse[L](value: Int)(f: (Int) => L): Either[L, PosInt]A factory/validation method that produces a PosInt, 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 PosInt, 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 positiveInt, it will return aPosIntrepresenting that value, wrapped in aRight. Otherwise, the passedIntvalue is not positive, 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 positive, return wrapped in a- Right(PosInt).
- returns
- the specified - Intvalue wrapped in a- Right(PosInt), if it is positive, else a- Left(f(value)).
 
-   final  def synchronized[T0](arg0: => T0): T0- Definition Classes
- AnyRef
 
-    def toString(): String- Definition Classes
- AnyRef → Any
 
-    def tryingValid(value: Int): Try[PosInt]A factory/validation method that produces a PosInt, wrapped in aSuccess, given a validIntvalue, or if the givenIntis invalid, anAssertionError, wrapped in aFailure.A factory/validation method that produces a PosInt, 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 positiveInt, it will return aPosIntrepresenting that value, wrapped in aSuccess. Otherwise, the passedIntvalue is not positive, 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 positive, return wrapped in a- Success(PosInt).
- returns
- the specified - Intvalue wrapped in a- Success(PosInt), if it is positive, else a- Failure(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: PosInt): DoubleImplicit widening conversion from PosInttoDouble.Implicit widening conversion from PosInttoDouble.- pos
- the - PosIntto widen
- returns
- the - Intvalue underlying the specified- PosInt, widened to- Double.
 
-   implicit  def widenToFloat(pos: PosInt): FloatImplicit widening conversion from PosInttoFloat.Implicit widening conversion from PosInttoFloat.- pos
- the - PosIntto widen
- returns
- the - Intvalue underlying the specified- PosInt, widened to- Float.
 
-   implicit  def widenToInt(pos: PosInt): IntImplicit widening conversion from PosInttoInt.Implicit widening conversion from PosInttoInt.- pos
- the - PosIntto widen
- returns
- the - Intvalue underlying the specified- PosInt.
 
-   implicit  def widenToLong(pos: PosInt): LongImplicit widening conversion from PosInttoLong.Implicit widening conversion from PosInttoLong.- pos
- the - PosIntto widen
- returns
- the - Intvalue underlying the specified- PosInt, widened to- Long.
 
-   implicit  def widenToNonZeroDouble(pos: PosInt): NonZeroDoubleImplicit widening conversion from PosInttoNonZeroDouble.Implicit widening conversion from PosInttoNonZeroDouble.- pos
- the - PosIntto widen
- returns
- the - Intvalue underlying the specified- PosInt, widened to- Doubleand wrapped in a- NonZeroDouble.
 
-   implicit  def widenToNonZeroFloat(pos: PosInt): NonZeroFloatImplicit widening conversion from PosInttoNonZeroFloat.Implicit widening conversion from PosInttoNonZeroFloat.- pos
- the - PosIntto widen
- returns
- the - Intvalue underlying the specified- PosInt, widened to- Floatand wrapped in a- NonZeroFloat.
 
-   implicit  def widenToNonZeroInt(pos: PosInt): NonZeroIntImplicit widening conversion from PosInttoNonZeroInt.Implicit widening conversion from PosInttoNonZeroInt.- pos
- the - PosIntto widen
- returns
- the - Intvalue underlying the specified- PosInt, widened to- Intand wrapped in a- NonZeroInt.
 
-   implicit  def widenToNonZeroLong(pos: PosInt): NonZeroLongImplicit widening conversion from PosInttoNonZeroLong.Implicit widening conversion from PosInttoNonZeroLong.- pos
- the - PosIntto widen
- returns
- the - Intvalue underlying the specified- PosInt, widened to- Longand wrapped in a- NonZeroLong.
 
-   implicit  def widenToPosDouble(pos: PosInt): PosDoubleImplicit widening conversion from PosInttoPosDouble.Implicit widening conversion from PosInttoPosDouble.- pos
- the - PosIntto widen
- returns
- the - Intvalue underlying the specified- PosInt, widened to- Doubleand wrapped in a- PosDouble.
 
-   implicit  def widenToPosFloat(pos: PosInt): PosFloatImplicit widening conversion from PosInttoPosFloat.Implicit widening conversion from PosInttoPosFloat.- pos
- the - PosIntto widen
- returns
- the - Intvalue underlying the specified- PosInt, widened to- Floatand wrapped in a- PosFloat.
 
-   implicit  def widenToPosLong(pos: PosInt): PosLongImplicit widening conversion from PosInttoPosLong.Implicit widening conversion from PosInttoPosLong.- pos
- the - PosIntto widen
- returns
- the - Intvalue underlying the specified- PosInt, widened to- Longand wrapped in a- PosLong.
 
-   implicit  def widenToPosZDouble(pos: PosInt): PosZDoubleImplicit widening conversion from PosInttoPosZDouble.Implicit widening conversion from PosInttoPosZDouble.- pos
- the - PosIntto widen
- returns
- the - Intvalue underlying the specified- PosInt, widened to- Doubleand wrapped in a- PosZDouble.
 
-   implicit  def widenToPosZFloat(pos: PosInt): PosZFloatImplicit widening conversion from PosInttoPosZFloat.Implicit widening conversion from PosInttoPosZFloat.- pos
- the - PosIntto widen
- returns
- the - Intvalue underlying the specified- PosInt, widened to- Floatand wrapped in a- PosZFloat.
 
-   implicit  def widenToPosZInt(pos: PosInt): PosZIntImplicit widening conversion from PosInttoPosZInt.Implicit widening conversion from PosInttoPosZInt.- pos
- the - PosIntto widen
- returns
- the - Intvalue underlying the specified- PosInt, widened to- Intand wrapped in a- PosZInt.
 
-   implicit  def widenToPosZLong(pos: PosInt): PosZLongImplicit widening conversion from PosInttoPosZLong.Implicit widening conversion from PosInttoPosZLong.- pos
- the - PosIntto widen
- returns
- the - Intvalue underlying the specified- PosInt, widened to- Longand wrapped in a- PosZLong.
 
Deprecated Value Members
-    val posIntOrd: Ordering[PosInt]The formerly implicit posIntOrdfield has been deprecated and will be removed in a future version of ScalaTest. Please use theorderingfield instead.The formerly implicit posIntOrdfield has been deprecated and will be removed in a future version of ScalaTest. Please use theorderingfield instead.- Annotations
- @deprecated
- Deprecated
- The formerly implicit posIntOrd field has been deprecated and will be removed in a future version of ScalaTest. Please use the ordering field instead.