Skip to content

Utility extensions to boost your programming with Kotlin.

License

Notifications You must be signed in to change notification settings

Carleslc/kotlin-extensions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

KotlinExtensions

Utility extensions, properties and useful methods to boost your programming with Kotlin.

How to install

Maven

Add the following repository to your pom.xml:

<repositories>
    <repository>
        <id>central</id>
        <url>http://34.210.110.148:8081/artifactory/libs-release</url>
    </repository>
</repositories>

Add the following dependencies to your pom.xml:

<dependencies>
    <!-- KotlinExtensions -->
    <dependency>
        <groupId>me.carleslc</groupId>
        <artifactId>kotlin-extensions</artifactId>
        <version>0.4.2</version>
    </dependency>
    <!-- FunKTionale -->
    <dependency>
        <groupId>org.funktionale</groupId>
        <artifactId>funktionale-all</artifactId>
        <version>1.1</version>
    </dependency>
    <!-- Guava -->
    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>22.0</version>
    </dependency>
</dependencies>

funKTionale and guava are optional dependencies, but they are very powerful to complement this library.

Gradle

Add the following repository to your build.gradle:

repositories {
    url 'http://34.210.110.148:8081/artifactory/libs-release'
}

Add the following dependency to your build.gradle:

dependencies {
    compile 'me.carleslc:kotlin-extensions:0.4.2'
    compile 'org.funktionale:funktionale-all:1.1'
    compile 'com.google.guava:guava:22.0'
}

funKTionale and guava are optional dependencies, but they are very powerful to complement this library.

Manual

  1. git clone https://github.com/Carleslc/kotlin-extensions.git
  2. cd kotlin-extensions
  3. Build the KotlinExtensions with mvn clean install. This also adds this project to your local Maven repository.
  4. Add the kotlin-extensions-0.4.2.jar from target folder as a dependency of your project.

If you wish you can use these steps to add the dependency using Maven without accessing to the remote repository.

In addition, if needed, you can add the dependencies of funKTionale and guava as they are very powerful to complement this library.

How to use

In order to use any of the extensions or methods of KotlinExtensions you only need to import them.

Import a single extension

import me.carleslc.kotlin.extensions.standard.times

Import all extensions of a package

import me.carleslc.kotlin.extensions.standard.*

Packages available

Arrays

import me.carleslc.kotlin.extensions.arrays.*

Extensions for arrays, a syntactic-sugar way to create literal arrays like A[1, 2, 3] instead typical arrayOf(1, 2, 3) and methods to work with 2D arrays and matrices (2D arrays with fixed columns size) easier.

Bytes

import me.carleslc.kotlin.extensions.bytes.*

Extensions for memory size conversions (from bits to pebibytes and petabytes).

Inspired from ktunits library.

Collections

import me.carleslc.kotlin.extensions.collections.*

Extensions for collections, sintactic-sugar for list and set literals with L[values] or S[values] and other global methods to create collections.

Conversions

import me.carleslc.kotlin.extensions.conversions.*

Extensions for conversions between basic types.

HTML

import me.carleslc.kotlin.extensions.html.*

Extensions to generate HTML in a more readable way.

Map

import me.carleslc.kotlin.extensions.map.*

Extensions for maps and sintactic-sugar for Map literals with `M[pairs].

Number

import me.carleslc.kotlin.extensions.number.*

Extensions for numbers and math operations.

Strings

import me.carleslc.kotlin.extensions.strings.*

Extensions for strings.

Time

import me.carleslc.kotlin.extensions.time.*

Extensions for timing, format and manage time or dates easily.

Inspired from kxdate and khronos libraries.

Tuples

import me.carleslc.kotlin.extensions.tuples.*

Extensions for pairs and triples.

Standard

import me.carleslc.kotlin.extensions.standard.*

General purpose extensions and global methods that do not match any other package category (e.g. looping with 10 times { code } or 10 * { code }).

Optional Libraries

This library includes some functional extensions and classes like those of the common and most used functional languages.

import org.funktionale.collections.*
import org.funktionale.complement.*
import org.funktionale.composition.*
import org.funktionale.currying.*
import org.funktionale.either.*
import org.funktionale.memoization.*
import org.funktionale.option.*
import org.funktionale.pairing.*
import org.funktionale.partials.*
import org.funktionale.pipe.*
import org.funktionale.reverse.*
import org.funktionale.state.*
import org.funktionale.tries.*
import org.funktionale.utils.*
import org.funktionale.validation.*

This library from Google Developers includes a lot of useful classes and methods to extend the language. Is written in Java but we can use it from Kotlin with no problems.