Merge branch 'master' of https://github.com/chris9408/tutorials into feature/selenium-cookies

This commit is contained in:
chris9408 2019-12-27 15:28:12 +02:00
commit 4739d48e95
110 changed files with 469 additions and 124 deletions

View File

@ -34,6 +34,11 @@
<artifactId>tradukisto</artifactId>
<version>${tradukisto.version}</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>28.1-jre</version>
</dependency>
<dependency>
<groupId>org.assertj</groupId>

View File

@ -0,0 +1,72 @@
package com.baeldung.algorithms.kruskal;
import java.util.ArrayList;
import java.util.List;
public class CycleDetector {
List<DisjointSetInfo> 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);
}
}
}
}

View File

@ -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;
}
}

View File

@ -0,0 +1,53 @@
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<Integer, Double> minSpanningTree(ValueGraph<Integer, Double> graph) {
return spanningTree(graph, true);
}
public ValueGraph<Integer, Double> maxSpanningTree(ValueGraph<Integer, Double> graph) {
return spanningTree(graph, false);
}
private ValueGraph<Integer, Double> spanningTree(ValueGraph<Integer, Double> graph, boolean minSpanningTree) {
Set<EndpointPair<Integer>> edges = graph.edges();
List<EndpointPair<Integer>> 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 totalNodes = graph.nodes().size();
CycleDetector cycleDetector = new CycleDetector(totalNodes);
int edgeCount = 0;
MutableValueGraph<Integer, Double> spanningTree = ValueGraphBuilder.undirected().build();
for (EndpointPair<Integer> edge : edgeList) {
if (cycleDetector.detectCycle(edge.nodeU(), edge.nodeV())) {
continue;
}
spanningTree.putEdgeValue(edge.nodeU(), edge.nodeV(), graph.edgeValue(edge).get());
edgeCount++;
if (edgeCount == totalNodes - 1) {
break;
}
}
return spanningTree;
}
}

View File

@ -0,0 +1,67 @@
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;
import com.baeldung.algorithms.kruskal.Kruskal;
public class KruskalUnitTest {
private MutableValueGraph<Integer, Double> 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<Integer, Double> 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<Integer, Double> 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));
}
}

View File

@ -16,7 +16,7 @@
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>org.baeldung.config</param-value>
<param-value>com.baeldung.config</param-value>
</context-param>
<listener>

View File

@ -1,4 +1,4 @@
package org.baeldung.java;
package com.baeldung.java;
import java.io.BufferedOutputStream;
import java.io.File;

View File

@ -1,4 +1,4 @@
package org.baeldung.java;
package com.baeldung.java;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;

View File

@ -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">
<modelVersion>4.0.0</modelVersion>
<groupId>org.baeldung.examples.olingo2</groupId>
<groupId>com.baeldung.examples.olingo2</groupId>
<artifactId>olingo2</artifactId>
<name>olingo2</name>
<description>Sample Olingo 2 Project</description>

View File

@ -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));

View File

@ -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;

View File

@ -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

View File

@ -1,4 +1,4 @@
package org.baeldung.examples.olingo2.domain;
package com.baeldung.examples.olingo2.domain;
import java.util.List;

View File

@ -1,4 +1,4 @@
package org.baeldung.examples.olingo2.domain;
package com.baeldung.examples.olingo2.domain;
import javax.persistence.Entity;
import javax.persistence.FetchType;

View File

@ -1,4 +1,4 @@
package org.baeldung.examples.olingo2;
package com.baeldung.examples.olingo2;
import org.junit.Test;
import org.junit.runner.RunWith;

View File

@ -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<String> 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<String> storage) {
try {
api.addIDsToStorage(capacity, storage);
} catch (Throwable throwable) {
// do something here
}
}
}

View File

@ -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)

View File

@ -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)

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-kotlin-lang-2</artifactId>
<name>core-kotlin-lang-2</name>
<packaging>jar</packaging>
<parent>
<groupId>com.baeldung.core-kotlin-modules</groupId>
<artifactId>core-kotlin-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
</project>

View File

@ -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;

View File

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

View File

@ -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

View File

