Package dev.inmo.micro_utils.common

Types

ByteArrayAllocator
Link copied to clipboard
typealias ByteArrayAllocator = () -> ByteArray
typealias ByteArrayAllocator = () -> ByteArray
typealias ByteArrayAllocator = () -> ByteArray
ByteArrayAllocatorSerializer
Link copied to clipboard
object ByteArrayAllocatorSerializer : KSerializer<ByteArrayAllocator>
object ByteArrayAllocatorSerializer : KSerializer<ByteArrayAllocator>
object ByteArrayAllocatorSerializer : KSerializer<ByteArrayAllocator>
Diff
Link copied to clipboard
data class Diff<T>

Diff object which contains information about differences between two Iterables

data class Diff<T>

Diff object which contains information about differences between two Iterables

data class Diff<T>

Diff object which contains information about differences between two Iterables

Either
Link copied to clipboard
interface Either<T1, T2>

Realization of this interface will contains at least one not null - optionalT1 or optionalT2

interface Either<T1, T2>

Realization of this interface will contains at least one not null - optionalT1 or optionalT2

interface Either<T1, T2>

Realization of this interface will contains at least one not null - optionalT1 or optionalT2

EitherFirst
Link copied to clipboard
data class EitherFirst<T1, T2>(t1: T1) : Either<T1, T2>

This type Either will always have not nullable optionalT1

data class EitherFirst<T1, T2>(t1: T1) : Either<T1, T2>

This type Either will always have not nullable optionalT1

data class EitherFirst<T1, T2>(t1: T1) : Either<T1, T2>

This type Either will always have not nullable optionalT1

EitherSecond
Link copied to clipboard
data class EitherSecond<T1, T2>(t2: T2) : Either<T1, T2>

This type Either will always have not nullable optionalT2

data class EitherSecond<T1, T2>(t2: T2) : Either<T1, T2>

This type Either will always have not nullable optionalT2

data class EitherSecond<T1, T2>(t2: T2) : Either<T1, T2>

This type Either will always have not nullable optionalT2

EitherSerializer
Link copied to clipboard
class EitherSerializer<T1, T2>(t1Serializer: KSerializer<T1>, t2Serializer: KSerializer<T2>) : KSerializer<Either<T1, T2>>
class EitherSerializer<T1, T2>(t1Serializer: KSerializer<T1>, t2Serializer: KSerializer<T2>) : KSerializer<Either<T1, T2>>
class EitherSerializer<T1, T2>(t1Serializer: KSerializer<T1>, t2Serializer: KSerializer<T2>) : KSerializer<Either<T1, T2>>
FileName
Link copied to clipboard
value class FileName(string: String)
value class FileName(string: String)
value class FileName(string: String)
MPPFile
Link copied to clipboard
expect class MPPFile
expect class MPPFile
expect class MPPFile
Optional
Link copied to clipboard
data class Optional<T>

This type represents T as not only potentially nullable data, but also as a data which can not be presented. This type will be useful in cases when T is nullable and null as valuable data too in time of data absence should be presented by some third type.

data class Optional<T>

This type represents T as not only potentially nullable data, but also as a data which can not be presented. This type will be useful in cases when T is nullable and null as valuable data too in time of data absence should be presented by some third type.

data class Optional<T>

This type represents T as not only potentially nullable data, but also as a data which can not be presented. This type will be useful in cases when T is nullable and null as valuable data too in time of data absence should be presented by some third type.

SuspendByteArrayAllocator
Link copied to clipboard
typealias SuspendByteArrayAllocator = suspend () -> ByteArray
typealias SuspendByteArrayAllocator = suspend () -> ByteArray
typealias SuspendByteArrayAllocator = suspend () -> ByteArray

Functions

