object NegInt
The companion object for NegInt
that offers factory methods that
produce NegInt
s, implicit widening conversions from NegInt
to other numeric types, and maximum and minimum constant values for NegInt
.
- Source
- NegInt.scala
- Alphabetic
- By Inheritance
- NegInt
- 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: NegInt
The largest value representable as a negative
Int
, which isNegInt(-1)
. - final val MinValue: NegInt
The smallest value representable as a negative
Int
, which isNegInt(-2147483648)
. - implicit macro def apply(value: Int): NegInt
A factory method, implemented via a macro, that produces a
NegInt
if passed a validInt
literal, otherwise a compile time error.A factory method, implemented via a macro, that produces a
NegInt
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 aNegInt
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 aNegInt
at run time.- returns
the specified, valid
Int
literal value wrapped in aNegInt
. (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): NegInt
A factory/assertion method that produces a
NegInt
given a validInt
value, or throwsAssertionError
, if given an invalidInt
value.A factory/assertion method that produces a
NegInt
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 negativeInt
, it will return aNegInt
representing that value. Otherwise, the passedInt
value is not 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 negative.- value
the
Int
to inspect, and if negative, return wrapped in aNegInt
.- returns
the specified
Int
value wrapped in aNegInt
, if it is negative, else throwsAssertionError
.
- Exceptions thrown
AssertionError
if the passed value is not 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[NegInt]
A factory method that produces an
Option[NegInt]
given anInt
value.A factory method that produces an
Option[NegInt]
given anInt
value.This method will inspect the passed
Int
value and if it is a negativeInt
, i.e., a negative integer value, it will return aNegInt
representing that value, wrapped in aSome
. Otherwise, the passedInt
value is not 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 negative, return wrapped in aSome[NegInt]
.- returns
the specified
Int
value wrapped in aSome[NegInt]
, if it is negative, elseNone
.
- def fromOrElse(value: Int, default: => NegInt): NegInt
A factory method that produces a
NegInt
given aInt
value and a defaultNegInt
.A factory method that produces a
NegInt
given aInt
value and a defaultNegInt
.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 aNegInt
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
NegInt
to return if the passedInt
value is not positive.- returns
the specified
Int
value wrapped in aNegInt
, if it is positive, else thedefault
NegInt
value.
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def goodOrElse[B](value: Int)(f: (Int) => B): Or[NegInt, B]
A factory/validation method that produces a
NegInt
, 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
NegInt
, 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 negativeInt
, it will return aNegInt
representing that value, wrapped in aGood
. Otherwise, the passedInt
value is not 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 negative, return wrapped in aGood(NegInt)
.- returns
the specified
Int
value wrapped in aGood(NegInt)
, if it is 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 negative.A predicate method that returns true if a given
Int
value is negative.- value
the
Int
to inspect, and if negative, return true.- returns
true if the specified
Int
is 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[NegInt]
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 negativeInt
, it will return aPass
. Otherwise, the passedInt
value is 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 negative.- returns
a
Pass
if the specifiedInt
value is 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, NegInt]
A factory/validation method that produces a
NegInt
, 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
NegInt
, 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 negativeInt
, it will return aNegInt
representing that value, wrapped in aRight
. Otherwise, the passedInt
value is not 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 negative, return wrapped in aRight(NegInt)
.- returns
the specified
Int
value wrapped in aRight(NegInt)
, if it is 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[NegInt]
A factory/validation method that produces a
NegInt
, wrapped in aSuccess
, given a validInt
value, or if the givenInt
is invalid, anAssertionError
, wrapped in aFailure
.A factory/validation method that produces a
NegInt
, 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 negativeInt
, it will return aNegInt
representing that value, wrapped in aSuccess
. Otherwise, the passedInt
value is not 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 negative, return wrapped in aSuccess(NegInt)
.- returns
the specified
Int
value wrapped in aSuccess(NegInt)
, if it is 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: NegInt): Double
Implicit widening conversion from
NegInt
toDouble
.Implicit widening conversion from
NegInt
toDouble
.- pos
the
NegInt
to widen- returns
the
Int
value underlying the specifiedNegInt
, widened toDouble
.
- implicit def widenToFloat(pos: NegInt): Float
Implicit widening conversion from
NegInt
toFloat
.Implicit widening conversion from
NegInt
toFloat
.- pos
the
NegInt
to widen- returns
the
Int
value underlying the specifiedNegInt
, widened toFloat
.
- implicit def widenToInt(pos: NegInt): Int
Implicit widening conversion from
NegInt
toInt
.Implicit widening conversion from
NegInt
toInt
.- pos
the
NegInt
to widen- returns
the
Int
value underlying the specifiedNegInt
.
- implicit def widenToLong(pos: NegInt): Long
Implicit widening conversion from
NegInt
toLong
.Implicit widening conversion from
NegInt
toLong
.- pos
the
NegInt
to widen- returns
the
Int
value underlying the specifiedNegInt
, widened toLong
.
- implicit def widenToNegDouble(pos: NegInt): NegDouble
Implicit widening conversion from
NegInt
toNegDouble
.Implicit widening conversion from
NegInt
toNegDouble
.- pos
the
NegInt
to widen- returns
the
Int
value underlying the specifiedNegInt
, widened toDouble
and wrapped in aNegDouble
.
- implicit def widenToNegFloat(pos: NegInt): NegFloat
Implicit widening conversion from
NegInt
toNegFloat
.Implicit widening conversion from
NegInt
toNegFloat
.- pos
the
NegInt
to widen- returns
the
Int
value underlying the specifiedNegInt
, widened toFloat
and wrapped in aNegFloat
.
- implicit def widenToNegLong(pos: NegInt): NegLong
Implicit widening conversion from
NegInt
toNegLong
.Implicit widening conversion from
NegInt
toNegLong
.- pos
the
NegInt
to widen- returns
the
Int
value underlying the specifiedNegInt
, widened toLong
and wrapped in aNegLong
.
- implicit def widenToNegZDouble(pos: NegInt): NegZDouble
Implicit widening conversion from
NegInt
toNegZDouble
.Implicit widening conversion from
NegInt
toNegZDouble
.- pos
the
NegInt
to widen- returns
the
Int
value underlying the specifiedNegInt
, widened toDouble
and wrapped in aNegZDouble
.
- implicit def widenToNegZFloat(pos: NegInt): NegZFloat
Implicit widening conversion from
NegInt
toNegZFloat
.Implicit widening conversion from
NegInt
toNegZFloat
.- pos
the
NegInt
to widen- returns
the
Int
value underlying the specifiedNegInt
, widened toFloat
and wrapped in aNegZFloat
.
- implicit def widenToNegZInt(pos: NegInt): NegZInt
Implicit widening conversion from
NegInt
toNegZInt
.Implicit widening conversion from
NegInt
toNegZInt
.- pos
the
NegInt
to widen- returns
the
Int
value underlying the specifiedNegInt
, widened toInt
and wrapped in aNegZInt
.
- implicit def widenToNegZLong(pos: NegInt): NegZLong
Implicit widening conversion from
NegInt
toNegZLong
.Implicit widening conversion from
NegInt
toNegZLong
.- pos
the
NegInt
to widen- returns
the
Int
value underlying the specifiedNegInt
, widened toLong
and wrapped in aNegZLong
.
- implicit def widenToNonZeroDouble(pos: NegInt): NonZeroDouble
Implicit widening conversion from
NegInt
toNonZeroDouble
.Implicit widening conversion from
NegInt
toNonZeroDouble
.- pos
the
NegInt
to widen- returns
the
Int
value underlying the specifiedNegInt
, widened toDouble
and wrapped in aNonZeroDouble
.
- implicit def widenToNonZeroFloat(pos: NegInt): NonZeroFloat
Implicit widening conversion from
NegInt
toNonZeroFloat
.Implicit widening conversion from
NegInt
toNonZeroFloat
.- pos
the
NegInt
to widen- returns
the
Int
value underlying the specifiedNegInt
, widened toFloat
and wrapped in aNonZeroFloat
.
- implicit def widenToNonZeroInt(pos: NegInt): NonZeroInt
Implicit widening conversion from
NegInt
toNonZeroInt
.Implicit widening conversion from
NegInt
toNonZeroInt
.- pos
the
NegInt
to widen- returns
the
Int
value underlying the specifiedNegInt
, widened toInt
and wrapped in aNonZeroInt
.
- implicit def widenToNonZeroLong(pos: NegInt): NonZeroLong
Implicit widening conversion from
NegInt
toNonZeroLong
.Implicit widening conversion from
NegInt
toNonZeroLong
.- pos
the
NegInt
to widen- returns
the
Int
value underlying the specifiedNegInt
, widened toLong
and wrapped in aNonZeroLong
.