[BAEL-19885] - Move articles out of core-kotlin part4

This commit is contained in:
catalin-burcea 2019-12-27 13:36:41 +02:00
parent b63a8c2335
commit 3254a03d8a
44 changed files with 194 additions and 57 deletions

View File

@ -5,7 +5,4 @@ This module contains articles about core Kotlin.
### Relevant articles: ### Relevant articles:
- [Kotlin Scope Functions](https://www.baeldung.com/kotlin-scope-functions) - [Kotlin Scope Functions](https://www.baeldung.com/kotlin-scope-functions)
- [Kotlin Annotations](https://www.baeldung.com/kotlin-annotations)
- [Split a List into Parts in Kotlin](https://www.baeldung.com/kotlin-split-list-into-parts)
- [Finding an Element in a List Using Kotlin](https://www.baeldung.com/kotlin-finding-element-in-list)
- More articles: [[<-- prev]](/core-kotlin) - More articles: [[<-- prev]](/core-kotlin)

View File

@ -0,0 +1,11 @@
## Core Kotlin Advanced
This module contains articles about advanced topics in Kotlin.
### Relevant articles:
- [Building DSLs in Kotlin](https://www.baeldung.com/kotlin-dsl)
- [Regular Expressions in Kotlin](https://www.baeldung.com/kotlin-regular-expressions)
- [Idiomatic Logging in Kotlin](https://www.baeldung.com/kotlin-logging)
- [Mapping of Data Objects in Kotlin](https://www.baeldung.com/kotlin-data-objects)
- [Reflection with Kotlin](https://www.baeldung.com/kotlin-reflection)
- [Kotlin Contracts](https://www.baeldung.com/kotlin-contracts)

View File

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-kotlin-advanced</artifactId>
<name>core-kotlin-advanced</name>
<packaging>jar</packaging>
<parent>
<groupId>com.baeldung.core-kotlin-modules</groupId>
<artifactId>core-kotlin-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test</artifactId>
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<kotlin.version>1.3.30</kotlin.version>
<assertj.version>3.10.0</assertj.version>
</properties>
</project>

View File

@ -3,10 +3,10 @@ package com.baeldung.datamapping
import kotlin.reflect.full.memberProperties import kotlin.reflect.full.memberProperties
fun User.toUserView() = UserView( fun User.toUserView() = UserView(
name = "$firstName $lastName", name = "$firstName $lastName",
address = "$street $houseNumber", address = "$street $houseNumber",
telephone = phone, telephone = phone,
age = age age = age
) )
fun User.toUserViewReflection() = with(::UserView) { fun User.toUserViewReflection() = with(::UserView) {

View File

@ -1,4 +1,4 @@
package com.baeldung.kotlin.dsl package com.baeldung.dsl
abstract class Condition { abstract class Condition {

View File

@ -1,4 +1,4 @@
package com.baeldung.kotlin.logging package com.baeldung.logging
import org.slf4j.Logger import org.slf4j.Logger

View File

@ -1,4 +1,4 @@
package com.baeldung.kotlin.logging package com.baeldung.logging
import org.slf4j.Logger import org.slf4j.Logger
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory

View File

@ -1,4 +1,4 @@
package com.baeldung.kotlin.logging package com.baeldung.logging
open class LoggerAsProperty { open class LoggerAsProperty {
private val logger = getLogger(javaClass) private val logger = getLogger(javaClass)

View File

@ -1,4 +1,4 @@
package com.baeldung.kotlin.logging package com.baeldung.logging
import org.slf4j.Logger import org.slf4j.Logger
import kotlin.properties.ReadOnlyProperty import kotlin.properties.ReadOnlyProperty
@ -43,5 +43,5 @@ fun main(args: Array<String>) {
class LoggerDelegate<in R : Any> : ReadOnlyProperty<R, Logger> { class LoggerDelegate<in R : Any> : ReadOnlyProperty<R, Logger> {
override fun getValue(thisRef: R, property: KProperty<*>) = override fun getValue(thisRef: R, property: KProperty<*>) =
getLogger(getClassForLogging(thisRef.javaClass)) getLogger(getClassForLogging(thisRef.javaClass))
} }

View File

@ -1,4 +1,4 @@
package com.baeldung.kotlin.logging package com.baeldung.logging
open class LoggerInCompanionObject { open class LoggerInCompanionObject {
companion object { companion object {

View File

@ -1,4 +1,4 @@
package com.baeldung.kotlin.logging package com.baeldung.logging
import org.slf4j.Logger import org.slf4j.Logger
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory

View File

@ -1,8 +1,7 @@
package com.baeldung.kotlin.dsl package com.baeldung.dsl
import org.assertj.core.api.Assertions.assertThat import org.assertj.core.api.Assertions.assertThat
import org.junit.Test import org.junit.Test
import java.lang.Exception
class SqlDslTest { class SqlDslTest {

View File

@ -1,4 +1,4 @@
package com.baeldung.kotlin.reflection package com.baeldung.reflection
import org.junit.Ignore import org.junit.Ignore
import org.junit.Test import org.junit.Test

View File

@ -1,4 +1,4 @@
package com.baeldung.kotlin.reflection package com.baeldung.reflection
import org.junit.Assert import org.junit.Assert
import org.junit.Ignore import org.junit.Ignore

View File

@ -1,4 +1,4 @@
package com.baeldung.kotlin.reflection package com.baeldung.reflection
import org.junit.Assert import org.junit.Assert
import org.junit.Test import org.junit.Test

View File

@ -1,12 +1,7 @@
package com.baeldung.kotlin.stdlib package com.baeldung.regex
import org.junit.Test import org.junit.Test
import java.beans.ExceptionListener
import java.beans.XMLEncoder
import java.io.*
import java.lang.Exception
import kotlin.test.* import kotlin.test.*
import kotlin.text.RegexOption.*
class RegexTest { class RegexTest {

View File

@ -0,0 +1,10 @@
## Core Kotlin Collections
This module contains articles about core Kotlin collections.
### Relevant articles:
- [Split a List Into Parts in Kotlin](https://www.baeldung.com/kotlin-split-list-into-parts)
- [Finding an Element in a List Using Kotlin](https://www.baeldung.com/kotlin-finding-element-in-list)
- [Overview of Kotlin Collections API](https://www.baeldung.com/kotlin-collections-api)
- [Converting a List to Map in Kotlin](https://www.baeldung.com/kotlin-list-to-map)
- [Filtering Kotlin Collections](https://www.baeldung.com/kotlin-filter-collection)

View File

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-kotlin-collections</artifactId>
<name>core-kotlin-collections</name>
<packaging>jar</packaging>
<parent>
<groupId>com.baeldung.core-kotlin-modules</groupId>
<artifactId>core-kotlin-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<version>${commons-math3.version}</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test</artifactId>
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<kotlin.version>1.3.30</kotlin.version>
<commons-math3.version>3.6.1</commons-math3.version>
<assertj.version>3.10.0</assertj.version>
</properties>
</project>

View File

@ -1,9 +1,9 @@
package com.baeldung.kotlin package com.baeldung.collections
import org.junit.Test import org.junit.Test
import kotlin.test.assertTrue
import kotlin.test.assertFalse
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFalse
import kotlin.test.assertTrue
class CollectionsTest { class CollectionsTest {
@ -142,5 +142,5 @@ class CollectionsTest {
val finalResult = theList.fold( 1000, { oldResult, currentItem -> oldResult + (currentItem *currentItem)}) val finalResult = theList.fold( 1000, { oldResult, currentItem -> oldResult + (currentItem *currentItem)})
print(finalResult) print(finalResult)
assertEquals(1091, finalResult) assertEquals(1091, finalResult)
} }
} }

View File

@ -1,11 +1,11 @@
package com.baeldung.lists package com.baeldung.findelement
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFalse import kotlin.test.assertFalse
import kotlin.test.assertTrue import kotlin.test.assertTrue
class ListsUnitTest { class FindAnElementInAListUnitTest {
var batmans: List<String> = listOf("Christian Bale", "Michael Keaton", "Ben Affleck", "George Clooney") var batmans: List<String> = listOf("Christian Bale", "Michael Keaton", "Ben Affleck", "George Clooney")

View File

@ -1,4 +1,4 @@
package com.baeldung.kotlin package com.baeldung.listtomap
import org.junit.Test import org.junit.Test
import kotlin.test.assertTrue import kotlin.test.assertTrue

View File

@ -0,0 +1,3 @@
package com.baeldung.listtomap
data class User(val name: String, val age: Int, val hobbies: List<String>)

View File

@ -1,9 +1,9 @@
package com.baeldung.lambda package com.baeldung.splitlist
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import kotlin.test.assertEquals import kotlin.test.assertEquals
class SplittingTest { class SplitListIntoPartsTest {
private val evenList = listOf(0, "a", 1, "b", 2, "c"); private val evenList = listOf(0, "a", 1, "b", 2, "c");
private val unevenList = listOf(0, "a", 1, "b", 2, "c", 3); private val unevenList = listOf(0, "a", 1, "b", 2, "c", 3);

View File

@ -0,0 +1,7 @@
## Core Kotlin Concurrency
This module contains articles about concurrency in Kotlin.
### Relevant articles:
- [Threads vs Coroutines in Kotlin](https://www.baeldung.com/kotlin-threads-coroutines)
- [Introduction to Kotlin Coroutines](https://www.baeldung.com/kotlin-coroutines)

View File

@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-kotlin-concurrency</artifactId>
<name>core-kotlin-concurrency</name>
<packaging>jar</packaging>
<parent>
<groupId>com.baeldung.core-kotlin-modules</groupId>
<artifactId>core-kotlin-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test</artifactId>
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<kotlin.version>1.3.30</kotlin.version>
<assertj.version>3.10.0</assertj.version>
</properties>
</project>

View File

@ -1,4 +1,4 @@
package com.baeldung.thread package com.baeldung.threadsvscoroutines
class SimpleRunnable: Runnable { class SimpleRunnable: Runnable {

View File

@ -1,4 +1,4 @@
package com.baeldung.thread package com.baeldung.threadsvscoroutines
class SimpleThread: Thread() { class SimpleThread: Thread() {

View File

@ -1,4 +1,4 @@
package com.baeldung.kotlin package com.baeldung.coroutines
import kotlinx.coroutines.* import kotlinx.coroutines.*
import org.junit.Test import org.junit.Test

View File

@ -1,4 +1,4 @@
package com.baeldung.thread package com.baeldung.threadsvscoroutines
import kotlinx.coroutines.* import kotlinx.coroutines.*
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test

View File

@ -1,4 +1,4 @@
package com.baeldung.thread package com.baeldung.threadsvscoroutines
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import kotlin.concurrent.thread import kotlin.concurrent.thread

View File

@ -15,7 +15,10 @@
</parent> </parent>
<modules> <modules>
<module>core-kotlin-advanced</module>
<module>core-kotlin-annotations</module> <module>core-kotlin-annotations</module>
<module>core-kotlin-collections</module>
<module>core-kotlin-concurrency</module>
<module>core-kotlin-io</module> <module>core-kotlin-io</module>
<module>core-kotlin-lang</module> <module>core-kotlin-lang</module>
<module>core-kotlin-lang-2</module> <module>core-kotlin-lang-2</module>

View File

@ -7,37 +7,26 @@ This module contains articles about core Kotlin.
- [Introduction to the Kotlin Language](https://www.baeldung.com/kotlin) - [Introduction to the Kotlin Language](https://www.baeldung.com/kotlin)
- [Kotlin Java Interoperability](https://www.baeldung.com/kotlin-java-interoperability) - [Kotlin Java Interoperability](https://www.baeldung.com/kotlin-java-interoperability)
- [Generics in Kotlin](https://www.baeldung.com/kotlin-generics) - [Generics in Kotlin](https://www.baeldung.com/kotlin-generics)
- [Introduction to Kotlin Coroutines](https://www.baeldung.com/kotlin-coroutines)
- [Overview of Kotlin Collections API](https://www.baeldung.com/kotlin-collections-api)
- [Converting a List to Map in Kotlin](https://www.baeldung.com/kotlin-list-to-map)
- [Data Classes in Kotlin](https://www.baeldung.com/kotlin-data-classes) - [Data Classes in Kotlin](https://www.baeldung.com/kotlin-data-classes)
- [Delegated Properties in Kotlin](https://www.baeldung.com/kotlin-delegated-properties) - [Delegated Properties in Kotlin](https://www.baeldung.com/kotlin-delegated-properties)
- [Sealed Classes in Kotlin](https://www.baeldung.com/kotlin-sealed-classes) - [Sealed Classes in Kotlin](https://www.baeldung.com/kotlin-sealed-classes)
- [JUnit 5 for Kotlin Developers](https://www.baeldung.com/junit-5-kotlin) - [JUnit 5 for Kotlin Developers](https://www.baeldung.com/junit-5-kotlin)
- [Extension Methods in Kotlin](https://www.baeldung.com/kotlin-extension-methods) - [Extension Methods in Kotlin](https://www.baeldung.com/kotlin-extension-methods)
- [Regular Expressions in Kotlin](https://www.baeldung.com/kotlin-regular-expressions)
- [Objects in Kotlin](https://www.baeldung.com/kotlin-objects) - [Objects in Kotlin](https://www.baeldung.com/kotlin-objects)
- [Filtering Kotlin Collections](https://www.baeldung.com/kotlin-filter-collection)
- [Working with Enums in Kotlin](https://www.baeldung.com/kotlin-enum) - [Working with Enums in Kotlin](https://www.baeldung.com/kotlin-enum)
- [Create a Java and Kotlin Project with Maven](https://www.baeldung.com/kotlin-maven-java-project) - [Create a Java and Kotlin Project with Maven](https://www.baeldung.com/kotlin-maven-java-project)
- [Reflection with Kotlin](https://www.baeldung.com/kotlin-reflection)
- [Get a Random Number in Kotlin](https://www.baeldung.com/kotlin-random-number) - [Get a Random Number in Kotlin](https://www.baeldung.com/kotlin-random-number)
- [Idiomatic Logging in Kotlin](https://www.baeldung.com/kotlin-logging)
- [Kotlin Constructors](https://www.baeldung.com/kotlin-constructors) - [Kotlin Constructors](https://www.baeldung.com/kotlin-constructors)
- [Creational Design Patterns in Kotlin: Builder](https://www.baeldung.com/kotlin-builder-pattern) - [Creational Design Patterns in Kotlin: Builder](https://www.baeldung.com/kotlin-builder-pattern)
- [Kotlin Nested and Inner Classes](https://www.baeldung.com/kotlin-inner-classes) - [Kotlin Nested and Inner Classes](https://www.baeldung.com/kotlin-inner-classes)
- [Fuel HTTP Library with Kotlin](https://www.baeldung.com/kotlin-fuel) - [Fuel HTTP Library with Kotlin](https://www.baeldung.com/kotlin-fuel)
- [Introduction to Kovenant Library for Kotlin](https://www.baeldung.com/kotlin-kovenant) - [Introduction to Kovenant Library for Kotlin](https://www.baeldung.com/kotlin-kovenant)
- [Converting Kotlin Data Class from JSON using GSON](https://www.baeldung.com/kotlin-json-convert-data-class) - [Converting Kotlin Data Class from JSON using GSON](https://www.baeldung.com/kotlin-json-convert-data-class)
- [Mapping of Data Objects in Kotlin](https://www.baeldung.com/kotlin-data-objects)
- [Threads vs Coroutines in Kotlin](https://www.baeldung.com/kotlin-threads-coroutines)
- [Guide to Kotlin Interfaces](https://www.baeldung.com/kotlin-interfaces) - [Guide to Kotlin Interfaces](https://www.baeldung.com/kotlin-interfaces)
- [Guide to Sorting in Kotlin](https://www.baeldung.com/kotlin-sort) - [Guide to Sorting in Kotlin](https://www.baeldung.com/kotlin-sort)
- [Dependency Injection for Kotlin with Injekt](https://www.baeldung.com/kotlin-dependency-injection-with-injekt) - [Dependency Injection for Kotlin with Injekt](https://www.baeldung.com/kotlin-dependency-injection-with-injekt)
- [Implementing a Binary Tree in Kotlin](https://www.baeldung.com/kotlin-binary-tree) - [Implementing a Binary Tree in Kotlin](https://www.baeldung.com/kotlin-binary-tree)
- [Kotlin Contracts](https://www.baeldung.com/kotlin-contracts)
- [Inline Classes in Kotlin](https://www.baeldung.com/kotlin-inline-classes) - [Inline Classes in Kotlin](https://www.baeldung.com/kotlin-inline-classes)
- [Building DSLs in Kotlin](https://www.baeldung.com/kotlin-dsl)
- [Static Methods Behavior in Kotlin](https://www.baeldung.com/kotlin-static-methods) - [Static Methods Behavior in Kotlin](https://www.baeldung.com/kotlin-static-methods)
- [Delegation Pattern in Kotlin](https://www.baeldung.com/kotlin-delegation-pattern) - [Delegation Pattern in Kotlin](https://www.baeldung.com/kotlin-delegation-pattern)
- More articles: [[next -->]](/core-kotlin-2) - More articles: [[next -->]](/core-kotlin-2)

View File

@ -14,11 +14,6 @@
</parent> </parent>
<dependencies> <dependencies>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-math3</artifactId>
<version>${commons-math3.version}</version>
</dependency>
<dependency> <dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId> <artifactId>commons-lang3</artifactId>
@ -75,7 +70,6 @@
</dependencies> </dependencies>
<properties> <properties>
<commons-math3.version>3.6.1</commons-math3.version>
<junit.platform.version>1.1.1</junit.platform.version> <junit.platform.version>1.1.1</junit.platform.version>
<junit.vintage.version>5.2.0</junit.vintage.version> <junit.vintage.version>5.2.0</junit.vintage.version>
<assertj.version>3.10.0</assertj.version> <assertj.version>3.10.0</assertj.version>