asAllocator
Link copied to clipboard
suspend fun SuspendByteArrayAllocator.asAllocator(): ByteArrayAllocator
suspend fun SuspendByteArrayAllocator.asAllocator(): ByteArrayAllocator
suspend fun SuspendByteArrayAllocator.asAllocator(): ByteArrayAllocator
bytes
Link copied to clipboard
suspend fun MPPFile.bytes(): ByteArray
suspend fun MPPFile.bytes(): ByteArray
suspend fun MPPFile.bytes(): ByteArray
bytesSync
Link copied to clipboard
fun MPPFile.bytesSync(): ByteArray
fun MPPFile.bytesSync(): ByteArray
fun MPPFile.bytesSync(): ByteArray
calculateDiff
Link copied to clipboard
fun <T> Iterable<T>.calculateDiff(other: Iterable<T>, strictComparison: Boolean = false): Diff<T>

Calculating Diff object

fun <T> Iterable<T>.calculateDiff(other: Iterable<T>, strictComparison: Boolean = false): Diff<T>

Calculating Diff object

fun <T> Iterable<T>.calculateDiff(other: Iterable<T>, strictComparison: Boolean = false): Diff<T>

Calculating Diff object

calculateStrictDiff
Link copied to clipboard
inline fun <T> Iterable<T>.calculateStrictDiff(other: Iterable<T>): Diff<T>

This method call calculateDiff with strict mode enabled

inline fun <T> Iterable<T>.calculateStrictDiff(other: Iterable<T>): Diff<T>

This method call calculateDiff with strict mode enabled

inline fun <T> Iterable<T>.calculateStrictDiff(other: Iterable<T>): Diff<T>

This method call calculateDiff with strict mode enabled

Link copied to clipboard
fun View.changeVisibility(show: Boolean = !isShown, goneOnHide: Boolean = true)
Link copied to clipboard
fun View.collapse(duration: Long = 500)
Link copied to clipboard
fun View.collapseHorizontally(duration: Long = 500)
dataOrElse
Link copied to clipboard
inline fun <T> Optional<T>.dataOrElse(block: () -> T): T

Returns Optional.data if Optional.dataPresented of this is true, or call block and returns the result of it

inline fun <T> Optional<T>.dataOrElse(block: () -> T): T

Returns Optional.data if Optional.dataPresented of this is true, or call block and returns the result of it

inline fun <T> Optional<T>.dataOrElse(block: () -> T): T

Returns Optional.data if Optional.dataPresented of this is true, or call block and returns the result of it

dataOrNull
Link copied to clipboard
fun <T> Optional<T>.dataOrNull(): T?

Returns Optional.data if Optional.dataPresented of this is true, or null otherwise

fun <T> Optional<T>.dataOrNull(): T?

Returns Optional.data if Optional.dataPresented of this is true, or null otherwise

fun <T> Optional<T>.dataOrNull(): T?

Returns Optional.data if Optional.dataPresented of this is true, or null otherwise

dataOrThrow
Link copied to clipboard
fun <T> Optional<T>.dataOrThrow(throwable: Throwable): T

Returns Optional.data if Optional.dataPresented of this is true, or throw throwable otherwise

fun <T> Optional<T>.dataOrThrow(throwable: Throwable): T

Returns Optional.data if Optional.dataPresented of this is true, or throw throwable otherwise

fun <T> Optional<T>.dataOrThrow(throwable: Throwable): T

Returns Optional.data if Optional.dataPresented of this is true, or throw throwable otherwise

