From 93c79bf9c759f5c4de37310fdc387d673cb30879 Mon Sep 17 00:00:00 2001 From: catalin-burcea Date: Mon, 16 Dec 2019 16:26:38 +0200 Subject: [PATCH 01/11] [BAEL-19883] - Move articles out of core-kotlin part2 --- core-kotlin-2/README.md | 3 --- core-kotlin-modules/core-kotlin-lang-2/README.md | 13 +++++++++++++ core-kotlin-modules/core-kotlin-lang-2/pom.xml | 16 ++++++++++++++++ .../lazy/ClassWithHeavyInitialization.java | 0 .../main/kotlin/com/baeldung/lambda/Lambda.kt | 0 .../com/baeldung/lazy}/LazyJavaUnitTest.java | 4 +--- .../ArrayInitializationTest.kt | 2 +- .../com/baeldung}/constant/ConstantUnitTest.kt | 4 ++-- .../constant/TestKotlinConstantClass.kt | 2 +- .../constant/TestKotlinConstantObject.kt | 2 +- .../infixfunctions}/InfixFunctionsTest.kt | 2 +- .../baeldung/lambda/LambdaKotlinUnitTest.java | 0 .../kotlin/com/baeldung/lambda/LambdaTest.kt | 1 + .../kotlin/com/baeldung/lazy}/LazyUnitTest.kt | 2 +- .../com/baeldung/nullsafety}/NullSafetyTest.kt | 3 ++- .../structuraljump}/StructuralJumpUnitTest.kt | 2 +- core-kotlin-modules/core-kotlin-lang/README.md | 16 ++++++++++++++++ core-kotlin-modules/core-kotlin-lang/pom.xml | 16 ++++++++++++++++ .../baeldung/destructuringdeclarations/Person.kt | 0 .../baeldung/destructuringdeclarations/Result.kt | 0 .../destructuringdeclarations/Sandbox.kt | 2 -- .../com/baeldung/equalityoperators}/User.kt | 2 +- .../main/kotlin/com/baeldung/forEach/forEach.kt | 0 .../main/kotlin/com/baeldung/inline}/Inline.kt | 2 +- .../main/kotlin/com/baeldung/operators/Money.kt | 0 .../main/kotlin/com/baeldung/operators/Page.kt | 0 .../main/kotlin/com/baeldung/operators/Point.kt | 0 .../main/kotlin/com/baeldung/operators/Utils.kt | 0 .../main/kotlin/com/baeldung/range/CharRange.kt | 0 .../src/main/kotlin/com/baeldung/range/Color.kt | 0 .../src/main/kotlin/com/baeldung/range/Filter.kt | 0 .../main/kotlin/com/baeldung/range/FirstLast.kt | 0 .../com/baeldung/range/OtherRangeFunctions.kt | 0 .../src/main/kotlin/com/baeldung/range/Range.kt | 0 .../kotlin/com/baeldung/range/ReverseRange.kt | 0 .../src/main/kotlin/com/baeldung/range/Step.kt | 0 .../main/kotlin/com/baeldung/range/UntilRange.kt | 0 .../com/baeldung/rangeiterator}/CustomColor.kt | 6 +++--- .../com/baeldung/whenblock}/WhenBlockTypes.kt | 2 +- .../baeldung/equalityoperators}/EqualityTest.kt | 2 +- .../kotlin/com/baeldung/operators/PageTest.kt | 0 .../kotlin/com/baeldung/operators/PointTest.kt | 0 .../kotlin/com/baeldung/operators/UtilsTest.kt | 0 .../kotlin/com/baeldung/range/CharRangeTest.kt | 0 .../test/kotlin/com/baeldung/range/ColorTest.kt | 0 .../test/kotlin/com/baeldung/range/FilterTest.kt | 0 .../kotlin/com/baeldung/range/FirstLastTest.kt | 0 .../baeldung/range/OtherRangeFunctionsTest.kt | 0 .../test/kotlin/com/baeldung/range/RangeTest.kt | 0 .../com/baeldung/range/ReverseRangeTest.kt | 0 .../test/kotlin/com/baeldung/range/StepTest.kt | 0 .../kotlin/com/baeldung/range/UntilRangeTest.kt | 0 .../baeldung/rangeiterator}/CustomColorTest.kt | 2 +- .../com/baeldung/trywithresource}/UseTest.kt | 2 +- .../com/baeldung}/voidtypes/VoidTypesUnitTest.kt | 0 .../com/baeldung/whenblock}/WhenBlockUnitTest.kt | 2 +- core-kotlin-modules/pom.xml | 2 ++ core-kotlin/README.md | 14 -------------- 58 files changed, 85 insertions(+), 41 deletions(-) create mode 100644 core-kotlin-modules/core-kotlin-lang-2/README.md create mode 100644 core-kotlin-modules/core-kotlin-lang-2/pom.xml rename {core-kotlin => core-kotlin-modules/core-kotlin-lang-2}/src/main/java/com/baeldung/lazy/ClassWithHeavyInitialization.java (100%) rename {core-kotlin => core-kotlin-modules/core-kotlin-lang-2}/src/main/kotlin/com/baeldung/lambda/Lambda.kt (100%) rename {core-kotlin/src/test/java/com/baeldung/kotlin => core-kotlin-modules/core-kotlin-lang-2/src/test/java/com/baeldung/lazy}/LazyJavaUnitTest.java (86%) rename {core-kotlin/src/test/kotlin/com/baeldung/kotlin => core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/arrayinitialization}/ArrayInitializationTest.kt (96%) rename {core-kotlin/src/test/kotlin/com/baeldung/kotlin => core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung}/constant/ConstantUnitTest.kt (79%) rename {core-kotlin/src/test/kotlin/com/baeldung/kotlin => core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung}/constant/TestKotlinConstantClass.kt (75%) rename {core-kotlin/src/test/kotlin/com/baeldung/kotlin => core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung}/constant/TestKotlinConstantObject.kt (87%) rename {core-kotlin/src/test/kotlin/com/baeldung/kotlin => core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/infixfunctions}/InfixFunctionsTest.kt (97%) rename {core-kotlin/src/test/java => core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin}/com/baeldung/lambda/LambdaKotlinUnitTest.java (100%) rename {core-kotlin => core-kotlin-modules/core-kotlin-lang-2}/src/test/kotlin/com/baeldung/lambda/LambdaTest.kt (99%) rename {core-kotlin/src/test/kotlin/com/baeldung/kotlin => core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/lazy}/LazyUnitTest.kt (98%) rename {core-kotlin/src/test/kotlin/com/baeldung/kotlin => core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/nullsafety}/NullSafetyTest.kt (99%) rename {core-kotlin/src/test/kotlin/com/baeldung/kotlin => core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/structuraljump}/StructuralJumpUnitTest.kt (98%) create mode 100644 core-kotlin-modules/core-kotlin-lang/README.md create mode 100644 core-kotlin-modules/core-kotlin-lang/pom.xml rename {core-kotlin => core-kotlin-modules/core-kotlin-lang}/src/main/kotlin/com/baeldung/destructuringdeclarations/Person.kt (100%) rename {core-kotlin => core-kotlin-modules/core-kotlin-lang}/src/main/kotlin/com/baeldung/destructuringdeclarations/Result.kt (100%) rename {core-kotlin => core-kotlin-modules/core-kotlin-lang}/src/main/kotlin/com/baeldung/destructuringdeclarations/Sandbox.kt (94%) rename {core-kotlin/src/main/kotlin/com/baeldung/kotlin => core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/equalityoperators}/User.kt (66%) rename {core-kotlin => core-kotlin-modules/core-kotlin-lang}/src/main/kotlin/com/baeldung/forEach/forEach.kt (100%) rename {core-kotlin/src/main/kotlin/com/baeldung/functions => core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/inline}/Inline.kt (95%) rename {core-kotlin => core-kotlin-modules/core-kotlin-lang}/src/main/kotlin/com/baeldung/operators/Money.kt (100%) rename {core-kotlin => core-kotlin-modules/core-kotlin-lang}/src/main/kotlin/com/baeldung/operators/Page.kt (100%) rename {core-kotlin => core-kotlin-modules/core-kotlin-lang}/src/main/kotlin/com/baeldung/operators/Point.kt (100%) rename {core-kotlin => core-kotlin-modules/core-kotlin-lang}/src/main/kotlin/com/baeldung/operators/Utils.kt (100%) rename {core-kotlin-2 => core-kotlin-modules/core-kotlin-lang}/src/main/kotlin/com/baeldung/range/CharRange.kt (100%) rename {core-kotlin-2 => core-kotlin-modules/core-kotlin-lang}/src/main/kotlin/com/baeldung/range/Color.kt (100%) rename {core-kotlin-2 => core-kotlin-modules/core-kotlin-lang}/src/main/kotlin/com/baeldung/range/Filter.kt (100%) rename {core-kotlin-2 => core-kotlin-modules/core-kotlin-lang}/src/main/kotlin/com/baeldung/range/FirstLast.kt (100%) rename {core-kotlin-2 => core-kotlin-modules/core-kotlin-lang}/src/main/kotlin/com/baeldung/range/OtherRangeFunctions.kt (100%) rename {core-kotlin-2 => core-kotlin-modules/core-kotlin-lang}/src/main/kotlin/com/baeldung/range/Range.kt (100%) rename {core-kotlin-2 => core-kotlin-modules/core-kotlin-lang}/src/main/kotlin/com/baeldung/range/ReverseRange.kt (100%) rename {core-kotlin-2 => core-kotlin-modules/core-kotlin-lang}/src/main/kotlin/com/baeldung/range/Step.kt (100%) rename {core-kotlin-2 => core-kotlin-modules/core-kotlin-lang}/src/main/kotlin/com/baeldung/range/UntilRange.kt (100%) rename {core-kotlin-2/src/main/kotlin/com/baeldung/range => core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/rangeiterator}/CustomColor.kt (84%) rename {core-kotlin/src/main/kotlin/com/baeldung/kotlin => core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/whenblock}/WhenBlockTypes.kt (95%) rename {core-kotlin/src/test/kotlin/com/baeldung/kotlin => core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/equalityoperators}/EqualityTest.kt (97%) rename {core-kotlin => core-kotlin-modules/core-kotlin-lang}/src/test/kotlin/com/baeldung/operators/PageTest.kt (100%) rename {core-kotlin => core-kotlin-modules/core-kotlin-lang}/src/test/kotlin/com/baeldung/operators/PointTest.kt (100%) rename {core-kotlin => core-kotlin-modules/core-kotlin-lang}/src/test/kotlin/com/baeldung/operators/UtilsTest.kt (100%) rename {core-kotlin-2 => core-kotlin-modules/core-kotlin-lang}/src/test/kotlin/com/baeldung/range/CharRangeTest.kt (100%) rename {core-kotlin-2 => core-kotlin-modules/core-kotlin-lang}/src/test/kotlin/com/baeldung/range/ColorTest.kt (100%) rename {core-kotlin-2 => core-kotlin-modules/core-kotlin-lang}/src/test/kotlin/com/baeldung/range/FilterTest.kt (100%) rename {core-kotlin-2 => core-kotlin-modules/core-kotlin-lang}/src/test/kotlin/com/baeldung/range/FirstLastTest.kt (100%) rename {core-kotlin-2 => core-kotlin-modules/core-kotlin-lang}/src/test/kotlin/com/baeldung/range/OtherRangeFunctionsTest.kt (100%) rename {core-kotlin-2 => core-kotlin-modules/core-kotlin-lang}/src/test/kotlin/com/baeldung/range/RangeTest.kt (100%) rename {core-kotlin-2 => core-kotlin-modules/core-kotlin-lang}/src/test/kotlin/com/baeldung/range/ReverseRangeTest.kt (100%) rename {core-kotlin-2 => core-kotlin-modules/core-kotlin-lang}/src/test/kotlin/com/baeldung/range/StepTest.kt (100%) rename {core-kotlin-2 => core-kotlin-modules/core-kotlin-lang}/src/test/kotlin/com/baeldung/range/UntilRangeTest.kt (100%) rename {core-kotlin-2/src/test/kotlin/com/baeldung/range => core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/rangeiterator}/CustomColorTest.kt (95%) rename {core-kotlin/src/test/kotlin/com/baeldung/kotlin => core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/trywithresource}/UseTest.kt (98%) rename {core-kotlin-2/src/test/kotlin => core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung}/voidtypes/VoidTypesUnitTest.kt (100%) rename {core-kotlin/src/test/kotlin/com/baeldung/kotlin => core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/whenblock}/WhenBlockUnitTest.kt (99%) diff --git a/core-kotlin-2/README.md b/core-kotlin-2/README.md index 5a443c1831..89e30bc5fe 100644 --- a/core-kotlin-2/README.md +++ b/core-kotlin-2/README.md @@ -4,9 +4,6 @@ This module contains articles about core Kotlin. ### Relevant articles: -- [Void Type in Kotlin](https://www.baeldung.com/kotlin-void-type) -- [How to use Kotlin Range Expressions](https://www.baeldung.com/kotlin-ranges) -- [Creating a Kotlin Range Iterator on a Custom Object](https://www.baeldung.com/kotlin-custom-range-iterator) - [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) diff --git a/core-kotlin-modules/core-kotlin-lang-2/README.md b/core-kotlin-modules/core-kotlin-lang-2/README.md new file mode 100644 index 0000000000..e64a39cb9b --- /dev/null +++ b/core-kotlin-modules/core-kotlin-lang-2/README.md @@ -0,0 +1,13 @@ +## Core Kotlin Lang + +This module contains articles about core features in the Kotlin language. + +### Relevant articles: +- [Kotlin return, break, continue Keywords](https://www.baeldung.com/kotlin-return-break-continue) +- [Infix Functions in Kotlin](https://www.baeldung.com/kotlin-infix-functions) +- [Lambda Expressions in Kotlin](https://www.baeldung.com/kotlin-lambda-expressions) +- [Creating Java static final Equivalents in Kotlin](https://www.baeldung.com/kotlin-java-static-final) +- [Initializing Arrays in Kotlin](https://www.baeldung.com/kotlin-initialize-array) +- [Lazy Initialization in Kotlin](https://www.baeldung.com/kotlin-lazy-initialization) +- [Comprehensive Guide to Null Safety in Kotlin](https://www.baeldung.com/kotlin-null-safety) +- [[<-- Prev]](/core-kotlin-modules/core-kotlin-lang) diff --git a/core-kotlin-modules/core-kotlin-lang-2/pom.xml b/core-kotlin-modules/core-kotlin-lang-2/pom.xml new file mode 100644 index 0000000000..753147728d --- /dev/null +++ b/core-kotlin-modules/core-kotlin-lang-2/pom.xml @@ -0,0 +1,16 @@ + + + 4.0.0 + core-kotlin-lang-2 + core-kotlin-lang-2 + jar + + + com.baeldung.core-kotlin-modules + core-kotlin-modules + 1.0.0-SNAPSHOT + + + \ No newline at end of file diff --git a/core-kotlin/src/main/java/com/baeldung/lazy/ClassWithHeavyInitialization.java b/core-kotlin-modules/core-kotlin-lang-2/src/main/java/com/baeldung/lazy/ClassWithHeavyInitialization.java similarity index 100% rename from core-kotlin/src/main/java/com/baeldung/lazy/ClassWithHeavyInitialization.java rename to core-kotlin-modules/core-kotlin-lang-2/src/main/java/com/baeldung/lazy/ClassWithHeavyInitialization.java diff --git a/core-kotlin/src/main/kotlin/com/baeldung/lambda/Lambda.kt b/core-kotlin-modules/core-kotlin-lang-2/src/main/kotlin/com/baeldung/lambda/Lambda.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/lambda/Lambda.kt rename to core-kotlin-modules/core-kotlin-lang-2/src/main/kotlin/com/baeldung/lambda/Lambda.kt diff --git a/core-kotlin/src/test/java/com/baeldung/kotlin/LazyJavaUnitTest.java b/core-kotlin-modules/core-kotlin-lang-2/src/test/java/com/baeldung/lazy/LazyJavaUnitTest.java similarity index 86% rename from core-kotlin/src/test/java/com/baeldung/kotlin/LazyJavaUnitTest.java rename to core-kotlin-modules/core-kotlin-lang-2/src/test/java/com/baeldung/lazy/LazyJavaUnitTest.java index e2fe58d537..01c87d9543 100644 --- a/core-kotlin/src/test/java/com/baeldung/kotlin/LazyJavaUnitTest.java +++ b/core-kotlin-modules/core-kotlin-lang-2/src/test/java/com/baeldung/lazy/LazyJavaUnitTest.java @@ -1,7 +1,5 @@ -package com.baeldung.kotlin; +package com.baeldung.lazy; - -import com.baeldung.lazy.ClassWithHeavyInitialization; import org.junit.Test; import static junit.framework.TestCase.assertTrue; diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/ArrayInitializationTest.kt b/core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/arrayinitialization/ArrayInitializationTest.kt similarity index 96% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/ArrayInitializationTest.kt rename to core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/arrayinitialization/ArrayInitializationTest.kt index ba3694c831..d4b9d607fb 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/ArrayInitializationTest.kt +++ b/core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/arrayinitialization/ArrayInitializationTest.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin +package com.baeldung.arrayinitialization import org.junit.Test import kotlin.test.assertEquals diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/constant/ConstantUnitTest.kt b/core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/constant/ConstantUnitTest.kt similarity index 79% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/constant/ConstantUnitTest.kt rename to core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/constant/ConstantUnitTest.kt index 51d45b8df0..d9bf433208 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/constant/ConstantUnitTest.kt +++ b/core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/constant/ConstantUnitTest.kt @@ -1,5 +1,5 @@ -import com.baeldung.kotlin.constant.TestKotlinConstantClass -import com.baeldung.kotlin.constant.TestKotlinConstantObject +package com.baeldung.constant + import org.junit.jupiter.api.Test import kotlin.test.assertEquals diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/constant/TestKotlinConstantClass.kt b/core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/constant/TestKotlinConstantClass.kt similarity index 75% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/constant/TestKotlinConstantClass.kt rename to core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/constant/TestKotlinConstantClass.kt index 8bcc327999..3c4d4db220 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/constant/TestKotlinConstantClass.kt +++ b/core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/constant/TestKotlinConstantClass.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin.constant +package com.baeldung.constant class TestKotlinConstantClass { diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/constant/TestKotlinConstantObject.kt b/core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/constant/TestKotlinConstantObject.kt similarity index 87% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/constant/TestKotlinConstantObject.kt rename to core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/constant/TestKotlinConstantObject.kt index 815fdeaf14..a6951b4481 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/constant/TestKotlinConstantObject.kt +++ b/core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/constant/TestKotlinConstantObject.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin.constant +package com.baeldung.constant object TestKotlinConstantObject { diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/InfixFunctionsTest.kt b/core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/infixfunctions/InfixFunctionsTest.kt similarity index 97% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/InfixFunctionsTest.kt rename to core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/infixfunctions/InfixFunctionsTest.kt index fc4286460a..0b09d34013 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/InfixFunctionsTest.kt +++ b/core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/infixfunctions/InfixFunctionsTest.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin +package com.baeldung.infixfunctions import org.junit.Assert import org.junit.Test diff --git a/core-kotlin/src/test/java/com/baeldung/lambda/LambdaKotlinUnitTest.java b/core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/lambda/LambdaKotlinUnitTest.java similarity index 100% rename from core-kotlin/src/test/java/com/baeldung/lambda/LambdaKotlinUnitTest.java rename to core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/lambda/LambdaKotlinUnitTest.java diff --git a/core-kotlin/src/test/kotlin/com/baeldung/lambda/LambdaTest.kt b/core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/lambda/LambdaTest.kt similarity index 99% rename from core-kotlin/src/test/kotlin/com/baeldung/lambda/LambdaTest.kt rename to core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/lambda/LambdaTest.kt index 3af00c98ff..bddabee462 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/lambda/LambdaTest.kt +++ b/core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/lambda/LambdaTest.kt @@ -6,6 +6,7 @@ import org.junit.jupiter.api.Test import kotlin.test.assertEquals class LambdaTest { + @Test fun whenCallingALambda_thenPerformTheAction() { assertEquals(9, inferredType(3)) diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/LazyUnitTest.kt b/core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/lazy/LazyUnitTest.kt similarity index 98% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/LazyUnitTest.kt rename to core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/lazy/LazyUnitTest.kt index 1169fb9193..b9b21ed4d9 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/LazyUnitTest.kt +++ b/core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/lazy/LazyUnitTest.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin +package com.baeldung.lazy import org.junit.Test import java.util.concurrent.CountDownLatch diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/NullSafetyTest.kt b/core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/nullsafety/NullSafetyTest.kt similarity index 99% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/NullSafetyTest.kt rename to core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/nullsafety/NullSafetyTest.kt index 0ecc74b6fb..66fc043581 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/NullSafetyTest.kt +++ b/core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/nullsafety/NullSafetyTest.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin +package com.baeldung.nullsafety import org.junit.Test import kotlin.test.assertEquals @@ -8,6 +8,7 @@ import kotlin.test.assertTrue class NullSafetyTest { + @Test fun givenNonNullableField_whenAssignValueToIt_thenNotNeedToCheckAgainstNull() { //given diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/StructuralJumpUnitTest.kt b/core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/structuraljump/StructuralJumpUnitTest.kt similarity index 98% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/StructuralJumpUnitTest.kt rename to core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/structuraljump/StructuralJumpUnitTest.kt index 436dc9e2ba..88011ab396 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/StructuralJumpUnitTest.kt +++ b/core-kotlin-modules/core-kotlin-lang-2/src/test/kotlin/com/baeldung/structuraljump/StructuralJumpUnitTest.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin +package com.baeldung.structuraljump import org.junit.Test import kotlin.test.assertEquals diff --git a/core-kotlin-modules/core-kotlin-lang/README.md b/core-kotlin-modules/core-kotlin-lang/README.md new file mode 100644 index 0000000000..eaeae76854 --- /dev/null +++ b/core-kotlin-modules/core-kotlin-lang/README.md @@ -0,0 +1,16 @@ +## Core Kotlin Lang + +This module contains articles about core features in the Kotlin language. + +### Relevant articles: +- [Guide to the “when{}” Block in Kotlin](https://www.baeldung.com/kotlin-when) +- [Difference Between “==” and “===” Operators in Kotlin](https://www.baeldung.com/kotlin-equality-operators) +- [Nested forEach in Kotlin](https://www.baeldung.com/kotlin-nested-foreach) +- [Destructuring Declarations in Kotlin](https://www.baeldung.com/kotlin-destructuring-declarations) +- [Try-with-resources in Kotlin](https://www.baeldung.com/kotlin-try-with-resources) +- [Operator Overloading in Kotlin](https://www.baeldung.com/kotlin-operator-overloading) +- [Inline Functions in Kotlin](https://www.baeldung.com/kotlin-inline-functions) +- [Void Type in Kotlin](https://www.baeldung.com/kotlin-void-type) +- [How to use Kotlin Range Expressions](https://www.baeldung.com/kotlin-ranges) +- [Creating a Kotlin Range Iterator on a Custom Object](https://www.baeldung.com/kotlin-custom-range-iterator) +- [[More --> ]](/core-kotlin-modules/core-kotlin-lang-2) diff --git a/core-kotlin-modules/core-kotlin-lang/pom.xml b/core-kotlin-modules/core-kotlin-lang/pom.xml new file mode 100644 index 0000000000..d3ac7f690c --- /dev/null +++ b/core-kotlin-modules/core-kotlin-lang/pom.xml @@ -0,0 +1,16 @@ + + + 4.0.0 + core-kotlin-lang + core-kotlin-lang + jar + + + com.baeldung.core-kotlin-modules + core-kotlin-modules + 1.0.0-SNAPSHOT + + + \ No newline at end of file diff --git a/core-kotlin/src/main/kotlin/com/baeldung/destructuringdeclarations/Person.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/destructuringdeclarations/Person.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/destructuringdeclarations/Person.kt rename to core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/destructuringdeclarations/Person.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/destructuringdeclarations/Result.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/destructuringdeclarations/Result.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/destructuringdeclarations/Result.kt rename to core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/destructuringdeclarations/Result.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/destructuringdeclarations/Sandbox.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/destructuringdeclarations/Sandbox.kt similarity index 94% rename from core-kotlin/src/main/kotlin/com/baeldung/destructuringdeclarations/Sandbox.kt rename to core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/destructuringdeclarations/Sandbox.kt index a5018d93c8..f845d01539 100644 --- a/core-kotlin/src/main/kotlin/com/baeldung/destructuringdeclarations/Sandbox.kt +++ b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/destructuringdeclarations/Sandbox.kt @@ -1,7 +1,5 @@ package com.baeldung.destructuringdeclarations -import com.baeldung.destructuringdeclarations.Person - fun main(args: Array) { //2.1. Objects diff --git a/core-kotlin/src/main/kotlin/com/baeldung/kotlin/User.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/equalityoperators/User.kt similarity index 66% rename from core-kotlin/src/main/kotlin/com/baeldung/kotlin/User.kt rename to core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/equalityoperators/User.kt index 759627b56e..030169bb8a 100644 --- a/core-kotlin/src/main/kotlin/com/baeldung/kotlin/User.kt +++ b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/equalityoperators/User.kt @@ -1,3 +1,3 @@ -package com.baeldung.kotlin +package com.baeldung.equalityoperators data class User(val name: String, val age: Int, val hobbies: List) diff --git a/core-kotlin/src/main/kotlin/com/baeldung/forEach/forEach.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/forEach/forEach.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/forEach/forEach.kt rename to core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/forEach/forEach.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/functions/Inline.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/inline/Inline.kt similarity index 95% rename from core-kotlin/src/main/kotlin/com/baeldung/functions/Inline.kt rename to core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/inline/Inline.kt index 239c425c03..3b179642ba 100644 --- a/core-kotlin/src/main/kotlin/com/baeldung/functions/Inline.kt +++ b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/inline/Inline.kt @@ -1,4 +1,4 @@ -package com.baeldung.functions +package com.baeldung.inline import kotlin.random.Random diff --git a/core-kotlin/src/main/kotlin/com/baeldung/operators/Money.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/operators/Money.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/operators/Money.kt rename to core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/operators/Money.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/operators/Page.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/operators/Page.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/operators/Page.kt rename to core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/operators/Page.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/operators/Point.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/operators/Point.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/operators/Point.kt rename to core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/operators/Point.kt diff --git a/core-kotlin/src/main/kotlin/com/baeldung/operators/Utils.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/operators/Utils.kt similarity index 100% rename from core-kotlin/src/main/kotlin/com/baeldung/operators/Utils.kt rename to core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/operators/Utils.kt diff --git a/core-kotlin-2/src/main/kotlin/com/baeldung/range/CharRange.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/range/CharRange.kt similarity index 100% rename from core-kotlin-2/src/main/kotlin/com/baeldung/range/CharRange.kt rename to core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/range/CharRange.kt diff --git a/core-kotlin-2/src/main/kotlin/com/baeldung/range/Color.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/range/Color.kt similarity index 100% rename from core-kotlin-2/src/main/kotlin/com/baeldung/range/Color.kt rename to core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/range/Color.kt diff --git a/core-kotlin-2/src/main/kotlin/com/baeldung/range/Filter.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/range/Filter.kt similarity index 100% rename from core-kotlin-2/src/main/kotlin/com/baeldung/range/Filter.kt rename to core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/range/Filter.kt diff --git a/core-kotlin-2/src/main/kotlin/com/baeldung/range/FirstLast.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/range/FirstLast.kt similarity index 100% rename from core-kotlin-2/src/main/kotlin/com/baeldung/range/FirstLast.kt rename to core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/range/FirstLast.kt diff --git a/core-kotlin-2/src/main/kotlin/com/baeldung/range/OtherRangeFunctions.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/range/OtherRangeFunctions.kt similarity index 100% rename from core-kotlin-2/src/main/kotlin/com/baeldung/range/OtherRangeFunctions.kt rename to core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/range/OtherRangeFunctions.kt diff --git a/core-kotlin-2/src/main/kotlin/com/baeldung/range/Range.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/range/Range.kt similarity index 100% rename from core-kotlin-2/src/main/kotlin/com/baeldung/range/Range.kt rename to core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/range/Range.kt diff --git a/core-kotlin-2/src/main/kotlin/com/baeldung/range/ReverseRange.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/range/ReverseRange.kt similarity index 100% rename from core-kotlin-2/src/main/kotlin/com/baeldung/range/ReverseRange.kt rename to core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/range/ReverseRange.kt diff --git a/core-kotlin-2/src/main/kotlin/com/baeldung/range/Step.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/range/Step.kt similarity index 100% rename from core-kotlin-2/src/main/kotlin/com/baeldung/range/Step.kt rename to core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/range/Step.kt diff --git a/core-kotlin-2/src/main/kotlin/com/baeldung/range/UntilRange.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/range/UntilRange.kt similarity index 100% rename from core-kotlin-2/src/main/kotlin/com/baeldung/range/UntilRange.kt rename to core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/range/UntilRange.kt diff --git a/core-kotlin-2/src/main/kotlin/com/baeldung/range/CustomColor.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/rangeiterator/CustomColor.kt similarity index 84% rename from core-kotlin-2/src/main/kotlin/com/baeldung/range/CustomColor.kt rename to core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/rangeiterator/CustomColor.kt index b4fed13b18..c1ab8e1610 100644 --- a/core-kotlin-2/src/main/kotlin/com/baeldung/range/CustomColor.kt +++ b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/rangeiterator/CustomColor.kt @@ -1,4 +1,4 @@ -package com.baeldung.range +package com.baeldung.rangeiterator import java.lang.IllegalStateException @@ -8,7 +8,7 @@ class CustomColor(val rgb: Int): Comparable { return this.rgb.compareTo(other.rgb) } - operator fun rangeTo(that: CustomColor) = ColorRange(this,that) + operator fun rangeTo(that: CustomColor) = ColorRange(this, that) operator fun inc(): CustomColor { return CustomColor(rgb + 1) @@ -25,7 +25,7 @@ class CustomColor(val rgb: Int): Comparable { } } class ColorRange(override val start: CustomColor, - override val endInclusive: CustomColor) : ClosedRange, Iterable{ + override val endInclusive: CustomColor) : ClosedRange, Iterable{ override fun iterator(): Iterator { return ColorIterator(start, endInclusive) diff --git a/core-kotlin/src/main/kotlin/com/baeldung/kotlin/WhenBlockTypes.kt b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/whenblock/WhenBlockTypes.kt similarity index 95% rename from core-kotlin/src/main/kotlin/com/baeldung/kotlin/WhenBlockTypes.kt rename to core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/whenblock/WhenBlockTypes.kt index 6180da10d9..a4cd7b98f0 100644 --- a/core-kotlin/src/main/kotlin/com/baeldung/kotlin/WhenBlockTypes.kt +++ b/core-kotlin-modules/core-kotlin-lang/src/main/kotlin/com/baeldung/whenblock/WhenBlockTypes.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin +package com.baeldung.whenblock enum class UnixFileType { D, HYPHEN_MINUS, L diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/EqualityTest.kt b/core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/equalityoperators/EqualityTest.kt similarity index 97% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/EqualityTest.kt rename to core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/equalityoperators/EqualityTest.kt index 6fb6d0a288..0728d55b73 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/EqualityTest.kt +++ b/core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/equalityoperators/EqualityTest.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin +package com.baeldung.equalityoperators import org.junit.Test import kotlin.test.assertFalse diff --git a/core-kotlin/src/test/kotlin/com/baeldung/operators/PageTest.kt b/core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/operators/PageTest.kt similarity index 100% rename from core-kotlin/src/test/kotlin/com/baeldung/operators/PageTest.kt rename to core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/operators/PageTest.kt diff --git a/core-kotlin/src/test/kotlin/com/baeldung/operators/PointTest.kt b/core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/operators/PointTest.kt similarity index 100% rename from core-kotlin/src/test/kotlin/com/baeldung/operators/PointTest.kt rename to core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/operators/PointTest.kt diff --git a/core-kotlin/src/test/kotlin/com/baeldung/operators/UtilsTest.kt b/core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/operators/UtilsTest.kt similarity index 100% rename from core-kotlin/src/test/kotlin/com/baeldung/operators/UtilsTest.kt rename to core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/operators/UtilsTest.kt diff --git a/core-kotlin-2/src/test/kotlin/com/baeldung/range/CharRangeTest.kt b/core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/range/CharRangeTest.kt similarity index 100% rename from core-kotlin-2/src/test/kotlin/com/baeldung/range/CharRangeTest.kt rename to core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/range/CharRangeTest.kt diff --git a/core-kotlin-2/src/test/kotlin/com/baeldung/range/ColorTest.kt b/core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/range/ColorTest.kt similarity index 100% rename from core-kotlin-2/src/test/kotlin/com/baeldung/range/ColorTest.kt rename to core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/range/ColorTest.kt diff --git a/core-kotlin-2/src/test/kotlin/com/baeldung/range/FilterTest.kt b/core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/range/FilterTest.kt similarity index 100% rename from core-kotlin-2/src/test/kotlin/com/baeldung/range/FilterTest.kt rename to core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/range/FilterTest.kt diff --git a/core-kotlin-2/src/test/kotlin/com/baeldung/range/FirstLastTest.kt b/core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/range/FirstLastTest.kt similarity index 100% rename from core-kotlin-2/src/test/kotlin/com/baeldung/range/FirstLastTest.kt rename to core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/range/FirstLastTest.kt diff --git a/core-kotlin-2/src/test/kotlin/com/baeldung/range/OtherRangeFunctionsTest.kt b/core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/range/OtherRangeFunctionsTest.kt similarity index 100% rename from core-kotlin-2/src/test/kotlin/com/baeldung/range/OtherRangeFunctionsTest.kt rename to core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/range/OtherRangeFunctionsTest.kt diff --git a/core-kotlin-2/src/test/kotlin/com/baeldung/range/RangeTest.kt b/core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/range/RangeTest.kt similarity index 100% rename from core-kotlin-2/src/test/kotlin/com/baeldung/range/RangeTest.kt rename to core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/range/RangeTest.kt diff --git a/core-kotlin-2/src/test/kotlin/com/baeldung/range/ReverseRangeTest.kt b/core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/range/ReverseRangeTest.kt similarity index 100% rename from core-kotlin-2/src/test/kotlin/com/baeldung/range/ReverseRangeTest.kt rename to core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/range/ReverseRangeTest.kt diff --git a/core-kotlin-2/src/test/kotlin/com/baeldung/range/StepTest.kt b/core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/range/StepTest.kt similarity index 100% rename from core-kotlin-2/src/test/kotlin/com/baeldung/range/StepTest.kt rename to core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/range/StepTest.kt diff --git a/core-kotlin-2/src/test/kotlin/com/baeldung/range/UntilRangeTest.kt b/core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/range/UntilRangeTest.kt similarity index 100% rename from core-kotlin-2/src/test/kotlin/com/baeldung/range/UntilRangeTest.kt rename to core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/range/UntilRangeTest.kt diff --git a/core-kotlin-2/src/test/kotlin/com/baeldung/range/CustomColorTest.kt b/core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/rangeiterator/CustomColorTest.kt similarity index 95% rename from core-kotlin-2/src/test/kotlin/com/baeldung/range/CustomColorTest.kt rename to core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/rangeiterator/CustomColorTest.kt index 8c8795ac42..676b47ae7a 100644 --- a/core-kotlin-2/src/test/kotlin/com/baeldung/range/CustomColorTest.kt +++ b/core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/rangeiterator/CustomColorTest.kt @@ -1,4 +1,4 @@ -package com.baeldung.range +package com.baeldung.rangeiterator import org.junit.Test import java.lang.IllegalStateException diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/UseTest.kt b/core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/trywithresource/UseTest.kt similarity index 98% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/UseTest.kt rename to core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/trywithresource/UseTest.kt index 15bdfcafd8..d17832b380 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/UseTest.kt +++ b/core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/trywithresource/UseTest.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin +package com.baeldung.trywithresource import org.junit.Test import java.beans.ExceptionListener diff --git a/core-kotlin-2/src/test/kotlin/voidtypes/VoidTypesUnitTest.kt b/core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/voidtypes/VoidTypesUnitTest.kt similarity index 100% rename from core-kotlin-2/src/test/kotlin/voidtypes/VoidTypesUnitTest.kt rename to core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/voidtypes/VoidTypesUnitTest.kt diff --git a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/WhenBlockUnitTest.kt b/core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/whenblock/WhenBlockUnitTest.kt similarity index 99% rename from core-kotlin/src/test/kotlin/com/baeldung/kotlin/WhenBlockUnitTest.kt rename to core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/whenblock/WhenBlockUnitTest.kt index aa1891fa46..31b6ad69f5 100644 --- a/core-kotlin/src/test/kotlin/com/baeldung/kotlin/WhenBlockUnitTest.kt +++ b/core-kotlin-modules/core-kotlin-lang/src/test/kotlin/com/baeldung/whenblock/WhenBlockUnitTest.kt @@ -1,4 +1,4 @@ -package com.baeldung.kotlin +package com.baeldung.whenblock import org.junit.Assert.assertEquals import org.junit.Assert.assertTrue diff --git a/core-kotlin-modules/pom.xml b/core-kotlin-modules/pom.xml index 747e8b69de..1abea86289 100644 --- a/core-kotlin-modules/pom.xml +++ b/core-kotlin-modules/pom.xml @@ -17,6 +17,8 @@ core-kotlin-annotations core-kotlin-io + core-kotlin-lang + core-kotlin-lang-2 core-kotlin-strings diff --git a/core-kotlin/README.md b/core-kotlin/README.md index f75a4e764c..785eb0b689 100644 --- a/core-kotlin/README.md +++ b/core-kotlin/README.md @@ -5,14 +5,9 @@ This module contains articles about core Kotlin. ### Relevant articles: - [Introduction to the Kotlin Language](https://www.baeldung.com/kotlin) -- [Guide to the “when{}” Block in Kotlin](https://www.baeldung.com/kotlin-when) -- [Comprehensive Guide to Null Safety in Kotlin](https://www.baeldung.com/kotlin-null-safety) - [Kotlin Java Interoperability](https://www.baeldung.com/kotlin-java-interoperability) -- [Difference Between “==” and “===” operators in Kotlin](https://www.baeldung.com/kotlin-equality-operators) - [Generics in Kotlin](https://www.baeldung.com/kotlin-generics) - [Introduction to Kotlin Coroutines](https://www.baeldung.com/kotlin-coroutines) -- [Destructuring Declarations in Kotlin](https://www.baeldung.com/kotlin-destructuring-declarations) -- [Lazy Initialization in Kotlin](https://www.baeldung.com/kotlin-lazy-initialization) - [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) @@ -20,12 +15,9 @@ This module contains articles about core Kotlin. - [Sealed Classes in Kotlin](https://www.baeldung.com/kotlin-sealed-classes) - [JUnit 5 for Kotlin Developers](https://www.baeldung.com/junit-5-kotlin) - [Extension Methods in Kotlin](https://www.baeldung.com/kotlin-extension-methods) -- [Infix Functions in Kotlin](https://www.baeldung.com/kotlin-infix-functions) -- [Try-with-resources in Kotlin](https://www.baeldung.com/kotlin-try-with-resources) - [Regular Expressions in Kotlin](https://www.baeldung.com/kotlin-regular-expressions) - [Objects in Kotlin](https://www.baeldung.com/kotlin-objects) - [Filtering Kotlin Collections](https://www.baeldung.com/kotlin-filter-collection) -- [Lambda Expressions in Kotlin](https://www.baeldung.com/kotlin-lambda-expressions) - [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) - [Reflection with Kotlin](https://www.baeldung.com/kotlin-reflection) @@ -37,21 +29,15 @@ This module contains articles about core Kotlin. - [Fuel HTTP Library with Kotlin](https://www.baeldung.com/kotlin-fuel) - [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) -- [Kotlin return, break, continue Keywords](https://www.baeldung.com/kotlin-return-break-continue) - [Mapping of Data Objects in Kotlin](https://www.baeldung.com/kotlin-data-objects) -- [Initializing Arrays in Kotlin](https://www.baeldung.com/kotlin-initialize-array) - [Threads vs Coroutines in Kotlin](https://www.baeldung.com/kotlin-threads-coroutines) - [Guide to Kotlin Interfaces](https://www.baeldung.com/kotlin-interfaces) - [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) - [Implementing a Binary Tree in Kotlin](https://www.baeldung.com/kotlin-binary-tree) - [Kotlin Contracts](https://www.baeldung.com/kotlin-contracts) -- [Operator Overloading in Kotlin](https://www.baeldung.com/kotlin-operator-overloading) - [Inline Classes in Kotlin](https://www.baeldung.com/kotlin-inline-classes) -- [Creating Java static final Equivalents in Kotlin](https://www.baeldung.com/kotlin-java-static-final) -- [Nested forEach in Kotlin](https://www.baeldung.com/kotlin-nested-foreach) - [Building DSLs in Kotlin](https://www.baeldung.com/kotlin-dsl) - [Static Methods Behavior in Kotlin](https://www.baeldung.com/kotlin-static-methods) -- [Inline Functions in Kotlin](https://www.baeldung.com/kotlin-inline-functions) - [Delegation Pattern in Kotlin](https://www.baeldung.com/kotlin-delegation-pattern) - More articles: [[next -->]](/core-kotlin-2) From 0df902da92720c0da367a3fa0ae444f99b2def2d Mon Sep 17 00:00:00 2001 From: Gang Date: Mon, 16 Dec 2019 23:46:22 -0700 Subject: [PATCH 02/11] =?UTF-8?q?BAEL-3406=20Kruskal=E2=80=99s=20Algorithm?= =?UTF-8?q?=20for=20Spanning=20Trees?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- algorithms-miscellaneous-5/pom.xml | 5 ++ .../baeldung/algorithms/kruskal/Kruskal.java | 88 +++++++++++++++++++ .../algorithms/kruskal/KruskalUnitTest.java | 66 ++++++++++++++ 3 files changed, 159 insertions(+) create mode 100644 algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/kruskal/Kruskal.java create mode 100644 algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/kruskal/KruskalUnitTest.java diff --git a/algorithms-miscellaneous-5/pom.xml b/algorithms-miscellaneous-5/pom.xml index 2f530958e3..83a30f420c 100644 --- a/algorithms-miscellaneous-5/pom.xml +++ b/algorithms-miscellaneous-5/pom.xml @@ -34,6 +34,11 @@ tradukisto ${tradukisto.version} + + com.google.guava + guava + 28.1-jre + org.assertj diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/kruskal/Kruskal.java b/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/kruskal/Kruskal.java new file mode 100644 index 0000000000..62b260c71e --- /dev/null +++ b/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/kruskal/Kruskal.java @@ -0,0 +1,88 @@ +package com.baeldung.algorithms.kruskal; + +import com.google.common.graph.EndpointPair; +import com.google.common.graph.MutableValueGraph; +import com.google.common.graph.ValueGraph; +import com.google.common.graph.ValueGraphBuilder; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.Set; + +public class Kruskal { + + public ValueGraph minSpanningTree(ValueGraph graph) { + + return spanningTree(graph, true); + } + + public ValueGraph maxSpanningTree(ValueGraph graph) { + return spanningTree(graph, false); + } + + private ValueGraph spanningTree(ValueGraph graph, boolean minSpanningTree) { + Set> edges = graph.edges(); + List> edgeList = new ArrayList<>(edges); + + if (minSpanningTree) { + edgeList.sort(Comparator.comparing(e -> graph.edgeValue(e).get())); + } else { + edgeList.sort(Collections.reverseOrder(Comparator.comparing(e -> graph.edgeValue(e).get()))); + } + + int totalEdges = edgeList.size(); + int totalNodes = graph.nodes().size(); + int edgeCount = 0; + List roots = new ArrayList<>(totalNodes); + List sizes = new ArrayList<>(totalNodes); + for (int i = 0; i < totalNodes; i++) { + roots.add(i); + sizes.add(1); + } + + MutableValueGraph spanningTree = ValueGraphBuilder.undirected().build(); + for (int i = 0; i < totalEdges; i++) { + EndpointPair edge = edgeList.get(i); + if (detectCycle(edge.nodeU(), edge.nodeV(), roots, sizes)) { + continue; + } + spanningTree.putEdgeValue(edge.nodeU(), edge.nodeV(), graph.edgeValue(edge).get()); + edgeCount++; + if (edgeCount == totalNodes - 1) { + break; + } + } + return spanningTree; + } + + private Integer find(Integer x, List roots) { + Integer root = roots.get(x); + if (!root.equals(x)) { + roots.set(x, find(root, roots)); + } + return roots.get(x); + } + + private void unionBySize(Integer rootU, Integer rootV, List roots, List sizes) { + Integer total = sizes.get(rootU) + sizes.get(rootV); + if (sizes.get(rootU) < sizes.get(rootV)) { + roots.set(rootU, rootV); + sizes.set(rootV, total); + } else { + roots.set(rootV, rootU); + sizes.set(rootU, total); + } + } + + private boolean detectCycle(Integer u, Integer v, List roots, List sizes) { + Integer rootU = find(u, roots); + Integer rootV = find(v, roots); + if (rootU.equals(rootV)) { + return true; + } + unionBySize(rootU, rootV, roots, sizes); + return false; + } +} diff --git a/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/kruskal/KruskalUnitTest.java b/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/kruskal/KruskalUnitTest.java new file mode 100644 index 0000000000..e944d2894c --- /dev/null +++ b/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/kruskal/KruskalUnitTest.java @@ -0,0 +1,66 @@ +package com.baeldung.algorithms.kruskal; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; + +import org.junit.Before; +import org.junit.Test; +import com.google.common.graph.MutableValueGraph; +import com.google.common.graph.ValueGraph; +import com.google.common.graph.ValueGraphBuilder; + +public class KruskalUnitTest { + + private MutableValueGraph graph; + + @Before + public void setup() { + graph = ValueGraphBuilder.undirected().build(); + graph.putEdgeValue(0, 1, 8.0); + graph.putEdgeValue(0, 2, 5.0); + graph.putEdgeValue(1, 2, 9.0); + graph.putEdgeValue(1, 3, 11.0); + graph.putEdgeValue(2, 3, 15.0); + graph.putEdgeValue(2, 4, 10.0); + graph.putEdgeValue(3, 4, 7.0); + } + + @Test + public void givenGraph_whenMinimumSpanningTree_thenOutputCorrectResult() { + final Kruskal kruskal = new Kruskal(); + ValueGraph spanningTree = kruskal.minSpanningTree(graph); + + assertTrue(spanningTree.hasEdgeConnecting(0, 1)); + assertTrue(spanningTree.hasEdgeConnecting(0, 2)); + assertTrue(spanningTree.hasEdgeConnecting(2, 4)); + assertTrue(spanningTree.hasEdgeConnecting(3, 4)); + assertEquals(graph.edgeValue(0, 1), spanningTree.edgeValue(0, 1)); + assertEquals(graph.edgeValue(0, 2), spanningTree.edgeValue(0, 2)); + assertEquals(graph.edgeValue(2, 4), spanningTree.edgeValue(2, 4)); + assertEquals(graph.edgeValue(3, 4), spanningTree.edgeValue(3, 4)); + + assertFalse(spanningTree.hasEdgeConnecting(1, 2)); + assertFalse(spanningTree.hasEdgeConnecting(1, 3)); + assertFalse(spanningTree.hasEdgeConnecting(2, 3)); + } + + @Test + public void givenGraph_whenMaximumSpanningTree_thenOutputCorrectResult() { + final Kruskal kruskal = new Kruskal(); + ValueGraph spanningTree = kruskal.maxSpanningTree(graph); + + assertTrue(spanningTree.hasEdgeConnecting(0, 1)); + assertTrue(spanningTree.hasEdgeConnecting(1, 3)); + assertTrue(spanningTree.hasEdgeConnecting(2, 3)); + assertTrue(spanningTree.hasEdgeConnecting(2, 4)); + assertEquals(graph.edgeValue(0, 1), spanningTree.edgeValue(0, 1)); + assertEquals(graph.edgeValue(1, 3), spanningTree.edgeValue(1, 3)); + assertEquals(graph.edgeValue(2, 3), spanningTree.edgeValue(2, 3)); + assertEquals(graph.edgeValue(2, 4), spanningTree.edgeValue(2, 4)); + + assertFalse(spanningTree.hasEdgeConnecting(0, 2)); + assertFalse(spanningTree.hasEdgeConnecting(1, 2)); + assertFalse(spanningTree.hasEdgeConnecting(3, 4)); + } +} From f8d612969c8049cb4ce50e5f787f222142832867 Mon Sep 17 00:00:00 2001 From: Thabo Ntsoko Date: Sun, 22 Dec 2019 17:08:39 +0200 Subject: [PATCH 03/11] Moving CatchingThrowable.java to the core-java-exceptions-2 module --- .../exceptions/CatchingThrowable.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 core-java-modules/core-java-exceptions-2/src/main/java/com/baeldung/exceptions/CatchingThrowable.java diff --git a/core-java-modules/core-java-exceptions-2/src/main/java/com/baeldung/exceptions/CatchingThrowable.java b/core-java-modules/core-java-exceptions-2/src/main/java/com/baeldung/exceptions/CatchingThrowable.java new file mode 100644 index 0000000000..20b06cdd26 --- /dev/null +++ b/core-java-modules/core-java-exceptions-2/src/main/java/com/baeldung/exceptions/CatchingThrowable.java @@ -0,0 +1,38 @@ +package com.baeldung.exceptions; + +import java.util.Set; +import java.util.UUID; + +public class CatchingThrowable { + + class CapacityException extends Exception { + CapacityException(String message) { + super(message); + } + } + + class StorageAPI { + + public void addIDsToStorage(int capacity, Set storage) throws CapacityException { + if (capacity < 1) { + throw new CapacityException("Capacity of less than 1 is not allowed"); + } + int count = 0; + while (count < capacity) { + storage.add(UUID.randomUUID().toString()); + count++; + } + } + + // other methods go here ... + } + + public void add(StorageAPI api, int capacity, Set storage) { + try { + api.addIDsToStorage(capacity, storage); + } catch (Throwable throwable) { + // do something here + } + } + +} From 103b04cb8e94dc17702a10b4a343cf89d930e55f Mon Sep 17 00:00:00 2001 From: Gang Date: Sun, 22 Dec 2019 18:53:01 -0700 Subject: [PATCH 04/11] BAEL-3406, refactor Kruskal algorithm by using more classes. --- algorithms-miscellaneous-5/pom.xml | 6 +- .../algorithms/kruskal/CycleDetector.java | 72 +++++++++++++++++++ .../algorithms/kruskal/DisjointSetInfo.java | 28 ++++++++ .../baeldung/algorithms/kruskal/Kruskal.java | 43 ++--------- .../algorithms/kruskal/KruskalUnitTest.java | 1 + 5 files changed, 108 insertions(+), 42 deletions(-) create mode 100644 algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/kruskal/CycleDetector.java create mode 100644 algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/kruskal/DisjointSetInfo.java diff --git a/algorithms-miscellaneous-5/pom.xml b/algorithms-miscellaneous-5/pom.xml index 83a30f420c..95036da775 100644 --- a/algorithms-miscellaneous-5/pom.xml +++ b/algorithms-miscellaneous-5/pom.xml @@ -35,9 +35,9 @@ ${tradukisto.version} - com.google.guava - guava - 28.1-jre + com.google.guava + guava + 28.1-jre diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/kruskal/CycleDetector.java b/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/kruskal/CycleDetector.java new file mode 100644 index 0000000000..dec0bcdd85 --- /dev/null +++ b/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/kruskal/CycleDetector.java @@ -0,0 +1,72 @@ +package com.baeldung.algorithms.kruskal; + +import java.util.ArrayList; +import java.util.List; + +public class CycleDetector { + + List nodes; + + public CycleDetector(int totalNodes) { + initDisjointSets(totalNodes); + } + + public boolean detectCycle(Integer u, Integer v) { + Integer rootU = pathCompressionFind(u); + Integer rootV = pathCompressionFind(v); + if (rootU.equals(rootV)) { + return true; + } + unionByRank(rootU, rootV); + return false; + } + + private void initDisjointSets(int totalNodes) { + nodes = new ArrayList<>(totalNodes); + for (int i = 0; i < totalNodes; i++) { + nodes.add(new DisjointSetInfo(i)); + } + } + + private Integer find(Integer node) { + Integer parent = nodes.get(node).getParentNode(); + if (parent.equals(node)) { + return node; + } else { + return find(parent); + } + } + + private Integer pathCompressionFind(Integer node) { + DisjointSetInfo setInfo = nodes.get(node); + Integer parent = setInfo.getParentNode(); + if (parent.equals(node)) { + return node; + } else { + Integer parentNode = find(parent); + setInfo.setParentNode(parentNode); + return parentNode; + } + } + + private void union(Integer rootU, Integer rootV) { + DisjointSetInfo setInfoU = nodes.get(rootU); + setInfoU.setParentNode(rootV); + } + + private void unionByRank(int rootU, int rootV) { + DisjointSetInfo setInfoU = nodes.get(rootU); + DisjointSetInfo setInfoV = nodes.get(rootV); + int rankU = setInfoU.getRank(); + int rankV = setInfoV.getRank(); + if (rankU < rankV) { + setInfoU.setParentNode(rootV); + } else { + setInfoV.setParentNode(rootU); + if (rankU == rankV) { + setInfoU.setRank(rankU + 1); + } + } + } + +} diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/kruskal/DisjointSetInfo.java b/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/kruskal/DisjointSetInfo.java new file mode 100644 index 0000000000..ecdc42587a --- /dev/null +++ b/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/kruskal/DisjointSetInfo.java @@ -0,0 +1,28 @@ +package com.baeldung.algorithms.kruskal; + +public class DisjointSetInfo { + + private Integer parentNode; + private int rank; + + DisjointSetInfo(Integer nodeNumber) { + setParentNode(nodeNumber); + setRank(1); + } + + public Integer getParentNode() { + return parentNode; + } + + public void setParentNode(Integer parentNode) { + this.parentNode = parentNode; + } + + public int getRank() { + return rank; + } + + public void setRank(int rank) { + this.rank = rank; + } +} diff --git a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/kruskal/Kruskal.java b/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/kruskal/Kruskal.java index 62b260c71e..da405679d1 100644 --- a/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/kruskal/Kruskal.java +++ b/algorithms-miscellaneous-5/src/main/java/com/baeldung/algorithms/kruskal/Kruskal.java @@ -14,7 +14,7 @@ import java.util.Set; public class Kruskal { public ValueGraph minSpanningTree(ValueGraph graph) { - + return spanningTree(graph, true); } @@ -32,20 +32,13 @@ public class Kruskal { edgeList.sort(Collections.reverseOrder(Comparator.comparing(e -> graph.edgeValue(e).get()))); } - int totalEdges = edgeList.size(); int totalNodes = graph.nodes().size(); + CycleDetector cycleDetector = new CycleDetector(totalNodes); int edgeCount = 0; - List roots = new ArrayList<>(totalNodes); - List sizes = new ArrayList<>(totalNodes); - for (int i = 0; i < totalNodes; i++) { - roots.add(i); - sizes.add(1); - } MutableValueGraph spanningTree = ValueGraphBuilder.undirected().build(); - for (int i = 0; i < totalEdges; i++) { - EndpointPair edge = edgeList.get(i); - if (detectCycle(edge.nodeU(), edge.nodeV(), roots, sizes)) { + for (EndpointPair edge : edgeList) { + if (cycleDetector.detectCycle(edge.nodeU(), edge.nodeV())) { continue; } spanningTree.putEdgeValue(edge.nodeU(), edge.nodeV(), graph.edgeValue(edge).get()); @@ -57,32 +50,4 @@ public class Kruskal { return spanningTree; } - private Integer find(Integer x, List roots) { - Integer root = roots.get(x); - if (!root.equals(x)) { - roots.set(x, find(root, roots)); - } - return roots.get(x); - } - - private void unionBySize(Integer rootU, Integer rootV, List roots, List sizes) { - Integer total = sizes.get(rootU) + sizes.get(rootV); - if (sizes.get(rootU) < sizes.get(rootV)) { - roots.set(rootU, rootV); - sizes.set(rootV, total); - } else { - roots.set(rootV, rootU); - sizes.set(rootU, total); - } - } - - private boolean detectCycle(Integer u, Integer v, List roots, List sizes) { - Integer rootU = find(u, roots); - Integer rootV = find(v, roots); - if (rootU.equals(rootV)) { - return true; - } - unionBySize(rootU, rootV, roots, sizes); - return false; - } } diff --git a/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/kruskal/KruskalUnitTest.java b/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/kruskal/KruskalUnitTest.java index e944d2894c..a7206c6cd0 100644 --- a/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/kruskal/KruskalUnitTest.java +++ b/algorithms-miscellaneous-5/src/test/java/com/baeldung/algorithms/kruskal/KruskalUnitTest.java @@ -9,6 +9,7 @@ import org.junit.Test; import com.google.common.graph.MutableValueGraph; import com.google.common.graph.ValueGraph; import com.google.common.graph.ValueGraphBuilder; +import com.baeldung.algorithms.kruskal.Kruskal; public class KruskalUnitTest { From e86eeeb593f1849bc7fa9a095a78599693568aab Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Tue, 24 Dec 2019 10:38:48 +0100 Subject: [PATCH 05/11] BAEL-20537: Migrate apache-* modules to the com.baeldung package --- apache-fop/src/main/webapp/WEB-INF/web.xml | 2 +- .../java/ApacheFOPConvertHTMLIntegrationTest.java | 2 +- .../baeldung/java/ApacheFOPHeroldLiveTest.java | 2 +- apache-olingo/olingo2/pom.xml | 2 +- .../examples/olingo2/CarsODataJPAServiceFactory.java | 9 ++------- .../baeldung/examples/olingo2/JerseyConfig.java | 3 +-- .../examples/olingo2/Olingo2SampleApplication.java | 3 +-- .../baeldung/examples/olingo2/domain/CarMaker.java | 2 +- .../baeldung/examples/olingo2/domain/CarModel.java | 2 +- .../olingo2/Olingo2SampleApplicationUnitTest.java | 2 +- 10 files changed, 11 insertions(+), 18 deletions(-) rename apache-fop/src/test/java/{org => com}/baeldung/java/ApacheFOPConvertHTMLIntegrationTest.java (99%) rename apache-fop/src/test/java/{org => com}/baeldung/java/ApacheFOPHeroldLiveTest.java (99%) rename apache-olingo/olingo2/src/main/java/{org => com}/baeldung/examples/olingo2/CarsODataJPAServiceFactory.java (95%) rename apache-olingo/olingo2/src/main/java/{org => com}/baeldung/examples/olingo2/JerseyConfig.java (97%) rename apache-olingo/olingo2/src/main/java/{org => com}/baeldung/examples/olingo2/Olingo2SampleApplication.java (80%) rename apache-olingo/olingo2/src/main/java/{org => com}/baeldung/examples/olingo2/domain/CarMaker.java (98%) rename apache-olingo/olingo2/src/main/java/{org => com}/baeldung/examples/olingo2/domain/CarModel.java (98%) rename apache-olingo/olingo2/src/test/java/{org => com}/baeldung/examples/olingo2/Olingo2SampleApplicationUnitTest.java (89%) diff --git a/apache-fop/src/main/webapp/WEB-INF/web.xml b/apache-fop/src/main/webapp/WEB-INF/web.xml index 935beae648..31187b8064 100644 --- a/apache-fop/src/main/webapp/WEB-INF/web.xml +++ b/apache-fop/src/main/webapp/WEB-INF/web.xml @@ -16,7 +16,7 @@ contextConfigLocation - org.baeldung.config + com.baeldung.config diff --git a/apache-fop/src/test/java/org/baeldung/java/ApacheFOPConvertHTMLIntegrationTest.java b/apache-fop/src/test/java/com/baeldung/java/ApacheFOPConvertHTMLIntegrationTest.java similarity index 99% rename from apache-fop/src/test/java/org/baeldung/java/ApacheFOPConvertHTMLIntegrationTest.java rename to apache-fop/src/test/java/com/baeldung/java/ApacheFOPConvertHTMLIntegrationTest.java index 5e2da6fd1e..bfc34d83b5 100644 --- a/apache-fop/src/test/java/org/baeldung/java/ApacheFOPConvertHTMLIntegrationTest.java +++ b/apache-fop/src/test/java/com/baeldung/java/ApacheFOPConvertHTMLIntegrationTest.java @@ -1,4 +1,4 @@ -package org.baeldung.java; +package com.baeldung.java; import java.io.BufferedOutputStream; import java.io.File; diff --git a/apache-fop/src/test/java/org/baeldung/java/ApacheFOPHeroldLiveTest.java b/apache-fop/src/test/java/com/baeldung/java/ApacheFOPHeroldLiveTest.java similarity index 99% rename from apache-fop/src/test/java/org/baeldung/java/ApacheFOPHeroldLiveTest.java rename to apache-fop/src/test/java/com/baeldung/java/ApacheFOPHeroldLiveTest.java index 8496222394..af36f46d02 100644 --- a/apache-fop/src/test/java/org/baeldung/java/ApacheFOPHeroldLiveTest.java +++ b/apache-fop/src/test/java/com/baeldung/java/ApacheFOPHeroldLiveTest.java @@ -1,4 +1,4 @@ -package org.baeldung.java; +package com.baeldung.java; import java.io.BufferedOutputStream; import java.io.BufferedReader; diff --git a/apache-olingo/olingo2/pom.xml b/apache-olingo/olingo2/pom.xml index fdbc9b4390..4689fa0ca9 100644 --- a/apache-olingo/olingo2/pom.xml +++ b/apache-olingo/olingo2/pom.xml @@ -3,7 +3,7 @@ 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"> 4.0.0 - org.baeldung.examples.olingo2 + com.baeldung.examples.olingo2 olingo2 olingo2 Sample Olingo 2 Project diff --git a/apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/CarsODataJPAServiceFactory.java b/apache-olingo/olingo2/src/main/java/com/baeldung/examples/olingo2/CarsODataJPAServiceFactory.java similarity index 95% rename from apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/CarsODataJPAServiceFactory.java rename to apache-olingo/olingo2/src/main/java/com/baeldung/examples/olingo2/CarsODataJPAServiceFactory.java index 65a0428154..55155732c8 100644 --- a/apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/CarsODataJPAServiceFactory.java +++ b/apache-olingo/olingo2/src/main/java/com/baeldung/examples/olingo2/CarsODataJPAServiceFactory.java @@ -1,4 +1,4 @@ -package org.baeldung.examples.olingo2; +package com.baeldung.examples.olingo2; import java.util.List; import java.util.Map; @@ -9,10 +9,8 @@ import javax.persistence.EntityManagerFactory; import javax.persistence.EntityTransaction; import javax.persistence.FlushModeType; import javax.persistence.LockModeType; -import javax.persistence.Persistence; import javax.persistence.Query; import javax.persistence.StoredProcedureQuery; -import javax.persistence.SynchronizationType; import javax.persistence.TypedQuery; import javax.persistence.criteria.CriteriaBuilder; import javax.persistence.criteria.CriteriaDelete; @@ -25,11 +23,8 @@ import org.apache.olingo.odata2.api.processor.ODataContext; import org.apache.olingo.odata2.jpa.processor.api.ODataJPAContext; import org.apache.olingo.odata2.jpa.processor.api.ODataJPAServiceFactory; import org.apache.olingo.odata2.jpa.processor.api.exception.ODataJPARuntimeException; -import org.baeldung.examples.olingo2.JerseyConfig.EntityManagerFilter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.orm.jpa.EntityManagerFactoryUtils; -import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; import org.springframework.stereotype.Component; /** @@ -58,7 +53,7 @@ public class CarsODataJPAServiceFactory extends ODataJPAServiceFactory { ODataJPAContext ctx = getODataJPAContext(); ODataContext octx = ctx.getODataContext(); HttpServletRequest request = (HttpServletRequest)octx.getParameter(ODataContext.HTTP_SERVLET_REQUEST_OBJECT); - EntityManager em = (EntityManager)request.getAttribute(EntityManagerFilter.EM_REQUEST_ATTRIBUTE); + EntityManager em = (EntityManager)request.getAttribute(JerseyConfig.EntityManagerFilter.EM_REQUEST_ATTRIBUTE); // Here we're passing the EM that was created by the EntityManagerFilter (see JerseyConfig) ctx.setEntityManager(new EntityManagerWrapper(em)); diff --git a/apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/JerseyConfig.java b/apache-olingo/olingo2/src/main/java/com/baeldung/examples/olingo2/JerseyConfig.java similarity index 97% rename from apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/JerseyConfig.java rename to apache-olingo/olingo2/src/main/java/com/baeldung/examples/olingo2/JerseyConfig.java index 78caf99861..02e5ce5adf 100644 --- a/apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/JerseyConfig.java +++ b/apache-olingo/olingo2/src/main/java/com/baeldung/examples/olingo2/JerseyConfig.java @@ -1,11 +1,10 @@ - package org.baeldung.examples.olingo2; + package com.baeldung.examples.olingo2; import java.io.IOException; import javax.persistence.EntityManager; import javax.persistence.EntityManagerFactory; import javax.persistence.EntityTransaction; -import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.ApplicationPath; import javax.ws.rs.Path; diff --git a/apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/Olingo2SampleApplication.java b/apache-olingo/olingo2/src/main/java/com/baeldung/examples/olingo2/Olingo2SampleApplication.java similarity index 80% rename from apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/Olingo2SampleApplication.java rename to apache-olingo/olingo2/src/main/java/com/baeldung/examples/olingo2/Olingo2SampleApplication.java index fa58612088..f76e0e00e3 100644 --- a/apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/Olingo2SampleApplication.java +++ b/apache-olingo/olingo2/src/main/java/com/baeldung/examples/olingo2/Olingo2SampleApplication.java @@ -1,8 +1,7 @@ -package org.baeldung.examples.olingo2; +package com.baeldung.examples.olingo2; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.builder.SpringApplicationBuilder; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; @SpringBootApplication diff --git a/apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/domain/CarMaker.java b/apache-olingo/olingo2/src/main/java/com/baeldung/examples/olingo2/domain/CarMaker.java similarity index 98% rename from apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/domain/CarMaker.java rename to apache-olingo/olingo2/src/main/java/com/baeldung/examples/olingo2/domain/CarMaker.java index e66d266062..d56a42374c 100644 --- a/apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/domain/CarMaker.java +++ b/apache-olingo/olingo2/src/main/java/com/baeldung/examples/olingo2/domain/CarMaker.java @@ -1,4 +1,4 @@ -package org.baeldung.examples.olingo2.domain; +package com.baeldung.examples.olingo2.domain; import java.util.List; diff --git a/apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/domain/CarModel.java b/apache-olingo/olingo2/src/main/java/com/baeldung/examples/olingo2/domain/CarModel.java similarity index 98% rename from apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/domain/CarModel.java rename to apache-olingo/olingo2/src/main/java/com/baeldung/examples/olingo2/domain/CarModel.java index f9f563e01e..6bbaa3ad0c 100644 --- a/apache-olingo/olingo2/src/main/java/org/baeldung/examples/olingo2/domain/CarModel.java +++ b/apache-olingo/olingo2/src/main/java/com/baeldung/examples/olingo2/domain/CarModel.java @@ -1,4 +1,4 @@ -package org.baeldung.examples.olingo2.domain; +package com.baeldung.examples.olingo2.domain; import javax.persistence.Entity; import javax.persistence.FetchType; diff --git a/apache-olingo/olingo2/src/test/java/org/baeldung/examples/olingo2/Olingo2SampleApplicationUnitTest.java b/apache-olingo/olingo2/src/test/java/com/baeldung/examples/olingo2/Olingo2SampleApplicationUnitTest.java similarity index 89% rename from apache-olingo/olingo2/src/test/java/org/baeldung/examples/olingo2/Olingo2SampleApplicationUnitTest.java rename to apache-olingo/olingo2/src/test/java/com/baeldung/examples/olingo2/Olingo2SampleApplicationUnitTest.java index 7cb685e3e9..74033a49cd 100644 --- a/apache-olingo/olingo2/src/test/java/org/baeldung/examples/olingo2/Olingo2SampleApplicationUnitTest.java +++ b/apache-olingo/olingo2/src/test/java/com/baeldung/examples/olingo2/Olingo2SampleApplicationUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.examples.olingo2; +package com.baeldung.examples.olingo2; import org.junit.Test; import org.junit.runner.RunWith; From 736b684c2440bb03f5ce33cb24b387ed8fd71112 Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Tue, 24 Dec 2019 10:44:49 +0100 Subject: [PATCH 06/11] BAEL-20537: Migrate custom-pmd module to the com.baeldung package --- custom-pmd/pom.xml | 2 +- .../{org => com}/baeldung/pmd/UnitTestNamingConventionRule.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename custom-pmd/src/main/java/{org => com}/baeldung/pmd/UnitTestNamingConventionRule.java (97%) diff --git a/custom-pmd/pom.xml b/custom-pmd/pom.xml index 601eedf08f..a011b6a121 100644 --- a/custom-pmd/pom.xml +++ b/custom-pmd/pom.xml @@ -2,7 +2,7 @@ 4.0.0 - org.baeldung.pmd + com.baeldung.pmd custom-pmd 0.0.1 custom-pmd diff --git a/custom-pmd/src/main/java/org/baeldung/pmd/UnitTestNamingConventionRule.java b/custom-pmd/src/main/java/com/baeldung/pmd/UnitTestNamingConventionRule.java similarity index 97% rename from custom-pmd/src/main/java/org/baeldung/pmd/UnitTestNamingConventionRule.java rename to custom-pmd/src/main/java/com/baeldung/pmd/UnitTestNamingConventionRule.java index 2cbab782ee..e30164ac4f 100644 --- a/custom-pmd/src/main/java/org/baeldung/pmd/UnitTestNamingConventionRule.java +++ b/custom-pmd/src/main/java/com/baeldung/pmd/UnitTestNamingConventionRule.java @@ -1,4 +1,4 @@ -package org.baeldung.pmd; +package com.baeldung.pmd; import net.sourceforge.pmd.lang.java.ast.ASTClassOrInterfaceDeclaration; import net.sourceforge.pmd.lang.java.rule.AbstractJavaRule; From 2ece7dbb4fe24789d4b7be869011b371e054abc3 Mon Sep 17 00:00:00 2001 From: Krzysztof Woyke Date: Tue, 24 Dec 2019 11:00:12 +0100 Subject: [PATCH 07/11] BAEL-20537: Migrate grpc module to the com.baeldung package --- .../{org => com}/baeldung/grpc/client/GrpcClient.java | 8 ++++---- .../{org => com}/baeldung/grpc/server/GrpcServer.java | 2 +- .../baeldung/grpc/server/HelloServiceImpl.java | 8 ++++---- grpc/src/main/proto/HelloService.proto | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) rename grpc/src/main/java/{org => com}/baeldung/grpc/client/GrpcClient.java (81%) rename grpc/src/main/java/{org => com}/baeldung/grpc/server/GrpcServer.java (93%) rename grpc/src/main/java/{org => com}/baeldung/grpc/server/HelloServiceImpl.java (79%) diff --git a/grpc/src/main/java/org/baeldung/grpc/client/GrpcClient.java b/grpc/src/main/java/com/baeldung/grpc/client/GrpcClient.java similarity index 81% rename from grpc/src/main/java/org/baeldung/grpc/client/GrpcClient.java rename to grpc/src/main/java/com/baeldung/grpc/client/GrpcClient.java index f653e17910..f10b24faa7 100644 --- a/grpc/src/main/java/org/baeldung/grpc/client/GrpcClient.java +++ b/grpc/src/main/java/com/baeldung/grpc/client/GrpcClient.java @@ -1,8 +1,8 @@ -package org.baeldung.grpc.client; +package com.baeldung.grpc.client; -import org.baeldung.grpc.HelloRequest; -import org.baeldung.grpc.HelloResponse; -import org.baeldung.grpc.HelloServiceGrpc; +import com.baeldung.grpc.HelloRequest; +import com.baeldung.grpc.HelloResponse; +import com.baeldung.grpc.HelloServiceGrpc; import io.grpc.ManagedChannel; import io.grpc.ManagedChannelBuilder; diff --git a/grpc/src/main/java/org/baeldung/grpc/server/GrpcServer.java b/grpc/src/main/java/com/baeldung/grpc/server/GrpcServer.java similarity index 93% rename from grpc/src/main/java/org/baeldung/grpc/server/GrpcServer.java rename to grpc/src/main/java/com/baeldung/grpc/server/GrpcServer.java index 8a2b94e53b..2380d73a8c 100644 --- a/grpc/src/main/java/org/baeldung/grpc/server/GrpcServer.java +++ b/grpc/src/main/java/com/baeldung/grpc/server/GrpcServer.java @@ -1,4 +1,4 @@ -package org.baeldung.grpc.server; +package com.baeldung.grpc.server; import java.io.IOException; diff --git a/grpc/src/main/java/org/baeldung/grpc/server/HelloServiceImpl.java b/grpc/src/main/java/com/baeldung/grpc/server/HelloServiceImpl.java similarity index 79% rename from grpc/src/main/java/org/baeldung/grpc/server/HelloServiceImpl.java rename to grpc/src/main/java/com/baeldung/grpc/server/HelloServiceImpl.java index b08ad02c97..8609477fe9 100644 --- a/grpc/src/main/java/org/baeldung/grpc/server/HelloServiceImpl.java +++ b/grpc/src/main/java/com/baeldung/grpc/server/HelloServiceImpl.java @@ -1,8 +1,8 @@ -package org.baeldung.grpc.server; +package com.baeldung.grpc.server; -import org.baeldung.grpc.HelloRequest; -import org.baeldung.grpc.HelloResponse; -import org.baeldung.grpc.HelloServiceGrpc.HelloServiceImplBase; +import com.baeldung.grpc.HelloRequest; +import com.baeldung.grpc.HelloResponse; +import com.baeldung.grpc.HelloServiceGrpc.HelloServiceImplBase; import io.grpc.stub.StreamObserver; diff --git a/grpc/src/main/proto/HelloService.proto b/grpc/src/main/proto/HelloService.proto index 4f53191ab9..a008fad4b0 100644 --- a/grpc/src/main/proto/HelloService.proto +++ b/grpc/src/main/proto/HelloService.proto @@ -1,6 +1,6 @@ syntax = "proto3"; option java_multiple_files = true; -package org.baeldung.grpc; +package com.baeldung.grpc; message HelloRequest { string firstName = 1; From b99b7b8b25619e744c499c7e53310e132eb22f0a Mon Sep 17 00:00:00 2001 From: "amit.pandey" Date: Tue, 24 Dec 2019 17:17:09 +0530 Subject: [PATCH 08/11] [BAEL-18774] - extracted versions into properties --- spring-boot-data/pom.xml | 14 +++++++------ .../spring-boot-with-starter-parent/pom.xml | 3 ++- .../property-exp-custom-config/pom.xml | 6 ++++-- spring-boot-testing/pom.xml | 3 ++- spring-cloud/spring-cloud-aws/pom.xml | 3 ++- .../spring-cloud-contract-producer/pom.xml | 6 +++++- spring-cloud/spring-cloud-functions/pom.xml | 3 ++- .../travel-agency-service/pom.xml | 3 ++- spring-core-2/pom.xml | 3 ++- spring-data-rest-querydsl/pom.xml | 11 +++++++--- spring-data-rest/pom.xml | 3 ++- spring-ejb/wildfly/wildfly-ear/pom.xml | 3 ++- spring-integration/pom.xml | 3 ++- spring-jms/pom.xml | 3 ++- spring-mvc-java/pom.xml | 21 ++++++++++++------- .../remoting-hessian-burlap-client/pom.xml | 5 ++++- spring-rest-hal-browser/pom.xml | 20 ++++++++++++------ spring-resttemplate/pom.xml | 12 +++++++---- 18 files changed, 85 insertions(+), 40 deletions(-) diff --git a/spring-boot-data/pom.xml b/spring-boot-data/pom.xml index 663ee640f3..f9e51920c2 100644 --- a/spring-boot-data/pom.xml +++ b/spring-boot-data/pom.xml @@ -97,8 +97,8 @@ org.apache.maven.plugins maven-compiler-plugin - 8 - 8 + ${source.version} + ${target.version} @@ -121,8 +121,8 @@ org.apache.maven.plugins maven-compiler-plugin - 8 - 8 + ${source.version} + ${target.version} @@ -156,8 +156,8 @@ org.apache.maven.plugins maven-compiler-plugin - 1.8 - 1.8 + ${source.version} + ${target.version} @@ -168,6 +168,8 @@ 5.6.3 2.2.4 + 1.8 + 1.8 diff --git a/spring-boot-parent/spring-boot-with-starter-parent/pom.xml b/spring-boot-parent/spring-boot-with-starter-parent/pom.xml index 9ea26e49fe..ed2cb8646c 100644 --- a/spring-boot-parent/spring-boot-with-starter-parent/pom.xml +++ b/spring-boot-parent/spring-boot-with-starter-parent/pom.xml @@ -20,7 +20,7 @@ org.springframework.boot spring-boot-starter-data-jpa - 2.1.1.RELEASE + ${spring-boot.version} @@ -38,6 +38,7 @@ 1.8 + 2.1.1.RELEASE 4.11 diff --git a/spring-boot-property-exp/property-exp-custom-config/pom.xml b/spring-boot-property-exp/property-exp-custom-config/pom.xml index f9c3d6ef62..0118de7396 100644 --- a/spring-boot-property-exp/property-exp-custom-config/pom.xml +++ b/spring-boot-property-exp/property-exp-custom-config/pom.xml @@ -52,7 +52,7 @@ org.apache.maven.plugins maven-resources-plugin - 2.7 + ${apache-maven.version} @ @@ -63,7 +63,7 @@ org.codehaus.mojo exec-maven-plugin - 1.6.0 + ${exec-maven-plugin.version} com.baeldung.propertyexpansion.SpringBootPropertyExpansionApp @@ -74,6 +74,8 @@ 1.5.10.RELEASE Custom Property Value + 2.7 + 1.6.0 diff --git a/spring-boot-testing/pom.xml b/spring-boot-testing/pom.xml index ebe87fdd70..5f358072d3 100644 --- a/spring-boot-testing/pom.xml +++ b/spring-boot-testing/pom.xml @@ -42,7 +42,7 @@ it.ozimov embedded-redis - 0.7.2 + ${redis.version} test @@ -131,6 +131,7 @@ 2.2.4 1.2-groovy-2.4 1.6 + 0.7.2 diff --git a/spring-cloud/spring-cloud-aws/pom.xml b/spring-cloud/spring-cloud-aws/pom.xml index c1fc458a24..abf9363288 100644 --- a/spring-cloud/spring-cloud-aws/pom.xml +++ b/spring-cloud/spring-cloud-aws/pom.xml @@ -50,7 +50,7 @@ org.springframework.cloud spring-cloud-aws - 2.0.1.RELEASE + ${spring-cloud} pom import @@ -60,6 +60,7 @@ com.baeldung.spring.cloud.aws.SpringCloudAwsApplication Dalston.SR4 + 2.0.1.RELEASE diff --git a/spring-cloud/spring-cloud-contract/spring-cloud-contract-producer/pom.xml b/spring-cloud/spring-cloud-contract/spring-cloud-contract-producer/pom.xml index c41ad687ed..e909dbc253 100644 --- a/spring-cloud/spring-cloud-contract/spring-cloud-contract-producer/pom.xml +++ b/spring-cloud/spring-cloud-contract/spring-cloud-contract-producer/pom.xml @@ -36,7 +36,7 @@ org.springframework.cloud spring-cloud-contract-maven-plugin - 2.1.1.RELEASE + ${spring-cloud.version} true com.baeldung.spring.cloud.springcloudcontractproducer.BaseTestClass @@ -45,4 +45,8 @@ + + + 2.1.1.RELEASE + diff --git a/spring-cloud/spring-cloud-functions/pom.xml b/spring-cloud/spring-cloud-functions/pom.xml index 2e1b747c2e..03510d0504 100644 --- a/spring-cloud/spring-cloud-functions/pom.xml +++ b/spring-cloud/spring-cloud-functions/pom.xml @@ -65,7 +65,7 @@ org.springframework.boot.experimental spring-boot-thin-layout - 1.0.10.RELEASE + ${spring-boot-thin.version} @@ -88,6 +88,7 @@ 2.0.2 1.1.0 2.0.4.RELEASE + 1.0.10.RELEASE diff --git a/spring-cloud/spring-cloud-kubernetes/kubernetes-guide/travel-agency-service/pom.xml b/spring-cloud/spring-cloud-kubernetes/kubernetes-guide/travel-agency-service/pom.xml index 93734a19a7..5459b77682 100644 --- a/spring-cloud/spring-cloud-kubernetes/kubernetes-guide/travel-agency-service/pom.xml +++ b/spring-cloud/spring-cloud-kubernetes/kubernetes-guide/travel-agency-service/pom.xml @@ -24,7 +24,7 @@ ch.qos.logback logback-classic - 1.2.3 + ${logback.version} @@ -71,6 +71,7 @@ Finchley.SR2 + 1.2.3 \ No newline at end of file diff --git a/spring-core-2/pom.xml b/spring-core-2/pom.xml index 12b6972a79..78b94880d0 100644 --- a/spring-core-2/pom.xml +++ b/spring-core-2/pom.xml @@ -174,7 +174,7 @@ org.apache.maven.plugins maven-war-plugin - 3.2.2 + ${maven.version} false @@ -214,6 +214,7 @@ 3.6.1 2.1.0 3.22.0-GA + 3.2.2 diff --git a/spring-data-rest-querydsl/pom.xml b/spring-data-rest-querydsl/pom.xml index 9f53f6b55f..c0ad43fe0b 100644 --- a/spring-data-rest-querydsl/pom.xml +++ b/spring-data-rest-querydsl/pom.xml @@ -72,8 +72,8 @@ org.apache.maven.plugins maven-compiler-plugin - 1.8 - 1.8 + ${maven.source} + ${maven.target} -verbose -parameters @@ -83,7 +83,7 @@ com.mysema.maven apt-maven-plugin - 1.1.3 + ${mysema.version} generate-sources @@ -99,5 +99,10 @@ + + 1.8 + 1.8 + 1.1.3 + diff --git a/spring-data-rest/pom.xml b/spring-data-rest/pom.xml index 05f2ccbbae..bb592c08d5 100644 --- a/spring-data-rest/pom.xml +++ b/spring-data-rest/pom.xml @@ -66,7 +66,7 @@ com.mysema.maven maven-apt-plugin - 1.0 + ${maven.version} generate-sources @@ -90,6 +90,7 @@ UTF-8 com.baeldung.books.SpringDataRestApplication + 1.0 \ No newline at end of file diff --git a/spring-ejb/wildfly/wildfly-ear/pom.xml b/spring-ejb/wildfly/wildfly-ear/pom.xml index 9393820b12..07f53358bf 100644 --- a/spring-ejb/wildfly/wildfly-ear/pom.xml +++ b/spring-ejb/wildfly/wildfly-ear/pom.xml @@ -45,7 +45,7 @@ ${maven-ear-plugin.version} lib/ - 7 + ${defaultLibBundleDir.version} com.baeldung.wildfly @@ -66,6 +66,7 @@ 2.10.1 1.2.0.Final + 7 \ No newline at end of file diff --git a/spring-integration/pom.xml b/spring-integration/pom.xml index ebdde5a1ee..a985f55d89 100644 --- a/spring-integration/pom.xml +++ b/spring-integration/pom.xml @@ -85,7 +85,7 @@ com.h2database h2 - 1.4.197 + ${h2.version} @@ -124,6 +124,7 @@ 1.1.1 2.10 1.5.0 + 1.4.197 diff --git a/spring-jms/pom.xml b/spring-jms/pom.xml index a0d2625477..9cd9126fac 100644 --- a/spring-jms/pom.xml +++ b/spring-jms/pom.xml @@ -38,7 +38,7 @@ org.springframework.boot spring-boot-starter-test - 1.5.10.RELEASE + ${spring-boot-test.version} test @@ -64,6 +64,7 @@ 4.3.4.RELEASE 5.14.1 + 1.5.10.RELEASE diff --git a/spring-mvc-java/pom.xml b/spring-mvc-java/pom.xml index 7d0afd85ec..dd197bbeb5 100644 --- a/spring-mvc-java/pom.xml +++ b/spring-mvc-java/pom.xml @@ -26,12 +26,12 @@ javax.servlet javax.servlet-api - 4.0.1 + ${javax.version} javax.servlet.jsp javax.servlet.jsp-api - 2.3.3 + ${javax-servlet-api.version} javax.servlet @@ -53,19 +53,19 @@ org.aspectj aspectjrt - 1.9.1 + ${aspectjrt.version} org.aspectj aspectjweaver - 1.9.1 + ${aspectjweaver.version} net.sourceforge.htmlunit htmlunit - 2.32 + ${htmlunit.version} commons-logging @@ -99,7 +99,7 @@ com.jayway.jsonpath json-path test - 2.4.0 + ${json-path.version} org.springframework.boot @@ -126,7 +126,7 @@ com.google.code.gson gson - 2.8.5 + ${gson.version} org.springframework.boot @@ -283,6 +283,13 @@ 3.16-beta1 3.0.1-b09 + 4.0.1 + 2.3.3 + 1.9.1 + 1.9.1 + 2.32 + 2.4.0 + 2.8.5 com.baeldung.SpringMVCApplication diff --git a/spring-remoting/remoting-hessian-burlap/remoting-hessian-burlap-client/pom.xml b/spring-remoting/remoting-hessian-burlap/remoting-hessian-burlap-client/pom.xml index 1f6181a365..20680d5880 100644 --- a/spring-remoting/remoting-hessian-burlap/remoting-hessian-burlap-client/pom.xml +++ b/spring-remoting/remoting-hessian-burlap/remoting-hessian-burlap-client/pom.xml @@ -31,7 +31,7 @@ com.caucho hessian - 4.0.38 + ${hessian.version} @@ -58,5 +58,8 @@ + + 4.0.38 + \ No newline at end of file diff --git a/spring-rest-hal-browser/pom.xml b/spring-rest-hal-browser/pom.xml index 94ce837b27..adef8bf2b0 100644 --- a/spring-rest-hal-browser/pom.xml +++ b/spring-rest-hal-browser/pom.xml @@ -19,25 +19,25 @@ org.springframework.boot spring-boot-starter-web - 2.0.3.RELEASE + ${spring-boot.version} org.springframework.boot spring-boot-starter-data-jpa - 2.0.3.RELEASE + ${spring-boot.version} org.springframework.data spring-data-rest-hal-browser - 3.0.8.RELEASE + ${spring-data.version} com.h2database h2 - 1.4.197 + ${h2.version} @@ -47,11 +47,19 @@ org.apache.maven.plugins maven-compiler-plugin - 1.8 - 1.8 + ${source.version} + ${target.version} + + 2.0.3.RELEASE + 3.0.8.RELEASE + 1.4.197 + 1.8 + 1.8 + + \ No newline at end of file diff --git a/spring-resttemplate/pom.xml b/spring-resttemplate/pom.xml index 0b5d0b20d0..138fde3b45 100644 --- a/spring-resttemplate/pom.xml +++ b/spring-resttemplate/pom.xml @@ -125,7 +125,7 @@ junit junit - 4.12 + ${junit.version} @@ -162,10 +162,10 @@ org.apache.maven.plugins maven-compiler-plugin - 3.7.0 + ${maven.version} - 1.8 - 1.8 + ${source.version} + ${target.version} @@ -308,6 +308,10 @@ 3.4.1 3.5.11 + 1.8 + 1.8 + 4.12 + 3.7.0 From f342d284028375ecc1b538349a29be0e1194c351 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Tue, 24 Dec 2019 13:08:05 +0100 Subject: [PATCH 09/11] BAEL-20537: Migrate tensorflow-java module to the com.baeldung package --- .../java/{org => com}/baeldung/tensorflow/TensorflowGraph.java | 2 +- .../{org => com}/baeldung/tensorflow/TensorflowSavedModel.java | 2 +- .../baeldung/tensorflow/TensorflowGraphUnitTest.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename tensorflow-java/src/main/java/{org => com}/baeldung/tensorflow/TensorflowGraph.java (98%) rename tensorflow-java/src/main/java/{org => com}/baeldung/tensorflow/TensorflowSavedModel.java (93%) rename tensorflow-java/src/test/java/{org => com}/baeldung/tensorflow/TensorflowGraphUnitTest.java (92%) diff --git a/tensorflow-java/src/main/java/org/baeldung/tensorflow/TensorflowGraph.java b/tensorflow-java/src/main/java/com/baeldung/tensorflow/TensorflowGraph.java similarity index 98% rename from tensorflow-java/src/main/java/org/baeldung/tensorflow/TensorflowGraph.java rename to tensorflow-java/src/main/java/com/baeldung/tensorflow/TensorflowGraph.java index a44ef4c4ee..5d9a85a491 100644 --- a/tensorflow-java/src/main/java/org/baeldung/tensorflow/TensorflowGraph.java +++ b/tensorflow-java/src/main/java/com/baeldung/tensorflow/TensorflowGraph.java @@ -1,4 +1,4 @@ -package org.baeldung.tensorflow; +package com.baeldung.tensorflow; import org.tensorflow.DataType; import org.tensorflow.Graph; diff --git a/tensorflow-java/src/main/java/org/baeldung/tensorflow/TensorflowSavedModel.java b/tensorflow-java/src/main/java/com/baeldung/tensorflow/TensorflowSavedModel.java similarity index 93% rename from tensorflow-java/src/main/java/org/baeldung/tensorflow/TensorflowSavedModel.java rename to tensorflow-java/src/main/java/com/baeldung/tensorflow/TensorflowSavedModel.java index 4259a787e8..96a063dff2 100644 --- a/tensorflow-java/src/main/java/org/baeldung/tensorflow/TensorflowSavedModel.java +++ b/tensorflow-java/src/main/java/com/baeldung/tensorflow/TensorflowSavedModel.java @@ -1,4 +1,4 @@ -package org.baeldung.tensorflow; +package com.baeldung.tensorflow; import org.tensorflow.SavedModelBundle; import org.tensorflow.Tensor; diff --git a/tensorflow-java/src/test/java/org/baeldung/tensorflow/TensorflowGraphUnitTest.java b/tensorflow-java/src/test/java/com/baeldung/tensorflow/TensorflowGraphUnitTest.java similarity index 92% rename from tensorflow-java/src/test/java/org/baeldung/tensorflow/TensorflowGraphUnitTest.java rename to tensorflow-java/src/test/java/com/baeldung/tensorflow/TensorflowGraphUnitTest.java index 51df6a4322..c2799a4bb1 100644 --- a/tensorflow-java/src/test/java/org/baeldung/tensorflow/TensorflowGraphUnitTest.java +++ b/tensorflow-java/src/test/java/com/baeldung/tensorflow/TensorflowGraphUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.tensorflow; +package com.baeldung.tensorflow; import static org.junit.jupiter.api.Assertions.assertEquals; From c4fc1b9aefac65b254927216091dc5b4341ef930 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Tue, 24 Dec 2019 13:13:41 +0100 Subject: [PATCH 10/11] BAEL-20537: Migrate guava-* modules to the com.baeldung package --- .../test/java/{org => com}/baeldung/guava/GuavaMapFromSet.java | 2 +- .../{org => com}/baeldung/guava/GuavaMapFromSetUnitTest.java | 2 +- .../java/{org => com}/baeldung/guava/GuavaMultiSetUnitTest.java | 2 +- .../java/{org => com}/baeldung/guava/GuavaRangeSetUnitTest.java | 2 +- .../{org => com}/baeldung/guava/GuavaSetOperationsUnitTest.java | 2 +- .../com/baeldung/guava/GuavaCountingOutputStreamUnitTest.java | 2 +- .../src/main/test/java/com/baeldung/guava/GuavaIOUnitTest.java | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) rename guava-collections-set/src/test/java/{org => com}/baeldung/guava/GuavaMapFromSet.java (98%) rename guava-collections-set/src/test/java/{org => com}/baeldung/guava/GuavaMapFromSetUnitTest.java (98%) rename guava-collections-set/src/test/java/{org => com}/baeldung/guava/GuavaMultiSetUnitTest.java (99%) rename guava-collections-set/src/test/java/{org => com}/baeldung/guava/GuavaRangeSetUnitTest.java (99%) rename guava-collections-set/src/test/java/{org => com}/baeldung/guava/GuavaSetOperationsUnitTest.java (99%) diff --git a/guava-collections-set/src/test/java/org/baeldung/guava/GuavaMapFromSet.java b/guava-collections-set/src/test/java/com/baeldung/guava/GuavaMapFromSet.java similarity index 98% rename from guava-collections-set/src/test/java/org/baeldung/guava/GuavaMapFromSet.java rename to guava-collections-set/src/test/java/com/baeldung/guava/GuavaMapFromSet.java index f474fcb17b..d2c772080d 100644 --- a/guava-collections-set/src/test/java/org/baeldung/guava/GuavaMapFromSet.java +++ b/guava-collections-set/src/test/java/com/baeldung/guava/GuavaMapFromSet.java @@ -1,4 +1,4 @@ -package org.baeldung.guava; +package com.baeldung.guava; import com.google.common.base.Function; diff --git a/guava-collections-set/src/test/java/org/baeldung/guava/GuavaMapFromSetUnitTest.java b/guava-collections-set/src/test/java/com/baeldung/guava/GuavaMapFromSetUnitTest.java similarity index 98% rename from guava-collections-set/src/test/java/org/baeldung/guava/GuavaMapFromSetUnitTest.java rename to guava-collections-set/src/test/java/com/baeldung/guava/GuavaMapFromSetUnitTest.java index 03f2d8f891..71a526601b 100644 --- a/guava-collections-set/src/test/java/org/baeldung/guava/GuavaMapFromSetUnitTest.java +++ b/guava-collections-set/src/test/java/com/baeldung/guava/GuavaMapFromSetUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.guava; +package com.baeldung.guava; import com.google.common.base.Function; import org.junit.Test; diff --git a/guava-collections-set/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java b/guava-collections-set/src/test/java/com/baeldung/guava/GuavaMultiSetUnitTest.java similarity index 99% rename from guava-collections-set/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java rename to guava-collections-set/src/test/java/com/baeldung/guava/GuavaMultiSetUnitTest.java index e74db29881..dc1489f7ea 100644 --- a/guava-collections-set/src/test/java/org/baeldung/guava/GuavaMultiSetUnitTest.java +++ b/guava-collections-set/src/test/java/com/baeldung/guava/GuavaMultiSetUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.guava; +package com.baeldung.guava; import com.google.common.collect.HashMultiset; import com.google.common.collect.Multiset; diff --git a/guava-collections-set/src/test/java/org/baeldung/guava/GuavaRangeSetUnitTest.java b/guava-collections-set/src/test/java/com/baeldung/guava/GuavaRangeSetUnitTest.java similarity index 99% rename from guava-collections-set/src/test/java/org/baeldung/guava/GuavaRangeSetUnitTest.java rename to guava-collections-set/src/test/java/com/baeldung/guava/GuavaRangeSetUnitTest.java index edefc61fc4..bd9aa09941 100644 --- a/guava-collections-set/src/test/java/org/baeldung/guava/GuavaRangeSetUnitTest.java +++ b/guava-collections-set/src/test/java/com/baeldung/guava/GuavaRangeSetUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.guava; +package com.baeldung.guava; import com.google.common.collect.ImmutableRangeSet; import com.google.common.collect.Range; diff --git a/guava-collections-set/src/test/java/org/baeldung/guava/GuavaSetOperationsUnitTest.java b/guava-collections-set/src/test/java/com/baeldung/guava/GuavaSetOperationsUnitTest.java similarity index 99% rename from guava-collections-set/src/test/java/org/baeldung/guava/GuavaSetOperationsUnitTest.java rename to guava-collections-set/src/test/java/com/baeldung/guava/GuavaSetOperationsUnitTest.java index dfd90ad738..eaa6d8a832 100644 --- a/guava-collections-set/src/test/java/org/baeldung/guava/GuavaSetOperationsUnitTest.java +++ b/guava-collections-set/src/test/java/com/baeldung/guava/GuavaSetOperationsUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.guava; +package com.baeldung.guava; import com.google.common.base.Function; import com.google.common.base.Joiner; diff --git a/guava-io/src/main/test/java/com/baeldung/guava/GuavaCountingOutputStreamUnitTest.java b/guava-io/src/main/test/java/com/baeldung/guava/GuavaCountingOutputStreamUnitTest.java index 7293b1631e..5d846933f9 100644 --- a/guava-io/src/main/test/java/com/baeldung/guava/GuavaCountingOutputStreamUnitTest.java +++ b/guava-io/src/main/test/java/com/baeldung/guava/GuavaCountingOutputStreamUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.guava; +package com.baeldung.guava; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; diff --git a/guava-io/src/main/test/java/com/baeldung/guava/GuavaIOUnitTest.java b/guava-io/src/main/test/java/com/baeldung/guava/GuavaIOUnitTest.java index 4a827dfbc0..7d7b0ea04d 100644 --- a/guava-io/src/main/test/java/com/baeldung/guava/GuavaIOUnitTest.java +++ b/guava-io/src/main/test/java/com/baeldung/guava/GuavaIOUnitTest.java @@ -1,4 +1,4 @@ -package org.baeldung.guava; +package com.baeldung.guava; import static org.hamcrest.Matchers.contains; import static org.junit.Assert.assertEquals; From a31800fbb7a13487f828c49bdf94211db052e887 Mon Sep 17 00:00:00 2001 From: Krzysiek Date: Tue, 24 Dec 2019 13:20:50 +0100 Subject: [PATCH 11/11] BAEL-20537: Migrate to the com.baeldung package --- .../baeldung/java/io/remote/SftpFileTransferLiveTest.java | 2 +- .../src/main/java/com/baeldung/enforcer/MyCustomRule.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename libraries-io/src/test/java/{org => com}/baeldung/java/io/remote/SftpFileTransferLiveTest.java (99%) diff --git a/libraries-io/src/test/java/org/baeldung/java/io/remote/SftpFileTransferLiveTest.java b/libraries-io/src/test/java/com/baeldung/java/io/remote/SftpFileTransferLiveTest.java similarity index 99% rename from libraries-io/src/test/java/org/baeldung/java/io/remote/SftpFileTransferLiveTest.java rename to libraries-io/src/test/java/com/baeldung/java/io/remote/SftpFileTransferLiveTest.java index 192153bc90..5846128082 100644 --- a/libraries-io/src/test/java/org/baeldung/java/io/remote/SftpFileTransferLiveTest.java +++ b/libraries-io/src/test/java/com/baeldung/java/io/remote/SftpFileTransferLiveTest.java @@ -1,4 +1,4 @@ -package org.baeldung.java.io.remote; +package com.baeldung.java.io.remote; import java.io.IOException; diff --git a/maven-all/maven/custom-rule/src/main/java/com/baeldung/enforcer/MyCustomRule.java b/maven-all/maven/custom-rule/src/main/java/com/baeldung/enforcer/MyCustomRule.java index 9b72f40bf1..db636c2308 100644 --- a/maven-all/maven/custom-rule/src/main/java/com/baeldung/enforcer/MyCustomRule.java +++ b/maven-all/maven/custom-rule/src/main/java/com/baeldung/enforcer/MyCustomRule.java @@ -19,8 +19,8 @@ public class MyCustomRule implements EnforcerRule { String groupId = (String) enforcerRuleHelper.evaluate("${project.groupId}"); - if (groupId == null || !groupId.startsWith("org.baeldung")) { - throw new EnforcerRuleException("Project group id does not start with org.baeldung"); + if (groupId == null || !groupId.startsWith("com.baeldung")) { + throw new EnforcerRuleException("Project group id does not start with com.baeldung"); } }