Merge remote-tracking branch 'upstream/master'
Conflicts: software-security/sql-injection-samples/pom.xml
This commit is contained in:
		
						commit
						6f140cf7c2
					
				| @ -14,18 +14,19 @@ | ||||
|     <dependencies> | ||||
|         <dependency> | ||||
|             <groupId>com.typesafe.akka</groupId> | ||||
|             <artifactId>akka-stream_2.11</artifactId> | ||||
|             <artifactId>akka-stream_${scala.version}</artifactId> | ||||
|             <version>${akkastreams.version}</version> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>com.typesafe.akka</groupId> | ||||
|             <artifactId>akka-stream-testkit_2.11</artifactId> | ||||
|             <artifactId>akka-stream-testkit_${scala.version}</artifactId> | ||||
|             <version>${akkastreams.version}</version> | ||||
|         </dependency> | ||||
|     </dependencies> | ||||
| 
 | ||||
|     <properties> | ||||
|         <akkastreams.version>2.5.2</akkastreams.version> | ||||
|         <scala.version>2.11</scala.version> | ||||
|     </properties> | ||||
| 
 | ||||
| </project> | ||||
| @ -1,42 +1,42 @@ | ||||
| package com.baeldung.algorithms.reversingtree; | ||||
| 
 | ||||
| public class TreeNode { | ||||
| 
 | ||||
|     private int value; | ||||
|     private TreeNode rightChild; | ||||
|     private TreeNode leftChild; | ||||
| 
 | ||||
|     public int getValue() { | ||||
|         return value; | ||||
|     } | ||||
| 
 | ||||
|     public void setValue(int value) { | ||||
|         this.value = value; | ||||
|     } | ||||
| 
 | ||||
|     public TreeNode getRightChild() { | ||||
|         return rightChild; | ||||
|     } | ||||
| 
 | ||||
|     public void setRightChild(TreeNode rightChild) { | ||||
|         this.rightChild = rightChild; | ||||
|     } | ||||
| 
 | ||||
|     public TreeNode getLeftChild() { | ||||
|         return leftChild; | ||||
|     } | ||||
| 
 | ||||
|     public void setLeftChild(TreeNode leftChild) { | ||||
|         this.leftChild = leftChild; | ||||
|     } | ||||
| 
 | ||||
|     public TreeNode(int value, TreeNode rightChild, TreeNode leftChild) { | ||||
|         this.value = value; | ||||
|         this.rightChild = rightChild; | ||||
|         this.leftChild = leftChild; | ||||
|     } | ||||
| 
 | ||||
|     public TreeNode(int value) { | ||||
|         this.value = value; | ||||
|     } | ||||
| } | ||||
| package com.baeldung.algorithms.reversingtree; | ||||
| 
 | ||||