Diff
Link copied to clipboard
inline fun <T> Iterable<T>.diff(other: Iterable<T>, strictComparison: Boolean = false): Diff<T>
inline fun <T> Iterable<T>.diff(other: Iterable<T>, strictComparison: Boolean = false): Diff<T>
inline fun <T> Iterable<T>.diff(other: Iterable<T>, strictComparison: Boolean = false): Diff<T>
Link copied to clipboard
fun View.disable()
either
Link copied to clipboard
inline fun <T1, T2> Any.either(): Either<T1, T2>
inline fun <T1, T2> Any.either(): Either<T1, T2>
inline fun <T1, T2> Any.either(): Either<T1, T2>
Link copied to clipboard
fun View.enable()
Link copied to clipboard
fun View.expand(duration: Long = 500, targetWidth: Int = ViewGroup.LayoutParams.MATCH_PARENT, targetHeight: Int = ViewGroup.LayoutParams.WRAP_CONTENT)
Link copied to clipboard
fun View.expandHorizontally(duration: Long = 500, targetWidth: Int = ViewGroup.LayoutParams.MATCH_PARENT, targetHeight: Int = ViewGroup.LayoutParams.WRAP_CONTENT)
first
Link copied to clipboard
inline fun <T1, T2> Either.Companion.first(t1: T1): Either<T1, T2>
inline fun <T1, T2> Either.Companion.first(t1: T1): Either<T1, T2>
inline fun <T1, T2> Either.Companion.first(t1: T1): Either<T1, T2>
firstNotNull
Link copied to clipboard
fun <T> Iterable<T?>.firstNotNull(): T
fun <T> Iterable<T?>.firstNotNull(): T
fun <T> Iterable<T?>.firstNotNull(): T
Link copied to clipboard
inline fun Resources.getDp(resId: Int): Float
Link copied to clipboard
inline fun Resources.getSp(resId: Int): Float
Link copied to clipboard
inline fun View.gone()
Link copied to clipboard
inline fun View.hide()
intersect
Link copied to clipboard
fun <T : Comparable<T>> ClosedRange<T>.intersect(other: ClosedRange<T>): Pair<T, T>?
fun IntRange.intersect(other: IntRange): IntRange?
fun LongRange.intersect(other: LongRange): LongRange?
fun <T : Comparable<T>> ClosedRange<T>.intersect(other: ClosedRange<T>): Pair<T, T>?
fun IntRange.intersect(other: IntRange): IntRange?
fun LongRange.intersect(other: LongRange): LongRange?
fun <T : Comparable<T>> ClosedRange<T>.intersect(other: ClosedRange<T>): Pair<T, T>?
fun IntRange.intersect(other: IntRange): IntRange?
fun LongRange.intersect(other: LongRange): LongRange?
joinTo
Link copied to clipboard
inline fun <I> Iterable<I>.joinTo(separator: I? = null, prefix: I? = null, postfix: I? = null): List<I>
inline fun <I> Iterable<I>.joinTo(separatorFun: (I) -> I?, prefix: I? = null, postfix: I? = null): List<I>
inline fun <I, R> Array<I>.joinTo(separator: R? = null, prefix: R? = null, postfix: R? = null, transform: (I) -> R?): Array<R>
inline fun <I, R> Array<I>.joinTo(separatorFun: (I) -> R?, prefix: R? = null, postfix: R? = null, transform: (I) -> R?): Array<R>
inline fun <I, R> Iterable<I>.joinTo(separator: R? = null, prefix: R? = null, postfix: R? = null, transform: (I) -> R?): List<R>
inline fun <I, R> Iterable<I>.joinTo(separatorFun: (I) -> R?, prefix: R? = null, postfix: R? = null, transform: (I) -> R?): List<R>
inline fun <I> Iterable<I>.joinTo(separator: I? = null, prefix: I? = null, postfix: I? = null): List<I>
inline fun <I> Iterable<I>.joinTo(separatorFun: (I) -> I?, prefix: I? = null, postfix: I? = null): List<I>
inline fun <I, R> Array<I>.joinTo(separator: R? = null, prefix: R? = null, postfix: R? = null, transform: (I) -> R?): Array<R>
inline fun <I, R> Array<I>.joinTo(separatorFun: (I) -> R?, prefix: R? = null, postfix: R? = null, transform: (I) -> R?): Array<R>
inline fun <I, R> Iterable<I>.joinTo(separator: R? = null, prefix: R? = null, postfix: R? = null, transform: (I) -> R?): List<R>
inline fun <I, R> Iterable<I>.joinTo(separatorFun: (I) -> R?, prefix: R? = null, postfix: R? = null, transform: (I) -> R?): List<R>
inline fun <I> Iterable<I>.joinTo(separator: I? = null, prefix: I? = null, postfix: I? = null): List<I>
inline fun <I> Iterable<I>.joinTo(separatorFun: (I) -> I?, prefix: I? = null, postfix: I? = null): List<I>
inline fun <I, R> Array<I>.joinTo(separator: R? = null, prefix: R? = null, postfix: R? = null, transform: (I) -> R?): Array<R>
inline fun <I, R> Array<I>.joinTo(separatorFun: (I) -> R?, prefix: R? = null, postfix: R? = null, transform: (I) -> R?): Array<R>
inline fun <I, R> Iterable<I>.joinTo(separator: R? = null, prefix: R? = null, postfix: R? = null, transform: (I) -> R?): List<R>
inline fun <I, R> Iterable<I>.joinTo(separatorFun: (I) -> R?, prefix: R? = null, postfix: R? = null, transform: (I) -> R?): List<R>
Link copied to clipboard
inline fun <T, R> Array<T>.mapNotNullA(mapper: (T) -> R?): List<R>
inline fun <T, R> Iterable<T>.mapNotNullA(transform: (T) -> R?): List<R>
mapOnAbsent
Link copied to clipboard
inline fun <T, R> Optional<T>.mapOnAbsent(block: () -> R): R?