@ -1,4 +1,4 @@
package com.baeldung.kotlin.constant
package com.baeldung.constant
class TestKotlinConstantClass {

View File

@ -1,4 +1,4 @@
package com.baeldung.kotlin.constant
package com.baeldung.constant
object TestKotlinConstantObject {

View File

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

View File

@ -6,6 +6,7 @@ import org.junit.jupiter.api.Test
import kotlin.test.assertEquals
class LambdaTest {
@Test
fun whenCallingALambda_thenPerformTheAction() {
assertEquals(9, inferredType(3))

View File

@ -1,4 +1,4 @@
package com.baeldung.kotlin
package com.baeldung.lazy
import org.junit.Test
import java.util.concurrent.CountDownLatch

View File

@ -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

View File

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

View File

@ -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)

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>core-kotlin-lang</artifactId>
<name>core-kotlin-lang</name>
<packaging>jar</packaging>
<parent>
<groupId>com.baeldung.core-kotlin-modules</groupId>
<artifactId>core-kotlin-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
</project>

View File

@ -1,7 +1,5 @@
package com.baeldung.destructuringdeclarations
import com.baeldung.destructuringdeclarations.Person
fun main(args: Array<String>) {
//2.1. Objects

View File

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

View File

@ -1,4 +1,4 @@
package com.baeldung.functions
package com.baeldung.inline
import kotlin.random.Random

View File

@ -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<CustomColor> {
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<CustomColor> {
}
}
class ColorRange(override val start: CustomColor,
override val endInclusive: CustomColor) : ClosedRange<CustomColor>, Iterable<CustomColor>{
override val endInclusive: CustomColor) : ClosedRange<CustomColor>, Iterable<CustomColor>{
override fun iterator(): Iterator<CustomColor> {
return ColorIterator(start, endInclusive)

View File

@ -1,4 +1,4 @@
package com.baeldung.kotlin
package com.baeldung.whenblock
enum class UnixFileType {
D, HYPHEN_MINUS, L

View File

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

View File

@ -1,4 +1,4 @@
package com.baeldung.range
package com.baeldung.rangeiterator
import org.junit.Test
import java.lang.IllegalStateException

View File

@ -1,4 +1,4 @@
package com.baeldung.kotlin
package com.baeldung.trywithresource
import org.junit.Test
import java.beans.ExceptionListener

View File

@ -1,4 +1,4 @@
package com.baeldung.kotlin
package com.baeldung.whenblock
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue

View File

@ -17,6 +17,8 @@
<modules>
<module>core-kotlin-annotations</module>
<module>core-kotlin-io</module>
<module>core-kotlin-lang</module>
<module>core-kotlin-lang-2</module>
<module>core-kotlin-strings</module>
</modules>

View File

@ -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)

View File

@ -2,7 +2,7 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.baeldung.pmd</groupId>
<groupId>com.baeldung.pmd</groupId>
<artifactId>custom-pmd</artifactId>
<version>0.0.1</version>
<name>custom-pmd</name>

View File

@ -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;

View File

@ -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;

View File

@ -1,4 +1,4 @@
package org.baeldung.grpc.server;
package com.baeldung.grpc.server;
import java.io.IOException;

View File

@ -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;

View File

@ -1,6 +1,6 @@
syntax = "proto3";
option java_multiple_files = true;
package org.baeldung.grpc;
package com.baeldung.grpc;
message HelloRequest {
string firstName = 1;

View File

@ -1,4 +1,4 @@
package org.baeldung.guava;
package com.baeldung.guava;
import com.google.common.base.Function;

View File

@ -1,4 +1,4 @@
package org.baeldung.guava;
package com.baeldung.guava;
import com.google.common.base.Function;
import org.junit.Test;

View File

@ -1,4 +1,4 @@
package org.baeldung.guava;
package com.baeldung.guava;
import com.google.common.collect.HashMultiset;
import com.google.common.collect.Multiset;

View File

@ -1,4 +1,4 @@
package org.baeldung.guava;
package com.baeldung.guava;
import com.google.common.collect.ImmutableRangeSet;
import com.google.common.collect.Range;

View File

@ -1,4 +1,4 @@
package org.baeldung.guava;
package com.baeldung.guava;
import com.google.common.base.Function;
import com.google.common.base.Joiner;

View File

@ -1,4 +1,4 @@
package org.baeldung.guava;
package com.baeldung.guava;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;

View File

@ -1,4 +1,4 @@
package org.baeldung.guava;
package com.baeldung.guava;
import static org.hamcrest.Matchers.contains;
import static org.junit.Assert.assertEquals;

View File

@ -1,4 +1,4 @@
package org.baeldung.java.io.remote;
package com.baeldung.java.io.remote;
import java.io.IOException;

View File

@ -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");
}
}

View File

@ -97,8 +97,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
<source>${source.version}</source>
<target>${target.version}</target>
</configuration>
</plugin>
</plugins>
@ -121,8 +121,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
<source>${source.version}</source>
<target>${target.version}</target>
</configuration>
</plugin>
<plugin>
@ -156,8 +156,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>${source.version}</source>
<target>${target.version}</target>
</configuration>
</plugin>
</plugins>
@ -168,6 +168,8 @@
<properties>
<javers.version>5.6.3</javers.version>
<git-commit-id-plugin.version>2.2.4</git-commit-id-plugin.version>
<source.version>1.8</source.version>
<target.version>1.8</target.version>
</properties>
</project>

View File

@ -20,7 +20,7 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
<version>2.1.1.RELEASE</version>
<version>${spring-boot.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
@ -38,6 +38,7 @@
<properties>
<java.version>1.8</java.version>
<spring-boot.version>2.1.1.RELEASE</spring-boot.version>
<junit.version>4.11</junit.version>
</properties>

View File

@ -52,7 +52,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<version>${apache-maven.version}</version>
<configuration>
<delimiters>
<delimiter>@</delimiter>
@ -63,7 +63,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<version>${exec-maven-plugin.version}</version>
<configuration>
<mainClass>com.baeldung.propertyexpansion.SpringBootPropertyExpansionApp</mainClass>
</configuration>
@ -74,6 +74,8 @@
<properties>
<spring-boot.version>1.5.10.RELEASE</spring-boot.version>
<custom.property>Custom Property Value</custom.property>
<apache-maven.version>2.7</apache-maven.version>
<exec-maven-plugin.version>1.6.0</exec-maven-plugin.version>
</properties>
</project>

View File

@ -42,7 +42,7 @@
<dependency>
<groupId>it.ozimov</groupId>
<artifactId>embedded-redis</artifactId>
<version>0.7.2</version>
<version>${redis.version}</version>
<scope>test</scope>
</dependency>
<!-- Spock & Spring -->
@ -131,6 +131,7 @@
<git-commit-id-plugin.version>2.2.4</git-commit-id-plugin.version>
<spock.version>1.2-groovy-2.4</spock.version>
<gmavenplus-plugin.version>1.6</gmavenplus-plugin.version>
<redis.version>0.7.2</redis.version>
</properties>
</project>

View File

@ -50,7 +50,7 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-aws</artifactId>
<version>2.0.1.RELEASE</version>
<version>${spring-cloud}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
@ -60,6 +60,7 @@
<properties>
<start-class>com.baeldung.spring.cloud.aws.SpringCloudAwsApplication</start-class>
<spring-cloud.version>Dalston.SR4</spring-cloud.version>
<spring-cloud>2.0.1.RELEASE</spring-cloud>
</properties>
</project>

View File

@ -36,7 +36,7 @@
<plugin>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-contract-maven-plugin</artifactId>
<version>2.1.1.RELEASE</version>
<version>${spring-cloud.version}</version>
<extensions>true</extensions>
<configuration>
<baseClassForTests>com.baeldung.spring.cloud.springcloudcontractproducer.BaseTestClass
@ -45,4 +45,8 @@
</plugin>
</plugins>
</build>
<properties>
<spring-cloud.version>2.1.1.RELEASE</spring-cloud.version>
</properties>
</project>

View File

@ -65,7 +65,7 @@
<dependency>
<groupId>org.springframework.boot.experimental</groupId>
<artifactId>spring-boot-thin-layout</artifactId>
<version>1.0.10.RELEASE</version>
<version>${spring-boot-thin.version}</version>
</dependency>
</dependencies>
</plugin>
@ -88,6 +88,7 @@
<aws-lambda-events.version>2.0.2</aws-lambda-events.version>
<aws-lambda-java-core.version>1.1.0</aws-lambda-java-core.version>
<spring-boot.version>2.0.4.RELEASE</spring-boot.version>
<spring-boot-thin.version>1.0.10.RELEASE</spring-boot-thin.version>
</properties>
</project>

View File

@ -24,7 +24,7 @@
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
<version>${logback.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
@ -71,6 +71,7 @@
<properties>
<spring-cloud-dependencies.version>Finchley.SR2</spring-cloud-dependencies.version>
<logback.version>1.2.3</logback.version>
</properties>
</project>

View File

@ -174,7 +174,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.2</version>
<version>${maven.version}</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
@ -214,6 +214,7 @@
<assertj.version>3.6.1</assertj.version>
<shedlock.version>2.1.0</shedlock.version>
<javassist.version>3.22.0-GA</javassist.version>
<maven.version>3.2.2</maven.version>
</properties>
</project>

View File

@ -72,8 +72,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>${maven.source}</source>
<target>${maven.target}</target>
<compilerArgs>
<arg>-verbose</arg>
<arg>-parameters</arg>
@ -83,7 +83,7 @@
<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>apt-maven-plugin</artifactId>
<version>1.1.3</version>
<version>${mysema.version}</version>
<executions>
<execution>
<phase>generate-sources</phase>
@ -99,5 +99,10 @@
</plugin>
</plugins>
</build>
<properties>
<maven.source>1.8</maven.source>
<maven.target>1.8</maven.target>
<mysema.version>1.1.3</mysema.version>
</properties>
</project>

View File

@ -66,7 +66,7 @@
<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>maven-apt-plugin</artifactId>
<version>1.0</version>
<version>${maven.version}</version>
<executions>
<execution>
<phase>generate-sources</phase>
@ -90,6 +90,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<start-class>com.baeldung.books.SpringDataRestApplication</start-class>
<maven.version>1.0</maven.version>
</properties>
</project>

Some files were not shown because too many files have changed in this diff Show More