| public class TreeNode { | ||||
| 
 | ||||
|     private int value; | ||||
|     private TreeNode rightChild; | ||||
|     private TreeNode leftChild; | ||||
| 
 | ||||
|     public int getValue() { | ||||
|         return value; | ||||
|     } | ||||
| 
 | ||||
|     public void setValue(int value) { | ||||
|         this.value = value; | ||||
|     } | ||||
| 
 | ||||
|     public TreeNode getRightChild() { | ||||
|         return rightChild; | ||||
|     } | ||||
| 
 | ||||
|     public void setRightChild(TreeNode rightChild) { | ||||
|         this.rightChild = rightChild; | ||||
|     } | ||||
| 
 | ||||
|     public TreeNode getLeftChild() { | ||||
|         return leftChild; | ||||
|     } | ||||
| 
 | ||||
|     public void setLeftChild(TreeNode leftChild) { | ||||
|         this.leftChild = leftChild; | ||||
|     } | ||||
| 
 | ||||
|     public TreeNode(int value, TreeNode leftChild, TreeNode rightChild) { | ||||
|         this.value = value; | ||||
|         this.rightChild = rightChild; | ||||
|         this.leftChild = leftChild; | ||||
|     } | ||||
| 
 | ||||
|     public TreeNode(int value) { | ||||
|         this.value = value; | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -1,68 +1,53 @@ | ||||
| package com.baeldung.algorithms.reversingtree; | ||||
| 
 | ||||
| import java.util.LinkedList; | ||||
| 
 | ||||
| public class TreeReverser { | ||||
| 
 | ||||
|     public TreeNode createBinaryTree() { | ||||
| 
 | ||||
|         TreeNode leaf1 = new TreeNode(3); | ||||
|         TreeNode leaf2 = new TreeNode(1); | ||||
|         TreeNode leaf3 = new TreeNode(9); | ||||
|         TreeNode leaf4 = new TreeNode(6); | ||||
| 
 | ||||
|         TreeNode nodeLeft = new TreeNode(2, leaf1, leaf2); | ||||
|         TreeNode nodeRight = new TreeNode(7, leaf3, leaf4); | ||||
| 
 | ||||
|         TreeNode root = new TreeNode(4, nodeRight, nodeLeft); | ||||
| 
 | ||||
|         return root; | ||||
|     } | ||||
| 
 | ||||
|     public void reverseRecursive(TreeNode treeNode) { | ||||
|         if (treeNode == null) { | ||||
|             return; | ||||
|         } | ||||
| 
 | ||||
|         TreeNode temp = treeNode.getLeftChild(); | ||||
|         treeNode.setLeftChild(treeNode.getRightChild()); | ||||
|         treeNode.setRightChild(temp); | ||||
| 
 | ||||
|         reverseRecursive(treeNode.getLeftChild()); | ||||
|         reverseRecursive(treeNode.getRightChild()); | ||||
|     } | ||||
| 
 | ||||
|     public void reverseIterative(TreeNode treeNode) { | ||||
|         LinkedList<TreeNode> queue = new LinkedList<TreeNode>(); | ||||
| 
 | ||||
|         if (treeNode != null) { | ||||
|             queue.add(treeNode); | ||||
|         } | ||||
| 
 | ||||
|         while (!queue.isEmpty()) { | ||||
| 
 | ||||
|             TreeNode node = queue.poll(); | ||||
|             if (node.getLeftChild() != null) | ||||
|                 queue.add(node.getLeftChild()); | ||||
|             if (node.getRightChild() != null) | ||||
|                 queue.add(node.getRightChild()); | ||||
| 
 | ||||
|             TreeNode temp = node.getLeftChild(); | ||||
|             node.setLeftChild(node.getRightChild()); | ||||
|             node.setRightChild(temp); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public String toString(TreeNode root) { | ||||
|         if (root == null) { | ||||
|             return ""; | ||||
|         } | ||||
| 
 | ||||
|         StringBuffer buffer = new StringBuffer(String.valueOf(root.getValue())).append(" "); | ||||
| 
 | ||||
|         buffer.append(toString(root.getLeftChild())); | ||||
|         buffer.append(toString(root.getRightChild())); | ||||
| 
 | ||||
|         return buffer.toString(); | ||||
|     } | ||||
| } | ||||
| package com.baeldung.algorithms.reversingtree; | ||||
| 
 | ||||
| import java.util.LinkedList; | ||||
| 
 | ||||
| public class TreeReverser { | ||||
| 
 | ||||
|     public void reverseRecursive(TreeNode treeNode) { | ||||
|         if (treeNode == null) { | ||||
|             return; | ||||
|         } | ||||
| 
 | ||||
|         TreeNode temp = treeNode.getLeftChild(); | ||||
|         treeNode.setLeftChild(treeNode.getRightChild()); | ||||
|         treeNode.setRightChild(temp); | ||||
| 
 | ||||
|         reverseRecursive(treeNode.getLeftChild()); | ||||
|         reverseRecursive(treeNode.getRightChild()); | ||||
|     } | ||||
| 
 | ||||
|     public void reverseIterative(TreeNode treeNode) { | ||||
|         LinkedList<TreeNode> queue = new LinkedList<TreeNode>(); | ||||
| 
 | ||||
|         if (treeNode != null) { | ||||
|             queue.add(treeNode); | ||||
|         } | ||||
| 
 | ||||
|         while (!queue.isEmpty()) { | ||||
| 
 | ||||
|             TreeNode node = queue.poll(); | ||||
|             if (node.getLeftChild() != null) | ||||
|                 queue.add(node.getLeftChild()); | ||||
|             if (node.getRightChild() != null) | ||||
|                 queue.add(node.getRightChild()); | ||||
| 
 | ||||
|             TreeNode temp = node.getLeftChild(); | ||||
|             node.setLeftChild(node.getRightChild()); | ||||
|             node.setRightChild(temp); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public String toString(TreeNode root) { | ||||
|         if (root == null) { | ||||
|             return ""; | ||||
|         } | ||||
| 
 | ||||
|         StringBuffer buffer = new StringBuffer(String.valueOf(root.getValue())).append(" "); | ||||
| 
 | ||||
|         buffer.append(toString(root.getLeftChild())); | ||||
|         buffer.append(toString(root.getRightChild())); | ||||
| 
 | ||||
|         return buffer.toString(); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -1,33 +1,47 @@ | ||||
| package com.baeldung.algorithms.reversingtree; | ||||
| 
 | ||||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||||
| 
 | ||||
| import org.junit.jupiter.api.Test; | ||||
| 
 | ||||
| public class TreeReverserUnitTest { | ||||
| 
 | ||||
|     @Test | ||||
|     public void givenTreeWhenReversingRecursivelyThenReversed() { | ||||
|         TreeReverser reverser = new TreeReverser(); | ||||
| 
 | ||||
|         TreeNode treeNode = reverser.createBinaryTree(); | ||||
| 
 | ||||
|         reverser.reverseRecursive(treeNode); | ||||
| 
 | ||||
|         assertEquals("4 7 9 6 2 3 1", reverser.toString(treeNode) | ||||
|             .trim()); | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     public void givenTreeWhenReversingIterativelyThenReversed() { | ||||
|         TreeReverser reverser = new TreeReverser(); | ||||
| 
 | ||||
|         TreeNode treeNode = reverser.createBinaryTree(); | ||||
| 
 | ||||
|         reverser.reverseIterative(treeNode); | ||||
| 
 | ||||
|         assertEquals("4 7 9 6 2 3 1", reverser.toString(treeNode) | ||||
|             .trim()); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| package com.baeldung.algorithms.reversingtree; | ||||
| 
 | ||||
| import static org.junit.jupiter.api.Assertions.assertEquals; | ||||
| 
 | ||||
| import org.junit.jupiter.api.Test; | ||||
| 
 | ||||
| public class TreeReverserUnitTest { | ||||
| 
 | ||||
|     @Test | ||||
|     public void givenTreeWhenReversingRecursivelyThenReversed() { | ||||
|         TreeReverser reverser = new TreeReverser(); | ||||
| 
 | ||||
|         TreeNode treeNode = createBinaryTree(); | ||||
| 
 | ||||
|         reverser.reverseRecursive(treeNode); | ||||
| 
 | ||||
|         assertEquals("4 7 9 6 2 3 1", reverser.toString(treeNode) | ||||
|             .trim()); | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     public void givenTreeWhenReversingIterativelyThenReversed() { | ||||
|         TreeReverser reverser = new TreeReverser(); | ||||
| 
 | ||||
|         TreeNode treeNode = createBinaryTree(); | ||||
| 
 | ||||
|         reverser.reverseIterative(treeNode); | ||||
| 
 | ||||
|         assertEquals("4 7 9 6 2 3 1", reverser.toString(treeNode) | ||||
|             .trim()); | ||||
|     } | ||||
| 
 | ||||
|     private TreeNode createBinaryTree() { | ||||
| 
 | ||||
|         TreeNode leaf1 = new TreeNode(1); | ||||
|         TreeNode leaf2 = new TreeNode(3); | ||||
|         TreeNode leaf3 = new TreeNode(6); | ||||
|         TreeNode leaf4 = new TreeNode(9); | ||||
| 
 | ||||
|         TreeNode nodeRight = new TreeNode(7, leaf3, leaf4); | ||||
|         TreeNode nodeLeft = new TreeNode(2, leaf1, leaf2); | ||||
| 
 | ||||
|         TreeNode root = new TreeNode(4, nodeLeft, nodeRight); | ||||
| 
 | ||||
|         return root; | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -10,6 +10,14 @@ | ||||
|         <version>1.0.0-SNAPSHOT</version> | ||||
|     </parent> | ||||
| 
 | ||||
|     <dependencies> | ||||
|         <dependency> | ||||
|             <groupId>org.antlr</groupId> | ||||
|             <artifactId>antlr4-runtime</artifactId> | ||||
|             <version>${antlr.version}</version> | ||||
|         </dependency> | ||||
|     </dependencies> | ||||
| 
 | ||||
|     <build> | ||||
|         <plugins> | ||||
|             <plugin> | ||||
| @ -44,13 +52,7 @@ | ||||
|             </plugin> | ||||
|         </plugins> | ||||
|     </build> | ||||
|     <dependencies> | ||||
|         <dependency> | ||||
|             <groupId>org.antlr</groupId> | ||||
|             <artifactId>antlr4-runtime</artifactId> | ||||
|             <version>${antlr.version}</version> | ||||
|         </dependency> | ||||
|     </dependencies> | ||||
|     	 | ||||
|     <properties> | ||||
|         <antlr.version>4.7.1</antlr.version> | ||||
|         <mojo.version>3.0.0</mojo.version> | ||||
|  | ||||
| @ -12,9 +12,18 @@ | ||||
|         <version>0.0.1-SNAPSHOT</version> | ||||
|     </parent> | ||||
| 
 | ||||
|     <properties> | ||||
|         <cxf-version>3.2.0</cxf-version> | ||||
|     </properties> | ||||
|     <dependencies> | ||||
|         <dependency> | ||||
|             <groupId>org.apache.cxf</groupId> | ||||
|             <artifactId>cxf-rt-rs-client</artifactId> | ||||
|             <version>${cxf-version}</version> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>org.apache.cxf</groupId> | ||||
|             <artifactId>cxf-rt-rs-sse</artifactId> | ||||
|             <version>${cxf-version}</version> | ||||
|         </dependency> | ||||
|     </dependencies> | ||||
| 
 | ||||
|     <build> | ||||
|         <plugins> | ||||
| @ -45,17 +54,8 @@ | ||||
|         </plugins> | ||||
|     </build> | ||||
| 
 | ||||
|     <dependencies> | ||||
|         <dependency> | ||||
|             <groupId>org.apache.cxf</groupId> | ||||
|             <artifactId>cxf-rt-rs-client</artifactId> | ||||
|             <version>${cxf-version}</version> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>org.apache.cxf</groupId> | ||||
|             <artifactId>cxf-rt-rs-sse</artifactId> | ||||
|             <version>${cxf-version}</version> | ||||
|         </dependency> | ||||
|     </dependencies> | ||||
|     <properties> | ||||
|         <cxf-version>3.2.0</cxf-version> | ||||
|     </properties> | ||||
| 
 | ||||
| </project> | ||||
|  | ||||
| @ -13,11 +13,28 @@ | ||||
|         <version>0.0.1-SNAPSHOT</version> | ||||
|     </parent> | ||||
| 
 | ||||
|     <properties> | ||||
|         <liberty-maven-plugin.version>2.4.2</liberty-maven-plugin.version> | ||||
|         <failOnMissingWebXml>false</failOnMissingWebXml> | ||||
|         <openliberty-version>18.0.0.2</openliberty-version> | ||||
|     </properties> | ||||
|     <dependencies> | ||||
| 
 | ||||
|         <dependency> | ||||
|             <groupId>javax.ws.rs</groupId> | ||||
|             <artifactId>javax.ws.rs-api</artifactId> | ||||
|             <version>2.1</version> | ||||
|             <scope>provided</scope> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>javax.enterprise</groupId> | ||||
|             <artifactId>cdi-api</artifactId> | ||||
|             <version>2.0</version> | ||||
|             <scope>provided</scope> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>javax.json.bind</groupId> | ||||
|             <artifactId>javax.json.bind-api</artifactId> | ||||
|             <version>1.0</version> | ||||
|             <scope>provided</scope> | ||||
|         </dependency> | ||||
| 
 | ||||
|     </dependencies> | ||||
| 
 | ||||
|     <build> | ||||
|         <finalName>${project.artifactId}</finalName> | ||||
| @ -59,27 +76,10 @@ | ||||
|         </plugins> | ||||
|     </build> | ||||
| 
 | ||||
|     <dependencies> | ||||
| 
 | ||||
|         <dependency> | ||||
|             <groupId>javax.ws.rs</groupId> | ||||
|             <artifactId>javax.ws.rs-api</artifactId> | ||||
|             <version>2.1</version> | ||||
|             <scope>provided</scope> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>javax.enterprise</groupId> | ||||
|             <artifactId>cdi-api</artifactId> | ||||
|             <version>2.0</version> | ||||
|             <scope>provided</scope> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>javax.json.bind</groupId> | ||||
|             <artifactId>javax.json.bind-api</artifactId> | ||||
|             <version>1.0</version> | ||||
|             <scope>provided</scope> | ||||
|         </dependency> | ||||
| 
 | ||||
|     </dependencies> | ||||
|     <properties> | ||||
|         <liberty-maven-plugin.version>2.4.2</liberty-maven-plugin.version> | ||||
|         <failOnMissingWebXml>false</failOnMissingWebXml> | ||||
|         <openliberty-version>18.0.0.2</openliberty-version> | ||||
|     </properties> | ||||
| 
 | ||||
| </project> | ||||
|  | ||||
| @ -6,6 +6,12 @@ | ||||
|     <version>0.0.1</version> | ||||
|     <name>apache-meecrowave</name> | ||||
|     <description>A sample REST API application with Meecrowave</description> | ||||
|      | ||||
|     <parent> | ||||
|         <groupId>com.baeldung</groupId> | ||||
|         <artifactId>parent-modules</artifactId> | ||||
|         <version>1.0.0-SNAPSHOT</version> | ||||
|     </parent> | ||||
| 
 | ||||
|     <dependencies> | ||||
|         <!-- https://mvnrepository.com/artifact/org.apache.meecrowave/meecrowave-core --> | ||||
|  | ||||
| @ -17,7 +17,7 @@ import okhttp3.Request; | ||||
| import okhttp3.Response; | ||||
| 
 | ||||
| @RunWith(MonoMeecrowave.Runner.class) | ||||
| public class ArticleEndpointsTest { | ||||
| public class ArticleEndpointsUnitTest { | ||||
|      | ||||
|     @ConfigurationInject | ||||
|     private Meecrowave.Builder config; | ||||
| @ -1,4 +1,4 @@ | ||||
| ### Relevant Articles: | ||||
| 
 | ||||
| - [Deploy Spring Boot App to Azure](http://www.baeldung.com/spring-boot-azure) | ||||
| - [Deploy a Spring Boot App to Azure](http://www.baeldung.com/spring-boot-azure) | ||||
| 
 | ||||
|  | ||||
| @ -1,5 +1,5 @@ | ||||
| ### Relevant Articles:  | ||||
| 
 | ||||
| - [Blade - A Complete GuideBook](http://www.baeldung.com/blade)  | ||||
| - [Blade – A Complete Guidebook](http://www.baeldung.com/blade)  | ||||
| 
 | ||||
| Run Integration Tests with `mvn integration-test` | ||||
| Run Integration Tests with `mvn integration-test` | ||||
|  | ||||
| @ -2,24 +2,20 @@ | ||||
| <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> | ||||
|     <parent> | ||||
|         <groupId>org.springframework.boot</groupId> | ||||
|         <artifactId>spring-boot-starter-parent</artifactId> | ||||
|         <version>2.1.3.RELEASE</version> | ||||
|         <relativePath/> <!-- lookup parent from repository --> | ||||
|     </parent> | ||||
|     <groupId>com.example</groupId> | ||||
|     <artifactId>cf-uaa-oauth2-client</artifactId> | ||||
|     <version>0.0.1-SNAPSHOT</version> | ||||
|     <name>uaa-client-webapp</name> | ||||
|     <description>Demo project for Spring Boot</description> | ||||
| 
 | ||||
|     <properties> | ||||
|         <java.version>1.8</java.version> | ||||
|     </properties> | ||||
|     <parent> | ||||
|         <artifactId>parent-boot-2</artifactId> | ||||
|         <groupId>com.baeldung</groupId> | ||||
|         <version>0.0.1-SNAPSHOT</version> | ||||
|         <relativePath>../../parent-boot-2</relativePath> | ||||
|     </parent> | ||||
| 
 | ||||
|     <dependencies> | ||||
| 
 | ||||
|         <dependency> | ||||
|             <groupId>org.springframework.boot</groupId> | ||||
|             <artifactId>spring-boot-starter-web</artifactId> | ||||
| @ -28,7 +24,6 @@ | ||||
|             <groupId>org.springframework.boot</groupId> | ||||
|             <artifactId>spring-boot-starter-oauth2-client</artifactId> | ||||
|         </dependency> | ||||
| 
 | ||||
|     </dependencies> | ||||
| 
 | ||||
|     <build> | ||||
| @ -40,4 +35,7 @@ | ||||
|         </plugins> | ||||
|     </build> | ||||
| 
 | ||||
|     <properties> | ||||
|         <java.version>1.8</java.version> | ||||
|     </properties> | ||||
| </project> | ||||
|  | ||||
| @ -2,24 +2,20 @@ | ||||
| <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> | ||||
|     <parent> | ||||
|         <groupId>org.springframework.boot</groupId> | ||||
|         <artifactId>spring-boot-starter-parent</artifactId> | ||||
|         <version>2.1.3.RELEASE</version> | ||||
|         <relativePath/> <!-- lookup parent from repository --> | ||||
|     </parent> | ||||
|     <groupId>com.baeldung.cfuaa</groupId> | ||||
|     <artifactId>cf-uaa-oauth2-resource-server</artifactId> | ||||
|     <version>0.0.1-SNAPSHOT</version> | ||||
|     <name>cf-uaa-oauth2-resource-server</name> | ||||
|     <description>Demo project for Spring Boot</description> | ||||
| 
 | ||||
|     <properties> | ||||
|         <java.version>1.8</java.version> | ||||
|     </properties> | ||||
| 
 | ||||
|     <parent> | ||||
|         <artifactId>parent-boot-2</artifactId> | ||||
|         <groupId>com.baeldung</groupId> | ||||
|         <version>0.0.1-SNAPSHOT</version> | ||||
|         <relativePath>../../parent-boot-2</relativePath> | ||||
|     </parent> | ||||
| 	 | ||||
|     <dependencies> | ||||
| 
 | ||||
|         <dependency> | ||||
|             <groupId>org.springframework.boot</groupId> | ||||
|             <artifactId>spring-boot-starter-oauth2-resource-server</artifactId> | ||||
| @ -28,7 +24,6 @@ | ||||
|             <groupId>org.springframework.boot</groupId> | ||||
|             <artifactId>spring-boot-starter-web</artifactId> | ||||
|         </dependency> | ||||
| 
 | ||||
|     </dependencies> | ||||
| 
 | ||||
|     <build> | ||||
| @ -40,4 +35,8 @@ | ||||
|         </plugins> | ||||
|     </build> | ||||
| 
 | ||||
|     <properties> | ||||
|         <java.version>1.8</java.version> | ||||
|     </properties> | ||||
| 
 | ||||
| </project> | ||||
|  | ||||
| @ -8,6 +8,8 @@ | ||||
| - [Types of Strings in Groovy](https://www.baeldung.com/groovy-strings) | ||||
| - [A Quick Guide to Iterating a Map in Groovy](https://www.baeldung.com/groovy-map-iterating) | ||||
| - [An Introduction to Traits in Groovy](https://www.baeldung.com/groovy-traits) | ||||
| - [Closures in Groovy](https://www.baeldung.com/groovy-closures) | ||||
| - [Finding Elements in Collections in Groovy](https://www.baeldung.com/groovy-collections-find-elements) | ||||
| - [Lists in Groovy](https://www.baeldung.com/groovy-lists) | ||||
| - [Converting a String to a Date in Groovy](https://www.baeldung.com/groovy-string-to-date) | ||||
| - [Guide to I/O in Groovy](https://www.baeldung.com/groovy-io) | ||||
| - [Guide to I/O in Groovy](https://www.baeldung.com/groovy-io) | ||||
| @ -6,3 +6,4 @@ | ||||
| - [Java 11 Nest Based Access Control](https://www.baeldung.com/java-nest-based-access-control) | ||||
| - [Exploring the New HTTP Client in Java 9 and 11](https://www.baeldung.com/java-9-http-client) | ||||
| - [An Introduction to Epsilon GC: A No-Op Experimental Garbage Collector](https://www.baeldung.com/jvm-epsilon-gc-garbage-collector) | ||||
| - [Guide to jlink](https://www.baeldung.com/jlink) | ||||
|  | ||||
| @ -14,6 +14,14 @@ | ||||
|         <version>1.0.0-SNAPSHOT</version> | ||||
|     </parent> | ||||
| 
 | ||||
|     <dependencies> | ||||
|         <dependency> | ||||
|             <groupId>com.google.guava</groupId> | ||||
|             <artifactId>guava</artifactId> | ||||
|             <version>${guava.version}</version> | ||||
|         </dependency> | ||||
|     </dependencies> | ||||
| 
 | ||||
|     <build> | ||||
|         <plugins> | ||||
|             <plugin> | ||||
| @ -31,6 +39,7 @@ | ||||
|     <properties> | ||||
|         <maven.compiler.source.version>11</maven.compiler.source.version> | ||||
|         <maven.compiler.target.version>11</maven.compiler.target.version> | ||||
|         <guava.version>27.1-jre</guava.version> | ||||
|     </properties> | ||||
| 
 | ||||
| </project> | ||||
|  | ||||
| @ -0,0 +1,32 @@ | ||||
| package com.baeldung; | ||||
| 
 | ||||
| import com.google.common.base.Strings; | ||||
| import org.junit.Assert; | ||||
| import org.junit.Test; | ||||
| 
 | ||||
| import java.util.Optional; | ||||
| import java.util.function.Predicate; | ||||
| 
 | ||||
| public class EmptyStringToEmptyOptionalUnitTest { | ||||
| 
 | ||||
|     @Test | ||||
|     public void givenEmptyString_whenFilteringOnOptional_thenEmptyOptionalIsReturned() { | ||||
|         String str = ""; | ||||
|         Optional<String> opt = Optional.ofNullable(str).filter(s -> !s.isEmpty()); | ||||
|         Assert.assertFalse(opt.isPresent()); | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     public void givenEmptyString_whenFilteringOnOptionalInJava11_thenEmptyOptionalIsReturned() { | ||||
|         String str = ""; | ||||
|         Optional<String> opt = Optional.ofNullable(str).filter(Predicate.not(String::isEmpty)); | ||||
|         Assert.assertFalse(opt.isPresent()); | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     public void givenEmptyString_whenPassingResultOfEmptyToNullToOfNullable_thenEmptyOptionalIsReturned() { | ||||
|         String str = ""; | ||||
|         Optional<String> opt = Optional.ofNullable(Strings.emptyToNull(str)); | ||||
|         Assert.assertFalse(opt.isPresent()); | ||||
|     } | ||||
| } | ||||
| @ -34,6 +34,7 @@ | ||||
|                 <configuration> | ||||
|                     <source>${maven.compiler.source.version}</source> | ||||
|                     <target>${maven.compiler.target.version}</target> | ||||
|                     <compilerArgs>--enable-preview</compilerArgs> | ||||
|                 </configuration> | ||||
|             </plugin> | ||||
|         </plugins> | ||||
|  | ||||
| @ -0,0 +1,37 @@ | ||||
| package com.baeldung.switchExpression; | ||||
| 
 | ||||
| import org.junit.Assert; | ||||
| import org.junit.Test; | ||||
| 
 | ||||
| public class SwitchUnitTest { | ||||
| 
 | ||||
|     @Test | ||||
|     public void switchJava12(){ | ||||
| 
 | ||||
|         var month = Month.AUG; | ||||
| 
 | ||||
|         var value = switch(month){ | ||||
|             case JAN,JUN, JUL -> 3; | ||||
|             case FEB,SEP, OCT, NOV, DEC -> 1; | ||||
|             case MAR,MAY, APR, AUG -> 2; | ||||
|         }; | ||||
| 
 | ||||
|         Assert.assertEquals(value, 2); | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     public void switchLocalVariable(){ | ||||
|         var month = Month.AUG; | ||||
|         int i = switch (month){ | ||||
|             case JAN,JUN, JUL -> 3; | ||||
|             case FEB,SEP, OCT, NOV, DEC -> 1; | ||||
|             case MAR,MAY, APR, AUG -> { | ||||
|                 int j = month.toString().length() * 4; | ||||
|                 break j; | ||||
|             } | ||||
|         }; | ||||
|         Assert.assertEquals(12, i); | ||||
|     } | ||||
| 
 | ||||
|     enum Month {JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC} | ||||
| } | ||||
							
								
								
									
										6
									
								
								core-java-8-2/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								core-java-8-2/README.md
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,6 @@ | ||||
| ========= | ||||
| 
 | ||||
| ## Core Java 8 Cookbooks and Examples (part 2) | ||||
| 
 | ||||
| ### Relevant Articles:  | ||||
| - [Anonymous Classes in Java](http://www.baeldung.com/) | ||||
							
								
								
									
										43
									
								
								core-java-8-2/pom.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										43
									
								
								core-java-8-2/pom.xml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,43 @@ | ||||
| <?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> | ||||
|     <groupId>com.baeldung</groupId> | ||||
|     <artifactId>core-java-8-2</artifactId> | ||||
|     <version>0.1.0-SNAPSHOT</version> | ||||
|     <name>core-java-8-2</name> | ||||
|     <packaging>jar</packaging> | ||||
| 
 | ||||
| 
 | ||||
|     <parent> | ||||
|         <groupId>com.baeldung</groupId> | ||||
|         <artifactId>parent-java</artifactId> | ||||
|         <version>0.0.1-SNAPSHOT</version> | ||||
|         <relativePath>../parent-java</relativePath> | ||||
|     </parent> | ||||
| 
 | ||||
|     <properties> | ||||
|         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||||
|         <maven.compiler.source>1.8</maven.compiler.source> | ||||
|         <maven.compiler.target>1.8</maven.compiler.target> | ||||
|     </properties> | ||||
| 
 | ||||
|     <dependencies> | ||||
|     </dependencies> | ||||
| 
 | ||||
|     <build> | ||||
|         <plugins> | ||||
|             <plugin> | ||||
|                 <groupId>org.apache.maven.plugins</groupId> | ||||
|                 <artifactId>maven-compiler-plugin</artifactId> | ||||
|                 <version>${maven-compiler-plugin.version}</version> | ||||
|                 <configuration> | ||||
|                     <source>${maven.compiler.source}</source> | ||||
|                     <target>${maven.compiler.target}</target> | ||||
|                 </configuration> | ||||
|             </plugin> | ||||
|         </plugins> | ||||
| 
 | ||||
|     </build> | ||||
| </project> | ||||
							
								
								
									
										15
									
								
								core-java-8-2/src/main/java/com/baeldung/anonymous/Book.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								core-java-8-2/src/main/java/com/baeldung/anonymous/Book.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,15 @@ | ||||
| package com.baeldung.anonymous; | ||||
| 
 | ||||
| public class Book { | ||||
| 
 | ||||
|     final String title; | ||||
|      | ||||
|     public Book(String title) { | ||||
|         this.title = title; | ||||
|     } | ||||
|      | ||||
|     public String description() { | ||||
|         return "Title: " + title; | ||||
|     } | ||||
| 
 | ||||
| } | ||||
							
								
								
									
										64
									
								
								core-java-8-2/src/main/java/com/baeldung/anonymous/Main.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										64
									
								
								core-java-8-2/src/main/java/com/baeldung/anonymous/Main.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,64 @@ | ||||
| package com.baeldung.anonymous; | ||||
| 
 | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| 
 | ||||
| /** | ||||
|  * Code snippet that illustrates the usage of anonymous classes. | ||||
|  *  | ||||
|  * Note that use of Runnable instances in this example does not demonstrate their | ||||
|  * common use. | ||||
|  *  | ||||
|  * @author A. Shcherbakov | ||||
|  * | ||||
|  */ | ||||
| public class Main { | ||||
| 
 | ||||
|     public static void main(String[] args) { | ||||
|         final List<Runnable> actions = new ArrayList<Runnable>(2); | ||||
| 
 | ||||
|         Runnable action = new Runnable() { | ||||
|             @Override | ||||
|             public void run() { | ||||
|                 System.out.println("Hello from runnable."); | ||||
|             } | ||||
| 
 | ||||
|         }; | ||||
|         actions.add(action); | ||||
| 
 | ||||
|         Book book = new Book("Design Patterns") { | ||||
|             @Override | ||||
|             public String description() { | ||||
|                 return "Famous GoF book."; | ||||
|             } | ||||
|         }; | ||||
| 
 | ||||
|         System.out.println(String.format("Title: %s, description: %s", book.title, book.description())); | ||||
| 
 | ||||
|         actions.add(new Runnable() { | ||||
|             @Override | ||||
|             public void run() { | ||||
|                 System.out.println("Hello from runnable #2."); | ||||
| 
 | ||||
|             } | ||||
|         }); | ||||
| 
 | ||||
|         int count = 1; | ||||
| 
 | ||||
|         Runnable action2 = new Runnable() { | ||||
|             static final int x = 0; | ||||
|             // static int y = 0; | ||||
| 
 | ||||
|             @Override | ||||
|             public void run() { | ||||
|                 System.out.println(String.format("Runnable with captured variables: count = %s, x = %s", count, x)); | ||||
|             } | ||||
|         }; | ||||
|         actions.add(action2); | ||||
| 
 | ||||
|         for (Runnable a : actions) { | ||||
|             a.run(); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| } | ||||
							
								
								
									
										18
									
								
								core-java-8-2/src/test/java/com/baeldung/UnitTest.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										18
									
								
								core-java-8-2/src/test/java/com/baeldung/UnitTest.java
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,18 @@ | ||||
| package com.baeldung; | ||||
| 
 | ||||
| import static org.junit.Assert.assertTrue; | ||||
| 
 | ||||
| import org.junit.Test; | ||||
| 
 | ||||
| /** | ||||
|  * Unit test for simple App. | ||||
|  */ | ||||
| public class UnitTest { | ||||
|     /** | ||||
|      * Stub test | ||||
|      */ | ||||
|     @Test | ||||
|     public void givenPreconditions_whenCondition_shouldResult() { | ||||
|         assertTrue(true); | ||||
|     } | ||||
| } | ||||
| @ -3,7 +3,7 @@ | ||||
| ## Core Java 8 Cookbooks and Examples | ||||
| 
 | ||||
| ### Relevant Articles:  | ||||
| - [Java 8 Collectors](http://www.baeldung.com/java-8-collectors) | ||||
| - [Guide to Java 8’s Collectors](http://www.baeldung.com/java-8-collectors) | ||||
| - [Functional Interfaces in Java 8](http://www.baeldung.com/java-8-functional-interfaces) | ||||
| - [Java 8 – Powerful Comparison with Lambdas](http://www.baeldung.com/java-8-sort-lambda) | ||||
| - [New Features in Java 8](http://www.baeldung.com/java-8-new-features) | ||||
|  | ||||
| @ -1,12 +0,0 @@ | ||||
| package com.baeldung; | ||||
| 
 | ||||
| import java.util.function.Consumer; | ||||
| import java.util.function.Function; | ||||
| 
 | ||||
| public interface Adder { | ||||
| 
 | ||||
|     String addWithFunction(Function<String, String> f); | ||||
| 
 | ||||
|     void addWithConsumer(Consumer<Integer> f); | ||||
| 
 | ||||
| } | ||||
| @ -1,18 +0,0 @@ | ||||
| package com.baeldung; | ||||
| 
 | ||||
| 
 | ||||
| import java.util.function.Consumer; | ||||
| import java.util.function.Function; | ||||
| 
 | ||||
| public class AdderImpl implements Adder { | ||||
| 
 | ||||
|     @Override | ||||
|     public String addWithFunction(final Function<String, String> f) { | ||||
|         return f.apply("Something "); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void addWithConsumer(final Consumer<Integer> f) { | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| @ -1,4 +1,4 @@ | ||||
| package com.baeldung; | ||||
| package com.baeldung.java8.lambda.tips; | ||||
| 
 | ||||
| 
 | ||||
| @FunctionalInterface | ||||
| @ -1,4 +1,4 @@ | ||||
| package com.baeldung; | ||||
| package com.baeldung.java8.lambda.tips; | ||||
| 
 | ||||
| 
 | ||||
| @FunctionalInterface | ||||
| @ -1,4 +1,4 @@ | ||||
| package com.baeldung; | ||||
| package com.baeldung.java8.lambda.tips; | ||||
| 
 | ||||
| 
 | ||||
| @FunctionalInterface | ||||
| @ -1,4 +1,4 @@ | ||||
| package com.baeldung; | ||||
| package com.baeldung.java8.lambda.tips; | ||||
| 
 | ||||
| 
 | ||||
| @FunctionalInterface | ||||
| @ -0,0 +1,12 @@ | ||||
| package com.baeldung.java8.lambda.tips; | ||||
| 
 | ||||
| import java.util.concurrent.Callable; | ||||
| import java.util.function.Supplier; | ||||
| 
 | ||||
| public interface Processor { | ||||
| 
 | ||||
|     String processWithCallable(Callable<String> c) throws Exception; | ||||
| 
 | ||||
|     String processWithSupplier(Supplier<String> s); | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,20 @@ | ||||
| package com.baeldung.java8.lambda.tips; | ||||
| 
 | ||||
| 
 | ||||
| import java.util.concurrent.Callable; | ||||
| import java.util.function.Consumer; | ||||
| import java.util.function.Function; | ||||
| import java.util.function.Supplier; | ||||
| 
 | ||||
| public class ProcessorImpl implements Processor { | ||||
| 
 | ||||
|     @Override | ||||
|     public String processWithCallable(Callable<String> c) throws Exception { | ||||
|         return c.call(); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public String processWithSupplier(Supplier<String> s) { | ||||
|         return s.get(); | ||||
|     } | ||||
| } | ||||
| @ -1,4 +1,4 @@ | ||||
| package com.baeldung; | ||||
| package com.baeldung.java8.lambda.tips; | ||||
| 
 | ||||
| 
 | ||||
| import java.util.function.Function; | ||||
| @ -1,8 +1,8 @@ | ||||
| package com.baeldung.java8; | ||||
| package com.baeldung.java8.lambda.tips; | ||||
| 
 | ||||
| import com.baeldung.Foo; | ||||
| import com.baeldung.FooExtended; | ||||
| import com.baeldung.UseFoo; | ||||
| import com.baeldung.java8.lambda.tips.Foo; | ||||
| import com.baeldung.java8.lambda.tips.FooExtended; | ||||
| import com.baeldung.java8.lambda.tips.UseFoo; | ||||
| import org.junit.Before; | ||||
| import org.junit.Test; | ||||
| 
 | ||||
| @ -5,26 +5,21 @@ | ||||
| [Java 9 New Features](http://www.baeldung.com/new-java-9) | ||||
| 
 | ||||
| ### Relevant Articles: | ||||
| - [Java 9 Stream API Improvements](http://www.baeldung.com/java-9-stream-api) | ||||
| - [Java 9 Convenience Factory Methods for Collections](http://www.baeldung.com/java-9-collections-factory-methods)  | ||||
| 
 | ||||
| - [Java 9 New Features](https://www.baeldung.com/new-java-9) | ||||
| - [New Stream Collectors in Java 9](http://www.baeldung.com/java9-stream-collectors) | ||||
| - [Java 9 CompletableFuture API Improvements](http://www.baeldung.com/java-9-completablefuture) | ||||
| - [Introduction to Java 9 StackWalking API](http://www.baeldung.com/java-9-stackwalking-api) | ||||
| - [Introduction to Project Jigsaw](http://www.baeldung.com/project-jigsaw-java-modularity) | ||||
| - [Java 9 Optional API Additions](http://www.baeldung.com/java-9-optional) | ||||
| - [Java 9 Reactive Streams](http://www.baeldung.com/java-9-reactive-streams) | ||||
| - [Java 9 java.util.Objects Additions](http://www.baeldung.com/java-9-objects-new) | ||||
| - [Java 9 Variable Handles Demistyfied](http://www.baeldung.com/java-variable-handles) | ||||
| - [Java 9 Variable Handles Demystified](http://www.baeldung.com/java-variable-handles) | ||||
| - [Exploring the New HTTP Client in Java 9 and 11](http://www.baeldung.com/java-9-http-client) | ||||
| - [Method Handles in Java](http://www.baeldung.com/java-method-handles) | ||||
| - [Introduction to Chronicle Queue](http://www.baeldung.com/java-chronicle-queue) | ||||
| - [A Guide to Java 9 Modularity](http://www.baeldung.com/java-9-modularity) | ||||
| - [Optional orElse Optional](http://www.baeldung.com/java-optional-or-else-optional) | ||||
| - [Java 9 java.lang.Module API](http://www.baeldung.com/java-9-module-api) | ||||
| - [Iterate Through a Range of Dates in Java](https://www.baeldung.com/java-iterate-date-range) | ||||
| - [Initialize a HashMap in Java](https://www.baeldung.com/java-initialize-hashmap) | ||||
| - [Java 9 Platform Logging API](https://www.baeldung.com/java-9-logging-api) | ||||
| - [Immutable Set in Java](https://www.baeldung.com/java-immutable-set) | ||||
| - [Multi-Release Jar Files](https://www.baeldung.com/java-multi-release-jar) | ||||
| - [Ahead of Time Compilation (AoT)](https://www.baeldung.com/ahead-of-time-compilation) | ||||
| - [Java 9 Process API Improvements](https://www.baeldung.com/java-9-process-api) | ||||
| - [Guide to java.lang.Process API](https://www.baeldung.com/java-process-api) | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
							
								
								
									
										6
									
								
								core-java-collections-map/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								core-java-collections-map/README.md
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,6 @@ | ||||
| ========= | ||||
| 
 | ||||
| ## Core Java Collections 2 | ||||
| 
 | ||||
| ### Relevant Articles:  | ||||
| - Java - Copying a HashMap | ||||
							
								
								
									
										78
									
								
								core-java-collections-map/pom.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										78
									
								
								core-java-collections-map/pom.xml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,78 @@ | ||||
| <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-java-collections-map</artifactId> | ||||
|     <version>0.1.0-SNAPSHOT</version> | ||||
|     <name>core-java-collections-map</name> | ||||
|     <packaging>jar</packaging> | ||||
| 
 | ||||
|     <parent> | ||||
|         <groupId>com.baeldung</groupId> | ||||
|         <artifactId>parent-java</artifactId> | ||||
|         <version>0.0.1-SNAPSHOT</version> | ||||
|         <relativePath>../parent-java</relativePath> | ||||
|     </parent> | ||||
| 
 | ||||
|     <dependencies> | ||||
|         <dependency> | ||||
|             <groupId>org.apache.commons</groupId> | ||||
|             <artifactId>commons-collections4</artifactId> | ||||
|             <version>${commons-collections4.version}</version> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>org.apache.commons</groupId> | ||||
|             <artifactId>commons-lang3</artifactId> | ||||
|             <version>${commons-lang3.version}</version> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>org.eclipse.collections</groupId> | ||||
|             <artifactId>eclipse-collections</artifactId> | ||||
|             <version>${eclipse.collections.version}</version> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>org.assertj</groupId> | ||||
|             <artifactId>assertj-core</artifactId> | ||||
|             <version>${assertj.version}</version> | ||||
|             <scope>test</scope> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>org.junit.platform</groupId> | ||||
|             <artifactId>junit-platform-runner</artifactId> | ||||
|             <version>${junit.platform.version}</version> | ||||
|             <scope>test</scope> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>org.openjdk.jmh</groupId> | ||||
|             <artifactId>jmh-core</artifactId> | ||||
|             <version>${openjdk.jmh.version}</version> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>org.openjdk.jmh</groupId> | ||||
|             <artifactId>jmh-generator-annprocess</artifactId> | ||||
|             <version>${openjdk.jmh.version}</version> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>org.apache.commons</groupId> | ||||
|             <artifactId>commons-exec</artifactId> | ||||
|             <version>${commons-exec.version}</version> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>org.projectlombok</groupId> | ||||
|             <artifactId>lombok</artifactId> | ||||
|             <version>${lombok.version}</version> | ||||
|             <scope>provided</scope> | ||||
|         </dependency> | ||||
|     </dependencies> | ||||
| 
 | ||||
|     <properties> | ||||
|         <openjdk.jmh.version>1.19</openjdk.jmh.version> | ||||
|         <junit.platform.version>1.2.0</junit.platform.version> | ||||
|         <commons-lang3.version>3.8.1</commons-lang3.version> | ||||
|         <commons-collections4.version>4.1</commons-collections4.version> | ||||
|         <collections-generic.version>4.01</collections-generic.version> | ||||
|         <avaitility.version>1.7.0</avaitility.version> | ||||
|         <assertj.version>3.11.1</assertj.version> | ||||
|         <eclipse.collections.version>7.1.0</eclipse.collections.version> | ||||
| 		<commons-exec.version>1.3</commons-exec.version> | ||||
|     </properties> | ||||
| </project> | ||||
| @ -0,0 +1,55 @@ | ||||
| package com.baeldung.copyinghashmap; | ||||
| 
 | ||||
| import java.util.HashMap; | ||||
| import java.util.Map; | ||||
| import java.util.Map.Entry; | ||||
| import java.util.Set; | ||||
| import java.util.stream.Collectors; | ||||
| 
 | ||||
| import org.apache.commons.lang3.SerializationUtils; | ||||
| 
 | ||||
| public class CopyHashMap { | ||||
|      | ||||
|     public static <String, Employee> HashMap<String, Employee> copyUsingConstructor(HashMap<String, Employee> originalMap) { | ||||
|         return new HashMap<String, Employee>(originalMap); | ||||
|     } | ||||
|      | ||||
|     public static <String, Employee> HashMap<String, Employee> copyUsingClone(HashMap<String, Employee> originalMap) { | ||||
|         return (HashMap<String, Employee>) originalMap.clone(); | ||||
|     } | ||||
| 
 | ||||
|     public static <String, Employee> HashMap<String, Employee> copyUsingPut(HashMap<String, Employee> originalMap) { | ||||
|         HashMap<String, Employee> shallowCopy = new HashMap<String, Employee>(); | ||||
|         Set<Entry<String, Employee>> entries = originalMap.entrySet(); | ||||
|         for(Map.Entry<String, Employee> mapEntry: entries) { | ||||
|             shallowCopy.put(mapEntry.getKey(), mapEntry.getValue()); | ||||
|         } | ||||
|          | ||||
|         return shallowCopy; | ||||
|     } | ||||
|      | ||||
|     public static <String, Employee> HashMap<String, Employee> copyUsingPutAll(HashMap<String, Employee> originalMap) { | ||||
|         HashMap<String, Employee> shallowCopy = new HashMap<String, Employee>(); | ||||
|         shallowCopy.putAll(originalMap); | ||||
|          | ||||
|         return shallowCopy; | ||||
|     } | ||||
|      | ||||
|     public static <String, Employee> HashMap<String, Employee> copyUsingJava8Stream(HashMap<String, Employee> originalMap) { | ||||
|         Set<Entry<String, Employee>> entries = originalMap.entrySet(); | ||||
|         HashMap<String, Employee> shallowCopy = (HashMap<String, Employee>) entries | ||||
|             .stream() | ||||
|             .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); | ||||
|          | ||||
|         return shallowCopy; | ||||
|     } | ||||
|      | ||||
|     public static <String, Employee> HashMap<String, Employee> shallowCopy(HashMap<String, Employee> originalMap) { | ||||
|         return (HashMap<String, Employee>) originalMap.clone(); | ||||
|     } | ||||
|      | ||||
|     public static <String, Employee> HashMap<String, Employee> deepCopy(HashMap<String, Employee> originalMap) { | ||||
|         return SerializationUtils.clone(originalMap); | ||||
|     } | ||||
|      | ||||
| } | ||||
| @ -0,0 +1,77 @@ | ||||
| package com.baeldung.copyinghashmap; | ||||
| 
 | ||||
| import static org.assertj.core.api.Assertions.assertThat; | ||||
| 
 | ||||
| import java.util.HashMap; | ||||
| import java.util.Map; | ||||
| 
 | ||||
| import org.junit.Test; | ||||
| 
 | ||||
| import com.google.common.collect.ImmutableMap; | ||||
| 
 | ||||
| public class CopyHashMapUnitTest { | ||||
|      | ||||
|     @Test | ||||
|     public void givenHashMap_whenShallowCopy_thenCopyisNotSameAsOriginal() { | ||||
|          | ||||
|         HashMap<String, Employee> map = new HashMap<>(); | ||||
|         Employee emp1 = new Employee("John"); | ||||
|         Employee emp2 = new Employee("Norman"); | ||||
|         map.put("emp1",emp1); | ||||
|         map.put("emp2",emp2); | ||||
|      | ||||
|         HashMap<String, Employee> shallowCopy = CopyHashMap.shallowCopy(map); | ||||
|          | ||||
|         assertThat(shallowCopy).isNotSameAs(map); | ||||
|          | ||||
|     } | ||||
|      | ||||
|     @Test | ||||
|     public void givenHashMap_whenShallowCopyModifyingOriginalObject_thenCopyShouldChange() { | ||||
|          | ||||
|         HashMap<String, Employee> map = new HashMap<>(); | ||||
|         Employee emp1 = new Employee("John"); | ||||
|         Employee emp2 = new Employee("Norman"); | ||||
|         map.put("emp1",emp1); | ||||
|         map.put("emp2",emp2); | ||||
|          | ||||
|         HashMap<String, Employee> shallowCopy = CopyHashMap.shallowCopy(map); | ||||
|          | ||||
|         emp1.setName("Johny"); | ||||
|          | ||||
|         assertThat(shallowCopy.get("emp1")).isEqualTo(map.get("emp1")); | ||||
|          | ||||
|     } | ||||
|      | ||||
|     @Test | ||||
|     public void givenHashMap_whenDeepCopyModifyingOriginalObject_thenCopyShouldNotChange() { | ||||
|          | ||||
|         HashMap<String, Employee> map = new HashMap<>(); | ||||
|         Employee emp1 = new Employee("John"); | ||||
|         Employee emp2 = new Employee("Norman"); | ||||
|         map.put("emp1",emp1); | ||||
|         map.put("emp2",emp2); | ||||
|         HashMap<String, Employee> deepCopy = CopyHashMap.deepCopy(map); | ||||
|          | ||||
|         emp1.setName("Johny"); | ||||
|          | ||||
|         assertThat(deepCopy.get("emp1")).isNotEqualTo(map.get("emp1")); | ||||
|          | ||||
|     } | ||||
|      | ||||
|     @Test | ||||
|     public void givenImmutableMap_whenCopyUsingGuava_thenCopyShouldNotChange() { | ||||
|         Employee emp1 = new Employee("John"); | ||||
|         Employee emp2 = new Employee("Norman"); | ||||
|          | ||||
|         Map<String, Employee> map = ImmutableMap.<String, Employee> builder() | ||||
|             .put("emp1",emp1) | ||||
|             .put("emp2",emp2) | ||||
|             .build(); | ||||
|         Map<String, Employee> shallowCopy = ImmutableMap.copyOf(map); | ||||
|          | ||||
|         assertThat(shallowCopy).isSameAs(map); | ||||
|          | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| @ -0,0 +1,28 @@ | ||||
| package com.baeldung.copyinghashmap; | ||||
| 
 | ||||
| import java.io.Serializable; | ||||
| 
 | ||||
| public class Employee implements Serializable{ | ||||
|      | ||||
|     private String name; | ||||
|      | ||||
|     public Employee(String name) { | ||||
|         super(); | ||||
|         this.name = name; | ||||
|     } | ||||
|     public String getName() { | ||||
|         return name; | ||||
|     } | ||||
|      | ||||
|     public void setName(String name) { | ||||
|         this.name = name; | ||||
|     } | ||||
|      | ||||
|     @Override | ||||
|     public String toString() { | ||||
|         return this.name; | ||||
|     } | ||||
|   | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| @ -3,7 +3,7 @@ | ||||
| ## Core Java Collections Cookbooks and Examples | ||||
| 
 | ||||
| ### Relevant Articles:  | ||||
| - [Java - Combine Multiple Collections](http://www.baeldung.com/java-combine-multiple-collections) | ||||
| - [Java – Combine Multiple Collections](http://www.baeldung.com/java-combine-multiple-collections) | ||||
| - [HashSet and TreeSet Comparison](http://www.baeldung.com/java-hashset-vs-treeset) | ||||
| - [Collect a Java Stream to an Immutable Collection](http://www.baeldung.com/java-stream-immutable-collection) | ||||
| - [Introduction to the Java ArrayDeque](http://www.baeldung.com/java-array-deque) | ||||
|  | ||||
| @ -12,7 +12,7 @@ | ||||
| - [Guide to the Java Phaser](http://www.baeldung.com/java-phaser) | ||||
| - [An Introduction to Atomic Variables in Java](http://www.baeldung.com/java-atomic-variables) | ||||
| - [CyclicBarrier in Java](http://www.baeldung.com/java-cyclic-barrier) | ||||
| - [Guide to Volatile Keyword in Java](http://www.baeldung.com/java-volatile) | ||||
| - [Guide to the Volatile Keyword in Java](http://www.baeldung.com/java-volatile) | ||||
| - [Semaphores in Java](http://www.baeldung.com/java-semaphore) | ||||
| - [Daemon Threads in Java](http://www.baeldung.com/java-daemon-thread) | ||||
| - [Priority-based Job Scheduling in Java](http://www.baeldung.com/java-priority-job-schedule) | ||||
| @ -20,6 +20,6 @@ | ||||
| - [Print Even and Odd Numbers Using 2 Threads](https://www.baeldung.com/java-even-odd-numbers-with-2-threads) | ||||
| - [Java CyclicBarrier vs CountDownLatch](https://www.baeldung.com/java-cyclicbarrier-countdownlatch) | ||||
| - [Guide to the Fork/Join Framework in Java](http://www.baeldung.com/java-fork-join) | ||||
| - [A Guide to ThreadLocalRandom in Java](http://www.baeldung.com/java-thread-local-random) | ||||
| - [Guide to ThreadLocalRandom in Java](http://www.baeldung.com/java-thread-local-random) | ||||
| - [The Thread.join() Method in Java](http://www.baeldung.com/java-thread-join) | ||||
| - [Passing Parameters to Java Threads](https://www.baeldung.com/java-thread-parameters) | ||||
|  | ||||
| @ -7,13 +7,13 @@ | ||||
| - [A Guide to the Java ExecutorService](http://www.baeldung.com/java-executor-service-tutorial) | ||||
| - [Guide to java.util.concurrent.Future](http://www.baeldung.com/java-future) | ||||
| - [Difference Between Wait and Sleep in Java](http://www.baeldung.com/java-wait-and-sleep) | ||||
| - [Guide to Synchronized Keyword in Java](http://www.baeldung.com/java-synchronized) | ||||
| - [Guide to the Synchronized Keyword in Java](http://www.baeldung.com/java-synchronized) | ||||
| - [Overview of the java.util.concurrent](http://www.baeldung.com/java-util-concurrent) | ||||
| - [Implementing a Runnable vs Extending a Thread](http://www.baeldung.com/java-runnable-vs-extending-thread) | ||||
| - [How to Kill a Java Thread](http://www.baeldung.com/java-thread-stop) | ||||
| - [ExecutorService - Waiting for Threads to Finish](http://www.baeldung.com/java-executor-wait-for-threads) | ||||
| - [ExecutorService – Waiting for Threads to Finish](http://www.baeldung.com/java-executor-wait-for-threads) | ||||
| - [wait and notify() Methods in Java](http://www.baeldung.com/java-wait-notify) | ||||
| - [Life Cycle of a Thread in Java](http://www.baeldung.com/java-thread-lifecycle) | ||||
| - [Runnable vs. Callable in Java](http://www.baeldung.com/java-runnable-callable) | ||||
| - [What is Thread-Safety and How to Achieve it](https://www.baeldung.com/java-thread-safety) | ||||
| - [What is Thread-Safety and How to Achieve it?](https://www.baeldung.com/java-thread-safety) | ||||
| - [How to Start a Thread in Java](https://www.baeldung.com/java-start-thread) | ||||
|  | ||||
| @ -6,7 +6,7 @@ | ||||
| - [How to Read a Large File Efficiently with Java](http://www.baeldung.com/java-read-lines-large-file) | ||||
| - [Java InputStream to String](http://www.baeldung.com/convert-input-stream-to-string) | ||||
| - [Java – Write to File](http://www.baeldung.com/java-write-to-file) | ||||
| - [Java - Convert File to InputStream](http://www.baeldung.com/convert-file-to-input-stream) | ||||
| - [Java – Convert File to InputStream](http://www.baeldung.com/convert-file-to-input-stream) | ||||
| - [Java Scanner](http://www.baeldung.com/java-scanner) | ||||
| - [Java – Byte Array to Writer](http://www.baeldung.com/java-convert-byte-array-to-writer) | ||||
| - [Java – Directory Size](http://www.baeldung.com/java-folder-size) | ||||
| @ -14,7 +14,7 @@ | ||||
| - [File Size in Java](http://www.baeldung.com/java-file-size) | ||||
| - [Comparing getPath(), getAbsolutePath(), and getCanonicalPath() in Java](http://www.baeldung.com/java-path) | ||||
| - [Using Java MappedByteBuffer](http://www.baeldung.com/java-mapped-byte-buffer) | ||||
| - [Copy a File with Java](http://www.baeldung.com/java-copy-file) | ||||
| - [How to Copy a File with Java](http://www.baeldung.com/java-copy-file) | ||||
| - [Java – Append Data to a File](http://www.baeldung.com/java-append-to-file) | ||||
| - [FileNotFoundException in Java](http://www.baeldung.com/java-filenotfound-exception) | ||||
| - [How to Read a File in Java](http://www.baeldung.com/reading-file-in-java) | ||||
|  | ||||
| @ -3,4 +3,4 @@ | ||||
| ## Core Java JVM Cookbooks and Examples | ||||
| 
 | ||||
| ### Relevant Articles:  | ||||
| - [Method Inlining in the JVM](http://www.baeldung.com/method-inlining-in-the-jvm/) | ||||
| - [Method Inlining in the JVM](https://www.baeldung.com/jvm-method-inlining) | ||||
|  | ||||
							
								
								
									
										19
									
								
								core-java-lambdas/pom.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								core-java-lambdas/pom.xml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,19 @@ | ||||
| <?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-java-lambdas</artifactId> | ||||
|   <version>0.1.0-SNAPSHOT</version> | ||||
|   <name>core-java</name> | ||||
|   <packaging>jar</packaging> | ||||
| 
 | ||||
|   <parent> | ||||
|     <groupId>com.baeldung</groupId> | ||||
|     <artifactId>parent-java</artifactId> | ||||
|     <version>0.0.1-SNAPSHOT</version> | ||||
|     <relativePath>../parent-java</relativePath> | ||||
|   </parent> | ||||
| 
 | ||||
| 
 | ||||
| </project> | ||||
| @ -0,0 +1,88 @@ | ||||
| package com.baeldung.lambdas; | ||||
| 
 | ||||
| import java.util.Random; | ||||
| import java.util.concurrent.ExecutorService; | ||||
| import java.util.concurrent.Executors; | ||||
| import java.util.function.Supplier; | ||||
| import java.util.stream.IntStream; | ||||
| 
 | ||||
| /** | ||||
|  * Class with examples about working with capturing lambdas. | ||||
|  */ | ||||
| public class LambdaVariables { | ||||
| 
 | ||||
|     private volatile boolean run = true; | ||||
|     private int start = 0; | ||||
| 
 | ||||
|     private ExecutorService executor = Executors.newFixedThreadPool(3); | ||||
| 
 | ||||
|     public static void main(String[] args) { | ||||
|         new LambdaVariables().localVariableMultithreading(); | ||||
|     } | ||||
| 
 | ||||
|     Supplier<Integer> incrementer(int start) { | ||||
|         return () -> start; // can't modify start parameter inside the lambda | ||||
|     } | ||||
| 
 | ||||
|     Supplier<Integer> incrementer() { | ||||
|         return () -> start++; | ||||
|     } | ||||
| 
 | ||||
|     public void localVariableMultithreading() { | ||||
|         boolean run = true; | ||||
|         executor.execute(() -> { | ||||
|             while (run) { | ||||
|                 // do operation | ||||
|             } | ||||
|         }); | ||||
|         // commented because it doesn't compile, it's just an example of non-final local variables in lambdas | ||||
|         // run = false; | ||||
|     } | ||||
| 
 | ||||
|     public void instanceVariableMultithreading() { | ||||
|         executor.execute(() -> { | ||||
|             while (run) { | ||||
|                 // do operation | ||||
|             } | ||||
|         }); | ||||
| 
 | ||||
|         run = false; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * WARNING: always avoid this workaround!! | ||||
|      */ | ||||
|     public void workaroundSingleThread() { | ||||
|         int[] holder = new int[] { 2 }; | ||||
|         IntStream sums = IntStream | ||||
|           .of(1, 2, 3) | ||||
|           .map(val -> val + holder[0]); | ||||
| 
 | ||||
|         holder[0] = 0; | ||||
| 
 | ||||
|         System.out.println(sums.sum()); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * WARNING: always avoid this workaround!! | ||||
|      */ | ||||
|     public void workaroundMultithreading() { | ||||
|         int[] holder = new int[] { 2 }; | ||||
|         Runnable runnable = () -> System.out.println(IntStream | ||||
|           .of(1, 2, 3) | ||||
|           .map(val -> val + holder[0]) | ||||
|           .sum()); | ||||
| 
 | ||||
|         new Thread(runnable).start(); | ||||
| 
 | ||||
|         // simulating some processing | ||||
|         try { | ||||
|             Thread.sleep(new Random().nextInt(3) * 1000L); | ||||
|         } catch (InterruptedException e) { | ||||
|             throw new RuntimeException(e); | ||||
|         } | ||||
| 
 | ||||
|         holder[0] = 0; | ||||
|     } | ||||
| 
 | ||||
| } | ||||
							
								
								
									
										4
									
								
								core-java-lang-oop-2/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								core-java-lang-oop-2/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,4 @@ | ||||
| target/ | ||||
| .idea/ | ||||
| bin/ | ||||
| *.iml | ||||
							
								
								
									
										5
									
								
								core-java-lang-oop-2/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								core-java-lang-oop-2/README.md
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,5 @@ | ||||
| ========= | ||||
| 
 | ||||
| ## Core Java Lang OOP 2 Cookbooks and Examples | ||||
| 
 | ||||
| ### Relevant Articles:  | ||||
							
								
								
									
										27
									
								
								core-java-lang-oop-2/pom.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								core-java-lang-oop-2/pom.xml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,27 @@ | ||||
| <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>com.baeldung</groupId> | ||||
|     <artifactId>core-java-lang-oop-2</artifactId> | ||||
|     <version>0.1.0-SNAPSHOT</version> | ||||
|     <name>core-java-lang-oop-2</name> | ||||
|     <packaging>jar</packaging> | ||||
| 
 | ||||
|     <parent> | ||||
|         <groupId>com.baeldung</groupId> | ||||
|         <artifactId>parent-java</artifactId> | ||||
|         <version>0.0.1-SNAPSHOT</version> | ||||
|         <relativePath>../parent-java</relativePath> | ||||
|     </parent> | ||||
| 
 | ||||
|     <build> | ||||
|         <finalName>core-java-lang-oop-2</finalName> | ||||
|         <resources> | ||||
|             <resource> | ||||
|                 <directory>src/main/resources</directory> | ||||
|                 <filtering>true</filtering> | ||||
|             </resource> | ||||
|         </resources> | ||||
|     </build> | ||||
| 
 | ||||
| </project> | ||||
| @ -0,0 +1,16 @@ | ||||
| package com.baeldung.supertypecompilerexception; | ||||
| 
 | ||||
| public class MyClass { | ||||
| 
 | ||||
|     private int myField1 = 10; | ||||
|     private int myField2; | ||||
| 
 | ||||
|     public MyClass() { | ||||
|         //uncomment this to see the supertype compiler error: | ||||
|         //this(myField1); | ||||
|     } | ||||
| 
 | ||||
|     public MyClass(int i) { | ||||
|         myField2 = i; | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,15 @@ | ||||
| package com.baeldung.supertypecompilerexception; | ||||
| 
 | ||||
| public class MyClassSolution1 { | ||||
| 
 | ||||
|     private int myField1 = 10; | ||||
|     private int myField2; | ||||
| 
 | ||||
|     public MyClassSolution1() { | ||||
|         myField2 = myField1; | ||||
|     } | ||||
| 
 | ||||
|     public MyClassSolution1(int i) { | ||||
|         myField2 = i; | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,19 @@ | ||||
| package com.baeldung.supertypecompilerexception; | ||||
| 
 | ||||
| public class MyClassSolution2 { | ||||
| 
 | ||||
|     private int myField1 = 10; | ||||
|     private int myField2; | ||||
| 
 | ||||
|     public MyClassSolution2() { | ||||
|         setupMyFields(myField1); | ||||
|     } | ||||
| 
 | ||||
|     public MyClassSolution2(int i) { | ||||
|         setupMyFields(i); | ||||
|     } | ||||
| 
 | ||||
|     private void setupMyFields(int i) { | ||||
|         myField2 = i; | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,15 @@ | ||||
| package com.baeldung.supertypecompilerexception; | ||||
| 
 | ||||
| public class MyClassSolution3 { | ||||
| 
 | ||||
|     private static final int SOME_CONSTANT = 10; | ||||
|     private int myField2; | ||||
| 
 | ||||
|     public MyClassSolution3() { | ||||
|         this(SOME_CONSTANT); | ||||
|     } | ||||
| 
 | ||||
|     public MyClassSolution3(int i) { | ||||
|         myField2 = i; | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,14 @@ | ||||
| package com.baeldung.supertypecompilerexception; | ||||
| 
 | ||||
| public class MyException extends RuntimeException { | ||||
|     private int errorCode = 0; | ||||
| 
 | ||||
|     public MyException(String message) { | ||||
|         //uncomment this to see the supertype compiler error: | ||||
|         //super(message + getErrorCode()); | ||||
|     } | ||||
| 
 | ||||
|     public int getErrorCode() { | ||||
|         return errorCode; | ||||
|     } | ||||
| } | ||||
| @ -10,7 +10,7 @@ | ||||
| - [How to Make a Deep Copy of an Object in Java](http://www.baeldung.com/java-deep-copy) | ||||
| - [Guide to Inheritance in Java](http://www.baeldung.com/java-inheritance) | ||||
| - [Object Type Casting in Java](http://www.baeldung.com/java-type-casting) | ||||
| - [The "final" Keyword in Java](http://www.baeldung.com/java-final) | ||||
| - [The “final” Keyword in Java](http://www.baeldung.com/java-final) | ||||
| - [Type Erasure in Java Explained](http://www.baeldung.com/java-type-erasure) | ||||
| - [Pass-By-Value as a Parameter Passing Mechanism in Java](http://www.baeldung.com/java-pass-by-value-or-pass-by-reference) | ||||
| - [Variable and Method Hiding in Java](http://www.baeldung.com/java-variable-method-hiding) | ||||
|  | ||||
| @ -12,7 +12,7 @@ | ||||
| - [Dynamic Proxies in Java](http://www.baeldung.com/java-dynamic-proxies) | ||||
| - [Java Double Brace Initialization](http://www.baeldung.com/java-double-brace-initialization) | ||||
| - [Guide to the Diamond Operator in Java](http://www.baeldung.com/java-diamond-operator) | ||||
| - [Quick Example - Comparator vs Comparable in Java](http://www.baeldung.com/java-comparator-comparable) | ||||
| - [Comparator and Comparable in Java](http://www.baeldung.com/java-comparator-comparable) | ||||
| - [The Java continue and break Keywords](http://www.baeldung.com/java-continue-and-break) | ||||
| - [Nested Classes in Java](http://www.baeldung.com/java-nested-classes) | ||||
| - [A Guide to Inner Interfaces in Java](http://www.baeldung.com/java-inner-interfaces) | ||||
|  | ||||
| @ -14,4 +14,5 @@ | ||||
| - [A Guide to Java Sockets](http://www.baeldung.com/a-guide-to-java-sockets) | ||||
| - [Guide to Java URL Encoding/Decoding](http://www.baeldung.com/java-url-encoding-decoding) | ||||
| - [Do a Simple HTTP Request in Java](http://www.baeldung.com/java-http-request) | ||||
| - [Difference between URL and URI](http://www.baeldung.com/java-url-vs-uri) | ||||
| - [Difference between URL and URI](http://www.baeldung.com/java-url-vs-uri) | ||||
| - [Read an InputStream using the Java Server Socket](https://www.baeldung.com/java-inputstream-server-socket) | ||||
|  | ||||
| @ -29,7 +29,7 @@ | ||||
| - [What is the serialVersionUID?](http://www.baeldung.com/java-serial-version-uid) | ||||
| - [A Guide to the ResourceBundle](http://www.baeldung.com/java-resourcebundle) | ||||
| - [Class Loaders in Java](http://www.baeldung.com/java-classloaders) | ||||
| - [Guide to Java Clock Class](http://www.baeldung.com/java-clock) | ||||
| - [Guide to the Java Clock Class](http://www.baeldung.com/java-clock) | ||||
| - [Importance of Main Manifest Attribute in a Self-Executing JAR](http://www.baeldung.com/java-jar-executable-manifest-main-class) | ||||
| - [Java Global Exception Handler](http://www.baeldung.com/java-global-exception-handler) | ||||
| - [How to Get the Size of an Object in Java](http://www.baeldung.com/java-size-of-object) | ||||
|  | ||||
| @ -2,5 +2,8 @@ | ||||
| 
 | ||||
| - [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) | ||||
| - [String Comparison in Kotlin](https://www.baeldung.com/kotlin-string-comparison) | ||||
| - [String Comparison in Kotlin](https://www.baeldung.com/kotlin-string-comparison) | ||||
| @ -0,0 +1,18 @@ | ||||
| package com.baeldung.inputstream | ||||
| 
 | ||||
| import java.io.InputStream | ||||
| 
 | ||||
| fun InputStream.readUpToChar(stopChar: Char): String { | ||||
|     val stringBuilder = StringBuilder() | ||||
|     var currentChar = this.read().toChar() | ||||
|     while (currentChar != stopChar) { | ||||
|         stringBuilder.append(currentChar) | ||||
|         currentChar = this.read().toChar() | ||||
|         if (this.available() <= 0) { | ||||
|             stringBuilder.append(currentChar) | ||||
|             break | ||||
|         } | ||||
|     } | ||||
|     return stringBuilder.toString() | ||||
| } | ||||
| 
 | ||||
| @ -0,0 +1,71 @@ | ||||
| package com.baeldung.inputstream | ||||
| 
 | ||||
| import kotlinx.io.core.use | ||||
| import org.junit.Test | ||||
| import java.io.BufferedReader | ||||
| import java.io.File | ||||
| import kotlin.test.assertEquals | ||||
| 
 | ||||
| class InputStreamToStringTest { | ||||
|     private val fileName = "src/test/resources/inputstream2string.txt" | ||||
|     private val fileFullContent = "Computer programming can be a hassle\r\n" + | ||||
|             "It's like trying to take a defended castle" | ||||
| 
 | ||||
|     @Test | ||||
|     fun whenReadFileWithBufferedReader_thenFullFileContentIsReadAsString() { | ||||
|         val file = File(fileName) | ||||
|         val inputStream = file.inputStream() | ||||
|         val content = inputStream.bufferedReader().use(BufferedReader::readText) | ||||
|         assertEquals(fileFullContent, content) | ||||
|     } | ||||
|     @Test | ||||
|     fun whenReadFileWithBufferedReaderReadText_thenFullFileContentIsReadAsString() { | ||||
|         val file = File(fileName) | ||||
|         val inputStream = file.inputStream() | ||||
|         val reader = BufferedReader(inputStream.reader()) | ||||
|         var content: String | ||||
|         try { | ||||
|             content = reader.readText() | ||||
|         } finally { | ||||
|             reader.close() | ||||
|         } | ||||
|         assertEquals(fileFullContent, content) | ||||
|     } | ||||
|     @Test | ||||
|     fun whenReadFileWithBufferedReaderManually_thenFullFileContentIsReadAsString() { | ||||
|         val file = File(fileName) | ||||
|         val inputStream = file.inputStream() | ||||
|         val reader = BufferedReader(inputStream.reader()) | ||||
|         val content = StringBuilder() | ||||
|         try { | ||||
|             var line = reader.readLine() | ||||
|             while (line != null) { | ||||
|                 content.append(line) | ||||
|                 line = reader.readLine() | ||||
|             } | ||||
|         } finally { | ||||
|             reader.close() | ||||
|         } | ||||
|         assertEquals(fileFullContent.replace("\r\n", ""), content.toString()) | ||||
| 
 | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     fun whenReadFileUpToStopChar_thenPartBeforeStopCharIsReadAsString() { | ||||
|         val file = File(fileName) | ||||
|         val inputStream = file.inputStream() | ||||
|         val content = inputStream.use { it.readUpToChar(' ') } | ||||
|         assertEquals("Computer", content) | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     fun whenReadFileWithoutContainingStopChar_thenFullFileContentIsReadAsString() { | ||||
|         val file = File(fileName) | ||||
|         val inputStream = file.inputStream() | ||||
|         val content = inputStream.use { it.readUpToChar('-') } | ||||
|         assertEquals(fileFullContent, content) | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
| } | ||||
| 
 | ||||
							
								
								
									
										2
									
								
								core-kotlin-2/src/test/resources/inputstream2string.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								core-kotlin-2/src/test/resources/inputstream2string.txt
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,2 @@ | ||||
| Computer programming can be a hassle | ||||
| It's like trying to take a defended castle | ||||
| @ -1,7 +1,7 @@ | ||||
| ## Relevant articles: | ||||
| 
 | ||||
| - [Introduction to the Kotlin Language](http://www.baeldung.com/kotlin) | ||||
| - [A guide to the “when{}” block in Kotlin](http://www.baeldung.com/kotlin-when) | ||||
| - [Guide to the “when{}” Block in Kotlin](http://www.baeldung.com/kotlin-when) | ||||
| - [Comprehensive Guide to Null Safety in Kotlin](http://www.baeldung.com/kotlin-null-safety) | ||||
| - [Kotlin Java Interoperability](http://www.baeldung.com/kotlin-java-interoperability) | ||||
| - [Difference Between “==” and “===” operators in Kotlin](http://www.baeldung.com/kotlin-equality-operators) | ||||
|  | ||||
| @ -0,0 +1,9 @@ | ||||
| @file:JvmName("Strings") | ||||
| package com.baeldung.kotlin | ||||
| 
 | ||||
| fun String.escapeForXml() : String { | ||||
|     return this | ||||
|             .replace("&", "&") | ||||
|             .replace("<", "<") | ||||
|             .replace(">", ">") | ||||
| } | ||||
| @ -0,0 +1,30 @@ | ||||
| package com.baeldung.kotlin; | ||||
| 
 | ||||
| import kotlin.text.StringsKt; | ||||
| import org.junit.Assert; | ||||
| import org.junit.Test; | ||||
| 
 | ||||
| import static com.baeldung.kotlin.Strings.*; | ||||
| 
 | ||||
| 
 | ||||
| public class StringUtilUnitTest { | ||||
| 
 | ||||
|     @Test | ||||
|     public void shouldEscapeXmlTagsInString() { | ||||
|         String xml = "<a>hi</a>"; | ||||
| 
 | ||||
|         String escapedXml = escapeForXml(xml); | ||||
| 
 | ||||
|         Assert.assertEquals("<a>hi</a>", escapedXml); | ||||
|     } | ||||
| 
 | ||||
|     @Test | ||||
|     public void callingBuiltInKotlinExtensionMethod() { | ||||
|         String name = "john"; | ||||
| 
 | ||||
|         String capitalizedName = StringsKt.capitalize(name); | ||||
| 
 | ||||
|         Assert.assertEquals("John", capitalizedName); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
| @ -6,13 +6,6 @@ import org.junit.Test | ||||
| class ExtensionMethods { | ||||
|     @Test | ||||
|     fun simpleExtensionMethod() { | ||||
|         fun String.escapeForXml() : String { | ||||
|             return this | ||||
|                     .replace("&", "&") | ||||
|                     .replace("<", "<") | ||||
|                     .replace(">", ">") | ||||
|         } | ||||
| 
 | ||||
|         Assert.assertEquals("Nothing", "Nothing".escapeForXml()) | ||||
|         Assert.assertEquals("<Tag>", "<Tag>".escapeForXml()) | ||||
|         Assert.assertEquals("a&b", "a&b".escapeForXml()) | ||||
|  | ||||
| @ -3,7 +3,7 @@ | ||||
| ### Relevant Articles: | ||||
| - [Introduction to Couchbase SDK for Java](http://www.baeldung.com/java-couchbase-sdk) | ||||
| - [Using Couchbase in a Spring Application](http://www.baeldung.com/couchbase-sdk-spring) | ||||
| - [Asynchronous Batch Opereations in Couchbase](http://www.baeldung.com/async-batch-operations-in-couchbase) | ||||
| - [Asynchronous Batch Operations in Couchbase](http://www.baeldung.com/async-batch-operations-in-couchbase) | ||||
| - [Querying Couchbase with MapReduce Views](http://www.baeldung.com/couchbase-query-mapreduce-view) | ||||
| - [Querying Couchbase with N1QL](http://www.baeldung.com/n1ql-couchbase) | ||||
| 
 | ||||
|  | ||||
| @ -11,6 +11,6 @@ | ||||
| - [Convert JSON to a Map Using Gson](https://www.baeldung.com/gson-json-to-map) | ||||
| - [Working with Primitive Values in Gson](https://www.baeldung.com/java-gson-primitives) | ||||
| - [Convert String to JsonObject with Gson](https://www.baeldung.com/gson-string-to-jsonobject) | ||||
| - [Mapping Multiple JSON Fields to One Java Field](https://www.baeldung.com/json-multiple-fields-single-java-field) | ||||
| - [Mapping Multiple JSON Fields to a Single Java Field](https://www.baeldung.com/json-multiple-fields-single-java-field) | ||||
| - [Serializing and Deserializing a List with Gson](https://www.baeldung.com/gson-list) | ||||
| 
 | ||||
|  | ||||
| @ -1,4 +1,4 @@ | ||||
| ### Relevant articles: | ||||
| - [New Stream, Comparator and Collector Functionality in Guava 21](http://www.baeldung.com/guava-21-new) | ||||
| - [New Stream, Comparator and Collector in Guava 21](http://www.baeldung.com/guava-21-new) | ||||
| - [New in Guava 21 common.util.concurrent](http://www.baeldung.com/guava-21-util-concurrent) | ||||
| - [Zipping Collections in Java](http://www.baeldung.com/java-collections-zip) | ||||
|  | ||||
| @ -15,13 +15,18 @@ | ||||
|         <dependency> | ||||
|             <groupId>io.helidon.microprofile.bundles</groupId> | ||||
|             <artifactId>helidon-microprofile-1.2</artifactId> | ||||
|             <version>0.10.4</version> | ||||
|             <version>${helidon-microprofile.version}</version> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>org.glassfish.jersey.media</groupId> | ||||
|             <artifactId>jersey-media-json-binding</artifactId> | ||||
|             <version>2.26</version> | ||||
|             <version>${jersey-media-json-binding.version}</version> | ||||
|         </dependency> | ||||
|     </dependencies> | ||||
| 
 | ||||
|     <properties> | ||||
|         <helidon-microprofile.version>0.10.4</helidon-microprofile.version> | ||||
|         <jersey-media-json-binding.version>2.26</jersey-media-json-binding.version> | ||||
|     </properties> | ||||
| 
 | ||||
| </project> | ||||
|  | ||||
| @ -12,10 +12,6 @@ | ||||
|         <version>1.0.0-SNAPSHOT</version> | ||||
|     </parent> | ||||
| 
 | ||||
|     <properties> | ||||
|         <helidon.version>0.10.4</helidon.version> | ||||
|     </properties> | ||||
| 
 | ||||
|     <dependencies> | ||||
|         <!--Config--> | ||||
|         <dependency> | ||||
| @ -61,4 +57,8 @@ | ||||
| 
 | ||||
|     </dependencies> | ||||
| 
 | ||||
|     <properties> | ||||
|         <helidon.version>0.10.4</helidon.version> | ||||
|     </properties> | ||||
| 
 | ||||
| </project> | ||||
| @ -9,7 +9,7 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring | ||||
| 
 | ||||
| - [HttpClient 4 – Send Custom Cookie](http://www.baeldung.com/httpclient-4-cookies) | ||||
| - [HttpClient 4 – Get the Status Code](http://www.baeldung.com/httpclient-status-code) | ||||
| - [HttpClient 4 – Cancel / Abort Request](http://www.baeldung.com/httpclient-cancel-request) | ||||
| - [HttpClient 4 – Cancel Request](http://www.baeldung.com/httpclient-cancel-request) | ||||
| - [HttpClient 4 Cookbook](http://www.baeldung.com/httpclient4) | ||||
| - [Unshorten URLs with HttpClient](http://www.baeldung.com/unshorten-url-httpclient) | ||||
| - [HttpClient 4 – Follow Redirects for POST](http://www.baeldung.com/httpclient-redirect-on-http-post) | ||||
|  | ||||
| @ -16,7 +16,7 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring | ||||
| - [Jackson – Bidirectional Relationships](http://www.baeldung.com/jackson-bidirectional-relationships-and-infinite-recursion) | ||||
| - [Jackson JSON Tutorial](http://www.baeldung.com/jackson) | ||||
| - [Jackson – Working with Maps and nulls](http://www.baeldung.com/jackson-map-null-values-or-null-key) | ||||
| - [Jackson – Decide What Fields Get Serialized/Deserializaed](http://www.baeldung.com/jackson-field-serializable-deserializable-or-not) | ||||
| - [Jackson – Decide What Fields Get Serialized/Deserialized](http://www.baeldung.com/jackson-field-serializable-deserializable-or-not) | ||||
| - [Jackson Annotation Examples](http://www.baeldung.com/jackson-annotations) | ||||
| - [Working with Tree Model Nodes in Jackson](http://www.baeldung.com/jackson-json-node-tree-model) | ||||
| - [Jackson vs Gson](http://www.baeldung.com/jackson-vs-gson) | ||||
|  | ||||
							
								
								
									
										2
									
								
								java-collections-maps-2/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								java-collections-maps-2/README.md
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,2 @@ | ||||
| ## Relevant Articles: | ||||
| - [Map of Primitives in Java](https://www.baeldung.com/java-map-primitives) | ||||
| @ -24,22 +24,25 @@ | ||||
|         <dependency> | ||||
|             <groupId>net.sf.trove4j</groupId> | ||||
|             <artifactId>trove4j</artifactId> | ||||
|             <version>3.0.2</version> | ||||
|             <version>${trove4j.version}</version> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>it.unimi.dsi</groupId> | ||||
|             <artifactId>fastutil</artifactId> | ||||
|             <version>8.1.0</version> | ||||
|             <version>${fastutil.version}</version> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>colt</groupId> | ||||
|             <artifactId>colt</artifactId> | ||||
|             <version>1.2.0</version> | ||||
|             <version>${colt.version}</version> | ||||
|         </dependency> | ||||
|     </dependencies> | ||||
| 
 | ||||
|     <properties> | ||||
|         <eclipse-collections.version>8.2.0</eclipse-collections.version> | ||||
|         <trove4j.version>3.0.2</trove4j.version> | ||||
|         <fastutil.version>8.1.0</fastutil.version> | ||||
|         <colt.version>1.2.0</colt.version> | ||||
|     </properties> | ||||
| 
 | ||||
| </project> | ||||
							
								
								
									
										2
									
								
								java-dates-2/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								java-dates-2/README.md
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,2 @@ | ||||
| ## Relevant Articles: | ||||
| - [Converting Between LocalDate and XMLGregorianCalendar](https://www.baeldung.com/java-localdate-to-xmlgregoriancalendar) | ||||
							
								
								
									
										4
									
								
								java-math/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								java-math/.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,4 @@ | ||||
| /target/ | ||||
| .settings/ | ||||
| .classpath | ||||
| .project | ||||
							
								
								
									
										10
									
								
								java-math/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								java-math/README.md
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,10 @@ | ||||
| ## Relevant articles: | ||||
| 
 | ||||
| - [Calculate Factorial in Java](https://www.baeldung.com/java-calculate-factorial) | ||||
| - [Generate Combinations in Java](https://www.baeldung.com/java-combinations-algorithm) | ||||
| - [Check If Two Rectangles Overlap In Java](https://www.baeldung.com/java-check-if-two-rectangles-overlap) | ||||
| - [Calculate the Distance Between Two Points in Java](https://www.baeldung.com/java-distance-between-two-points) | ||||
| - [Find the Intersection of Two Lines in Java](https://www.baeldung.com/java-intersection-of-two-lines) | ||||
| - [Round Up to the Nearest Hundred](https://www.baeldung.com/java-round-up-nearest-hundred) | ||||
| - [Calculate Percentage in Java](https://www.baeldung.com/java-calculate-percentage) | ||||
| - [Convert Latitude and Longitude to a 2D Point in Java](https://www.baeldung.com/java-convert-latitude-longitude) | ||||
							
								
								
									
										68
									
								
								java-math/pom.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								java-math/pom.xml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,68 @@ | ||||
| <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>java-math</artifactId> | ||||
|     <version>0.0.1-SNAPSHOT</version> | ||||
|     <name>java-math</name> | ||||
|      | ||||
|     <parent> | ||||
|         <groupId>com.baeldung</groupId> | ||||
|         <artifactId>parent-modules</artifactId> | ||||
|         <version>1.0.0-SNAPSHOT</version> | ||||
|     </parent> | ||||
| 
 | ||||
|     <dependencies> | ||||
|         <dependency> | ||||
|             <groupId>org.apache.commons</groupId> | ||||
|             <artifactId>commons-math3</artifactId> | ||||
|             <version>${commons-math3.version}</version> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>com.google.guava</groupId> | ||||
|             <artifactId>guava</artifactId> | ||||
|             <version>${guava.version}</version> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>commons-codec</groupId> | ||||
|             <artifactId>commons-codec</artifactId> | ||||
|             <version>${commons-codec.version}</version> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>org.projectlombok</groupId> | ||||
|             <artifactId>lombok</artifactId> | ||||
|             <version>${lombok.version}</version> | ||||
|             <scope>provided</scope> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>org.assertj</groupId> | ||||
|             <artifactId>assertj-core</artifactId> | ||||
|             <version>${org.assertj.core.version}</version> | ||||
|             <scope>test</scope> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>com.github.dpaukov</groupId> | ||||
|             <artifactId>combinatoricslib3</artifactId> | ||||
|             <version>3.3.0</version> | ||||
|          </dependency> | ||||
|     </dependencies> | ||||
| 
 | ||||
|     <build> | ||||
|         <pluginManagement> | ||||
|             <plugins> | ||||
|                 <plugin> | ||||
|                     <groupId>org.codehaus.mojo</groupId> | ||||
|                     <artifactId>exec-maven-plugin</artifactId> | ||||
|                     <version>${exec-maven-plugin.version}</version> | ||||
|                 </plugin> | ||||
|             </plugins> | ||||
|         </pluginManagement> | ||||
|     </build> | ||||
| 
 | ||||
|     <properties> | ||||
|         <commons-math3.version>3.6.1</commons-math3.version> | ||||
|         <org.assertj.core.version>3.9.0</org.assertj.core.version> | ||||
|         <commons-codec.version>1.11</commons-codec.version> | ||||
|         <guava.version>27.0.1-jre</guava.version> | ||||
|     </properties> | ||||
| 
 | ||||
| </project> | ||||
| @ -1,4 +1,4 @@ | ||||
| package com.baeldung.percentage; | ||||
| package com.baeldung.algorithms.percentage; | ||||
| 
 | ||||
| import java.util.Scanner; | ||||
| 
 | ||||
| @ -2,8 +2,6 @@ package com.baeldung.algorithms.distancebetweenpoints; | ||||
| 
 | ||||
| import org.junit.Test; | ||||
| 
 | ||||
| import com.baeldung.algorithms.distancebetweenpoints.DistanceBetweenPointsService; | ||||
| 
 | ||||
| import static org.junit.Assert.assertEquals; | ||||
| 
 | ||||
| public class DistanceBetweenPointsServiceUnitTest { | ||||
Some files were not shown because too many files have changed in this diff Show More
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user