Will call block when data presented (Optional.dataPresented == true)

inline fun <T, R> Optional<T>.mapOnAbsent(block: () -> R): R?

Will call block when data presented (Optional.dataPresented == true)

inline fun <T, R> Optional<T>.mapOnAbsent(block: () -> R): R?

Will call block when data presented (Optional.dataPresented == true)

mapOnFirst
Link copied to clipboard
inline fun <T1, R> Either<T1, *>.mapOnFirst(block: (T1) -> R): R?
inline fun <T1, R> Either<T1, *>.mapOnFirst(block: (T1) -> R): R?
inline fun <T1, R> Either<T1, *>.mapOnFirst(block: (T1) -> R): R?
mapOnPresented
Link copied to clipboard
inline fun <T, R> Optional<T>.mapOnPresented(block: (T) -> R): R?

Will call block when data presented (Optional.dataPresented == true)

inline fun <T, R> Optional<T>.mapOnPresented(block: (T) -> R): R?

Will call block when data presented (Optional.dataPresented == true)

inline fun <T, R> Optional<T>.mapOnPresented(block: (T) -> R): R?

Will call block when data presented (Optional.dataPresented == true)

mapOnSecond
Link copied to clipboard
inline fun <T2, R> Either<*, T2>.mapOnSecond(block: (T2) -> R): R?
inline fun <T2, R> Either<*, T2>.mapOnSecond(block: (T2) -> R): R?
inline fun <T2, R> Either<*, T2>.mapOnSecond(block: (T2) -> R): R?
onAbsent
Link copied to clipboard
inline fun <T> Optional<T>.onAbsent(block: () -> Unit): Optional<T>

Will call block when data absent (Optional.dataPresented == false)

inline fun <T> Optional<T>.onAbsent(block: () -> Unit): Optional<T>

Will call block when data absent (Optional.dataPresented == false)

inline fun <T> Optional<T>.onAbsent(block: () -> Unit): Optional<T>

Will call block when data absent (Optional.dataPresented == false)

onFirst
Link copied to clipboard
inline fun <T1, T2, E : Either<T1, T2>> E.onFirst(block: (T1) -> Unit): E

Will call block in case when this is EitherFirst

inline fun <T1, T2, E : Either<T1, T2>> E.onFirst(block: (T1) -> Unit): E

Will call block in case when this is EitherFirst

inline fun <T1, T2, E : Either<T1, T2>> E.onFirst(block: (T1) -> Unit): E

Will call block in case when this is EitherFirst

onPresented
Link copied to clipboard
inline fun <T> Optional<T>.onPresented(block: (T) -> Unit): Optional<T>

Will call block when data presented (Optional.dataPresented == true)

inline fun <T> Optional<T>.onPresented(block: (T) -> Unit): Optional<T>

Will call block when data presented (Optional.dataPresented == true)

inline fun <T> Optional<T>.onPresented(block: (T) -> Unit): Optional<T>

Will call block when data presented (Optional.dataPresented == true)

