com.tegonal.scala.commons

Members list

Value members

Concrete methods

inline def check(predicate: Boolean, inline errorMessage: => String): Unit
inline def discardReturnValue[A](evaluateForSideEffectOnly: => A): Unit

Intended to be used to explicitly state that we want to discard a return value.

Intended to be used to explicitly state that we want to discard a return value.

Attributes

Since

0.1.0

inline def failIf(predicate: Boolean, inline errorMessage: => String): Unit

Extensions

Extensions

extension (self: Boolean)
inline def not: Boolean

Negates the receiver object, turning a true into a false and a false into a true.

Negates the receiver object, turning a true into a false and a false into a true.

Attributes

Returns

the negation of the receiver object

Since

0.1.0

extension (self: CharSequence)
def isBlank: Boolean

Returns true if the receiver object CharSequence.isEmpty as well as all chars are either Character.isWhitespace or Character.isSpaceChar, false otherwise.

Returns true if the receiver object CharSequence.isEmpty as well as all chars are either Character.isWhitespace or Character.isSpaceChar, false otherwise.

Attributes

Returns

true if empty or blank, false otherwise.

Since

0.1.0

def isEmpty: Boolean

Returns true if the receiver object consists of no char, false otherwise.

Returns true if the receiver object consists of no char, false otherwise.

Attributes

Returns

true if non empty, false otherwise.

Since

0.1.0

def isNotNullNorBlank: Boolean

Returns true if the receiver object is neither null nor isBlank.

Returns true if the receiver object is neither null nor isBlank.

Attributes

Returns

true if neither null nor blank, false otherwise

Since

0.1.0

def isNotNullNorEmpty: Boolean

Returns true if the receiver object is neither null nor isEmpty.

Returns true if the receiver object is neither null nor isEmpty.

Attributes

Returns

true if neither null nor empty, false otherwise

Since

0.1.0

def nonEmpty: Boolean

Returns true if the receiver object consists of at least 1 char, false otherwise.

Returns true if the receiver object consists of at least 1 char, false otherwise.

Attributes

Returns

true if non empty, false otherwise.

Since

0.1.0

extension [T <: CharSequence](self: Option[T])
def blankToNone(): Option[T]

Turns this Option into None if the contained String is blank.

Turns this Option into None if the contained String is blank.

Attributes

Returns

None if the String is blank otherwise the String as Some.

Since

0.1.0

extension [T](self: T)
inline def as[TSub <: T]: T

Casts the receiver object to type T, inserting runtime checks where possible emitting a warning otherwise.

Casts the receiver object to type T, inserting runtime checks where possible emitting a warning otherwise.

Type parameters

TSub

the subtype to which we want to cast

Attributes

Returns

The receiver object cast to T

Since

0.1.0

inline def pipe[R](inline f: T => R): R

Applies the given function f to the receiver object.

Applies the given function f to the receiver object.

Basically the same as the scala.util.chaining.scalaUtilChainingOps, but for sure inlines and since we use it often at Tegonal and we add this library to -Yimports we automatically have it in scope.

Type parameters

R

the resulting type of the function application

Value parameters

f

the function to apply to the receiver object.

Attributes

Returns

the result of the function application

Since

0.1.0

inline def tap(inline f: T => Unit): Unit

Perform some side effect defined in the given function f based on this receiver object.

Perform some side effect defined in the given function f based on this receiver object.

Basically the same as the scala.util.chaining.scalaUtilChainingOps, but for sure inlines and since we use it often at Tegonal and we add this library to -Yimports we automatically have it in scope.

Value parameters

f

the function which is executed, passing the receiver object as input.

Attributes

Since

0.1.0

extension [T <: CharSequence](self: T)
def blankToNone(): Option[T]

Turns this String into an Option where None is used in case this String is null or blank and Some otherwise.

Turns this String into an Option where None is used in case this String is null or blank and Some otherwise.

Attributes

Returns

None if the String is blank otherwise the String as Some.

Since

0.1.0

extension [T <: CharSequence](self: Option[T])
def blankToNone(): Option[T]

Turns this Option into None if the contained String is blank.

Turns this Option into None if the contained String is blank.

Attributes

Returns

None if the String is blank otherwise the String as Some.

Since

0.1.0

extension (self: String)
def blankToNone(): Option[String]

Turns this String into an Option where None is used in case this String is null or blank and Some otherwise.

Turns this String into an Option where None is used in case this String is null or blank and Some otherwise.

Attributes

Returns

None if the String is blank otherwise the String as Some.

Since

0.1.0

extension [T <: CharSequence](self: T)
def blankToNone(): Option[T]

Turns this String into an Option where None is used in case this String is null or blank and Some otherwise.

Turns this String into an Option where None is used in case this String is null or blank and Some otherwise.

Attributes

Returns

None if the String is blank otherwise the String as Some.

Since

0.1.0

extension (self: String)
def blankToNone(): Option[String]

Turns this String into an Option where None is used in case this String is null or blank and Some otherwise.

Turns this String into an Option where None is used in case this String is null or blank and Some otherwise.

Attributes

Returns

None if the String is blank otherwise the String as Some.

Since

0.1.0

extension [T](t: Try[T])
inline def mapFailure(f: Throwable => Throwable): Try[T]

Map over the Failure of this Try.

Map over the Failure of this Try.

Value parameters

f

the function which maps the Throwable of the current Failure to a new Throwable.

Attributes

Returns

The resulting Try.

Since

0.1.0