onSecond
Link copied to clipboard
inline fun <T1, T2, E : Either<T1, T2>> E.onSecond(block: (T2) -> Unit): E

Will call block in case when this is EitherSecond

inline fun <T1, T2, E : Either<T1, T2>> E.onSecond(block: (T2) -> Unit): E

Will call block in case when this is EitherSecond

inline fun <T1, T2, E : Either<T1, T2>> E.onSecond(block: (T2) -> Unit): E

Will call block in case when this is EitherSecond

repeatOnFailure
Link copied to clipboard
inline fun <R> repeatOnFailure(times: Int, onEachFailure: (Throwable) -> Unit = {}, action: (Int) -> R): Optional<R>

Executes the given action until getting of successful result specified number of times.

inline fun <R> repeatOnFailure(times: Int, onEachFailure: (Throwable) -> Unit = {}, action: (Int) -> R): Optional<R>

Executes the given action until getting of successful result specified number of times.

inline fun <R> repeatOnFailure(times: Int, onEachFailure: (Throwable) -> Unit = {}, action: (Int) -> R): Optional<R>

Executes the given action until getting of successful result specified number of times.

second
Link copied to clipboard
inline fun <T1, T2> Either.Companion.second(t2: T2): Either<T1, T2>
inline fun <T1, T2> Either.Companion.second(t2: T2): Either<T1, T2>
inline fun <T1, T2> Either.Companion.second(t2: T2): Either<T1, T2>
Link copied to clipboard
inline fun View.show()
StrictDiff
Link copied to clipboard
inline fun <T> StrictDiff(old: Iterable<T>, new: Iterable<T>): Diff<T>
inline fun <T> StrictDiff(old: Iterable<T>, new: Iterable<T>): Diff<T>
inline fun <T> StrictDiff(old: Iterable<T>, new: Iterable<T>): Diff<T>
Link copied to clipboard
fun View.toggleEnabledState(enabled: Boolean)
Link copied to clipboard
fun View.toggleExpandHorizontallyState(duration: Long = 500): Boolean
Link copied to clipboard
fun View.toggleExpandState(duration: Long = 500): Boolean
Link copied to clipboard
fun View.toggleVisibility(goneOnHide: Boolean = true)

Properties

Link copied to clipboard
val ByteArray.asAllocator: ByteArrayAllocator
Link copied to clipboard
val ByteArray.asAllocator: ByteArrayAllocator
Link copied to clipboard
val ByteArray.asAllocator: ByteArrayAllocator
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
expect val MPPFile.bytesAllocator: SuspendByteArrayAllocator
Link copied to clipboard
expect val MPPFile.bytesAllocator: SuspendByteArrayAllocator
Link copied to clipboard
expect val MPPFile.bytesAllocator: SuspendByteArrayAllocator
Link copied to clipboard
expect val MPPFile.bytesAllocatorSync: ByteArrayAllocator
Link copied to clipboard
expect val MPPFile.bytesAllocatorSync: ByteArrayAllocator
Link copied to clipboard
expect val MPPFile.bytesAllocatorSync: ByteArrayAllocator
Link copied to clipboard
val View.disabled: Boolean
Link copied to clipboard
val View.enabled: Boolean
Link copied to clipboard
expect val MPPFile.filename: FileName
Link copied to clipboard
expect val MPPFile.filename: FileName
Link copied to clipboard
expect val MPPFile.filename: FileName
Link copied to clipboard
expect val MPPFile.filesize: Long
Link copied to clipboard
expect val MPPFile.filesize: Long
Link copied to clipboard
expect val MPPFile.filesize: Long
Link copied to clipboard
val View.gone: Boolean
Link copied to clipboard
val View.hidden: Boolean
Link copied to clipboard
val View.isCollapsed: Boolean
Link copied to clipboard
val View.isExpanded: Boolean
Link copied to clipboard
val <T> T.optional: Optional<T>
Link copied to clipboard
val <T> T.optional: Optional<T>
Link copied to clipboard
val <T> T.optional: Optional<T>
Link copied to clipboard
val View.shown: Boolean