Merge remote-tracking branch 'upstream/master' into BAEL-2781-classgraph
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
.idea/
|
.idea/
|
||||||
*.iml
|
*.iml
|
||||||
*.iws
|
*.iws
|
||||||
|
out/
|
||||||
|
|
||||||
# Mac
|
# Mac
|
||||||
.DS_Store
|
.DS_Store
|
||||||
@@ -27,6 +28,9 @@
|
|||||||
log/
|
log/
|
||||||
target/
|
target/
|
||||||
|
|
||||||
|
# Gradle
|
||||||
|
.gradle/
|
||||||
|
|
||||||
spring-openid/src/main/resources/application.properties
|
spring-openid/src/main/resources/application.properties
|
||||||
.recommenders/
|
.recommenders/
|
||||||
/spring-hibernate4/nbproject/
|
/spring-hibernate4/nbproject/
|
||||||
|
|||||||
@@ -14,18 +14,19 @@
|
|||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.typesafe.akka</groupId>
|
<groupId>com.typesafe.akka</groupId>
|
||||||
<artifactId>akka-stream_2.11</artifactId>
|
<artifactId>akka-stream_${scala.version}</artifactId>
|
||||||
<version>${akkastreams.version}</version>
|
<version>${akkastreams.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.typesafe.akka</groupId>
|
<groupId>com.typesafe.akka</groupId>
|
||||||
<artifactId>akka-stream-testkit_2.11</artifactId>
|
<artifactId>akka-stream-testkit_${scala.version}</artifactId>
|
||||||
<version>${akkastreams.version}</version>
|
<version>${akkastreams.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<akkastreams.version>2.5.2</akkastreams.version>
|
<akkastreams.version>2.5.2</akkastreams.version>
|
||||||
|
<scala.version>2.11</scala.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
+1
-1
@@ -30,7 +30,7 @@ public class TreeNode {
|
|||||||
this.leftChild = leftChild;
|
this.leftChild = leftChild;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TreeNode(int value, TreeNode rightChild, TreeNode leftChild) {
|
public TreeNode(int value, TreeNode leftChild, TreeNode rightChild) {
|
||||||
this.value = value;
|
this.value = value;
|
||||||
this.rightChild = rightChild;
|
this.rightChild = rightChild;
|
||||||
this.leftChild = leftChild;
|
this.leftChild = leftChild;
|
||||||
|
|||||||
-15
@@ -4,21 +4,6 @@ import java.util.LinkedList;
|
|||||||
|
|
||||||
public class TreeReverser {
|
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) {
|
public void reverseRecursive(TreeNode treeNode) {
|
||||||
if (treeNode == null) {
|
if (treeNode == null) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
+16
-2
@@ -10,7 +10,7 @@ public class TreeReverserUnitTest {
|
|||||||
public void givenTreeWhenReversingRecursivelyThenReversed() {
|
public void givenTreeWhenReversingRecursivelyThenReversed() {
|
||||||
TreeReverser reverser = new TreeReverser();
|
TreeReverser reverser = new TreeReverser();
|
||||||
|
|
||||||
TreeNode treeNode = reverser.createBinaryTree();
|
TreeNode treeNode = createBinaryTree();
|
||||||
|
|
||||||
reverser.reverseRecursive(treeNode);
|
reverser.reverseRecursive(treeNode);
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ public class TreeReverserUnitTest {
|
|||||||
public void givenTreeWhenReversingIterativelyThenReversed() {
|
public void givenTreeWhenReversingIterativelyThenReversed() {
|
||||||
TreeReverser reverser = new TreeReverser();
|
TreeReverser reverser = new TreeReverser();
|
||||||
|
|
||||||
TreeNode treeNode = reverser.createBinaryTree();
|
TreeNode treeNode = createBinaryTree();
|
||||||
|
|
||||||
reverser.reverseIterative(treeNode);
|
reverser.reverseIterative(treeNode);
|
||||||
|
|
||||||
@@ -30,4 +30,18 @@ public class TreeReverserUnitTest {
|
|||||||
.trim());
|
.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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-7
@@ -10,6 +10,14 @@
|
|||||||
<version>1.0.0-SNAPSHOT</version>
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.antlr</groupId>
|
||||||
|
<artifactId>antlr4-runtime</artifactId>
|
||||||
|
<version>${antlr.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
@@ -44,13 +52,7 @@
|
|||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.antlr</groupId>
|
|
||||||
<artifactId>antlr4-runtime</artifactId>
|
|
||||||
<version>${antlr.version}</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
<properties>
|
<properties>
|
||||||
<antlr.version>4.7.1</antlr.version>
|
<antlr.version>4.7.1</antlr.version>
|
||||||
<mojo.version>3.0.0</mojo.version>
|
<mojo.version>3.0.0</mojo.version>
|
||||||
|
|||||||
@@ -12,9 +12,18 @@
|
|||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<properties>
|
<dependencies>
|
||||||
<cxf-version>3.2.0</cxf-version>
|
<dependency>
|
||||||
</properties>
|
<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>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
@@ -45,17 +54,8 @@
|
|||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<dependencies>
|
<properties>
|
||||||
<dependency>
|
<cxf-version>3.2.0</cxf-version>
|
||||||
<groupId>org.apache.cxf</groupId>
|
</properties>
|
||||||
<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>
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -13,11 +13,28 @@
|
|||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<properties>
|
<dependencies>
|
||||||
<liberty-maven-plugin.version>2.4.2</liberty-maven-plugin.version>
|
|
||||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
<dependency>
|
||||||
<openliberty-version>18.0.0.2</openliberty-version>
|
<groupId>javax.ws.rs</groupId>
|
||||||
</properties>
|
<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>
|
<build>
|
||||||
<finalName>${project.artifactId}</finalName>
|
<finalName>${project.artifactId}</finalName>
|
||||||
@@ -59,27 +76,10 @@
|
|||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<dependencies>
|
<properties>
|
||||||
|
<liberty-maven-plugin.version>2.4.2</liberty-maven-plugin.version>
|
||||||
<dependency>
|
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||||
<groupId>javax.ws.rs</groupId>
|
<openliberty-version>18.0.0.2</openliberty-version>
|
||||||
<artifactId>javax.ws.rs-api</artifactId>
|
</properties>
|
||||||
<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>
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -7,6 +7,12 @@
|
|||||||
<name>apache-meecrowave</name>
|
<name>apache-meecrowave</name>
|
||||||
<description>A sample REST API application with Meecrowave</description>
|
<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>
|
<dependencies>
|
||||||
<!-- https://mvnrepository.com/artifact/org.apache.meecrowave/meecrowave-core -->
|
<!-- https://mvnrepository.com/artifact/org.apache.meecrowave/meecrowave-core -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
+1
-1
@@ -17,7 +17,7 @@ import okhttp3.Request;
|
|||||||
import okhttp3.Response;
|
import okhttp3.Response;
|
||||||
|
|
||||||
@RunWith(MonoMeecrowave.Runner.class)
|
@RunWith(MonoMeecrowave.Runner.class)
|
||||||
public class ArticleEndpointsTest {
|
public class ArticleEndpointsUnitTest {
|
||||||
|
|
||||||
@ConfigurationInject
|
@ConfigurationInject
|
||||||
private Meecrowave.Builder config;
|
private Meecrowave.Builder config;
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
### Relevant Articles:
|
### 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
-1
@@ -1,5 +1,5 @@
|
|||||||
### Relevant Articles:
|
### 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`
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
### Revelant Articles
|
||||||
|
|
||||||
|
- [A Quick Guide To Using Cloud Foundry UAA](https://www.baeldung.com/cloud-foundry-uaa)
|
||||||
@@ -2,24 +2,20 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<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">
|
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>
|
<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>
|
<groupId>com.example</groupId>
|
||||||
<artifactId>cf-uaa-oauth2-client</artifactId>
|
<artifactId>cf-uaa-oauth2-client</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<name>uaa-client-webapp</name>
|
<name>uaa-client-webapp</name>
|
||||||
<description>Demo project for Spring Boot</description>
|
<description>Demo project for Spring Boot</description>
|
||||||
|
|
||||||
<properties>
|
<parent>
|
||||||
<java.version>1.8</java.version>
|
<artifactId>parent-boot-2</artifactId>
|
||||||
</properties>
|
<groupId>com.baeldung</groupId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<relativePath>../../parent-boot-2</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
@@ -28,7 +24,6 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-oauth2-client</artifactId>
|
<artifactId>spring-boot-starter-oauth2-client</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@@ -40,4 +35,7 @@
|
|||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
</properties>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -2,24 +2,20 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<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">
|
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>
|
<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>
|
<groupId>com.baeldung.cfuaa</groupId>
|
||||||
<artifactId>cf-uaa-oauth2-resource-server</artifactId>
|
<artifactId>cf-uaa-oauth2-resource-server</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<name>cf-uaa-oauth2-resource-server</name>
|
<name>cf-uaa-oauth2-resource-server</name>
|
||||||
<description>Demo project for Spring Boot</description>
|
<description>Demo project for Spring Boot</description>
|
||||||
|
|
||||||
<properties>
|
<parent>
|
||||||
<java.version>1.8</java.version>
|
<artifactId>parent-boot-2</artifactId>
|
||||||
</properties>
|
<groupId>com.baeldung</groupId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
<relativePath>../../parent-boot-2</relativePath>
|
||||||
|
</parent>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
|
<artifactId>spring-boot-starter-oauth2-resource-server</artifactId>
|
||||||
@@ -28,7 +24,6 @@
|
|||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@@ -40,4 +35,8 @@
|
|||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
# Groovy
|
||||||
|
|
||||||
|
## Relevant articles:
|
||||||
|
|
||||||
|
- [String Matching in Groovy](http://www.baeldung.com/)
|
||||||
|
- [Groovy def Keyword]
|
||||||
|
|
||||||
@@ -0,0 +1,131 @@
|
|||||||
|
<?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-groovy-2</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<name>core-groovy-2</name>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>com.baeldung</groupId>
|
||||||
|
<artifactId>parent-modules</artifactId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.codehaus.groovy</groupId>
|
||||||
|
<artifactId>groovy</artifactId>
|
||||||
|
<version>${groovy.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.codehaus.groovy</groupId>
|
||||||
|
<artifactId>groovy-all</artifactId>
|
||||||
|
<version>${groovy-all.version}</version>
|
||||||
|
<type>pom</type>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.codehaus.groovy</groupId>
|
||||||
|
<artifactId>groovy-dateutil</artifactId>
|
||||||
|
<version>${groovy.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.codehaus.groovy</groupId>
|
||||||
|
<artifactId>groovy-sql</artifactId>
|
||||||
|
<version>${groovy-sql.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.platform</groupId>
|
||||||
|
<artifactId>junit-platform-runner</artifactId>
|
||||||
|
<version>${junit.platform.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.hsqldb</groupId>
|
||||||
|
<artifactId>hsqldb</artifactId>
|
||||||
|
<version>${hsqldb.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.spockframework</groupId>
|
||||||
|
<artifactId>spock-core</artifactId>
|
||||||
|
<version>${spock-core.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.gmavenplus</groupId>
|
||||||
|
<artifactId>gmavenplus-plugin</artifactId>
|
||||||
|
<version>${gmavenplus-plugin.version}</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<goals>
|
||||||
|
<goal>addSources</goal>
|
||||||
|
<goal>addTestSources</goal>
|
||||||
|
<goal>compile</goal>
|
||||||
|
<goal>compileTests</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-failsafe-plugin</artifactId>
|
||||||
|
<version>${maven-failsafe-plugin.version}</version>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.junit.platform</groupId>
|
||||||
|
<artifactId>junit-platform-surefire-provider</artifactId>
|
||||||
|
<version>${junit.platform.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>junit5</id>
|
||||||
|
<goals>
|
||||||
|
<goal>integration-test</goal>
|
||||||
|
<goal>verify</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<includes>
|
||||||
|
<include>**/*Test5.java</include>
|
||||||
|
</includes>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>2.20.1</version>
|
||||||
|
<configuration>
|
||||||
|
<useFile>false</useFile>
|
||||||
|
<includes>
|
||||||
|
<include>**/*Test.java</include>
|
||||||
|
<include>**/*Spec.java</include>
|
||||||
|
</includes>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>central</id>
|
||||||
|
<url>http://jcenter.bintray.com</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<junit.platform.version>1.0.0</junit.platform.version>
|
||||||
|
<groovy.version>2.5.6</groovy.version>
|
||||||
|
<groovy-all.version>2.5.6</groovy-all.version>
|
||||||
|
<groovy-sql.version>2.5.6</groovy-sql.version>
|
||||||
|
<hsqldb.version>2.4.0</hsqldb.version>
|
||||||
|
<spock-core.version>1.1-groovy-2.4</spock-core.version>
|
||||||
|
<gmavenplus-plugin.version>1.6</gmavenplus-plugin.version>
|
||||||
|
</properties>
|
||||||
|
</project>
|
||||||
|
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
package com.baeldung.defkeyword
|
||||||
|
|
||||||
|
import org.codehaus.groovy.runtime.NullObject
|
||||||
|
import org.codehaus.groovy.runtime.typehandling.GroovyCastException
|
||||||
|
|
||||||
|
import groovy.transform.TypeChecked
|
||||||
|
import groovy.transform.TypeCheckingMode
|
||||||
|
|
||||||
|
@TypeChecked
|
||||||
|
class DefUnitTest extends GroovyTestCase {
|
||||||
|
|
||||||
|
def id
|
||||||
|
def firstName = "Samwell"
|
||||||
|
def listOfCountries = ['USA', 'UK', 'FRANCE', 'INDIA']
|
||||||
|
|
||||||
|
@TypeChecked(TypeCheckingMode.SKIP)
|
||||||
|
def multiply(x, y) {
|
||||||
|
return x*y
|
||||||
|
}
|
||||||
|
|
||||||
|
@TypeChecked(TypeCheckingMode.SKIP)
|
||||||
|
void testDefVariableDeclaration() {
|
||||||
|
|
||||||
|
def list
|
||||||
|
assert list.getClass() == org.codehaus.groovy.runtime.NullObject
|
||||||
|
assert list.is(null)
|
||||||
|
|
||||||
|
list = [1,2,4]
|
||||||
|
assert list instanceof ArrayList
|
||||||
|
}
|
||||||
|
|
||||||
|
@TypeChecked(TypeCheckingMode.SKIP)
|
||||||
|
void testTypeVariables() {
|
||||||
|
int rate = 200
|
||||||
|
try {
|
||||||
|
rate = [12] //GroovyCastException
|
||||||
|
rate = "nill" //GroovyCastException
|
||||||
|
} catch(GroovyCastException) {
|
||||||
|
println "Cannot assign anything other than integer"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@TypeChecked(TypeCheckingMode.SKIP)
|
||||||
|
void testDefVariableMultipleAssignment() {
|
||||||
|
def rate
|
||||||
|
assert rate == null
|
||||||
|
assert rate.getClass() == org.codehaus.groovy.runtime.NullObject
|
||||||
|
|
||||||
|
rate = 12
|
||||||
|
assert rate instanceof Integer
|
||||||
|
|
||||||
|
rate = "Not Available"
|
||||||
|
assert rate instanceof String
|
||||||
|
|
||||||
|
rate = [1, 4]
|
||||||
|
assert rate instanceof List
|
||||||
|
|
||||||
|
assert divide(12, 3) instanceof BigDecimal
|
||||||
|
assert divide(1, 0) instanceof String
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
def divide(int x, int y) {
|
||||||
|
if(y==0) {
|
||||||
|
return "Should not divide by 0"
|
||||||
|
} else {
|
||||||
|
return x/y
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def greetMsg() {
|
||||||
|
println "Hello! I am Groovy"
|
||||||
|
}
|
||||||
|
|
||||||
|
void testDefVsType() {
|
||||||
|
def int count
|
||||||
|
assert count instanceof Integer
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package com.baeldung.strings
|
||||||
|
|
||||||
|
import spock.lang.Specification
|
||||||
|
|
||||||
|
import java.util.regex.Pattern
|
||||||
|
|
||||||
|
class StringMatchingSpec extends Specification {
|
||||||
|
|
||||||
|
def "pattern operator example"() {
|
||||||
|
given: "a pattern"
|
||||||
|
def p = ~'foo'
|
||||||
|
|
||||||
|
expect:
|
||||||
|
p instanceof Pattern
|
||||||
|
|
||||||
|
and: "you can use slash strings to avoid escaping of blackslash"
|
||||||
|
def digitPattern = ~/\d*/
|
||||||
|
digitPattern.matcher('4711').matches()
|
||||||
|
}
|
||||||
|
|
||||||
|
def "match operator example"() {
|
||||||
|
expect:
|
||||||
|
'foobar' ==~ /.*oba.*/
|
||||||
|
|
||||||
|
and: "matching is strict"
|
||||||
|
!('foobar' ==~ /foo/)
|
||||||
|
}
|
||||||
|
|
||||||
|
def "find operator example"() {
|
||||||
|
when: "using the find operator"
|
||||||
|
def matcher = 'foo and bar, baz and buz' =~ /(\w+) and (\w+)/
|
||||||
|
|
||||||
|
then: "will find groups"
|
||||||
|
matcher.size() == 2
|
||||||
|
|
||||||
|
and: "can access groups using array"
|
||||||
|
matcher[0][0] == 'foo and bar'
|
||||||
|
matcher[1][2] == 'buz'
|
||||||
|
|
||||||
|
and: "you can use it as a predicate"
|
||||||
|
'foobarbaz' =~ /bar/
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -8,6 +8,8 @@
|
|||||||
- [Types of Strings in Groovy](https://www.baeldung.com/groovy-strings)
|
- [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)
|
- [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)
|
- [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)
|
- [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)
|
- [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)
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package com.baeldung.strings
|
||||||
|
|
||||||
|
import spock.lang.Specification
|
||||||
|
|
||||||
|
import java.util.regex.Pattern
|
||||||
|
|
||||||
|
class StringMatchingSpec extends Specification {
|
||||||
|
|
||||||
|
def "pattern operator example"() {
|
||||||
|
given: "a pattern"
|
||||||
|
def p = ~'foo'
|
||||||
|
|
||||||
|
expect:
|
||||||
|
p instanceof Pattern
|
||||||
|
|
||||||
|
and: "you can use slash strings to avoid escaping of blackslash"
|
||||||
|
def digitPattern = ~/\d*/
|
||||||
|
digitPattern.matcher('4711').matches()
|
||||||
|
}
|
||||||
|
|
||||||
|
def "match operator example"() {
|
||||||
|
expect:
|
||||||
|
'foobar' ==~ /.*oba.*/
|
||||||
|
|
||||||
|
and: "matching is strict"
|
||||||
|
!('foobar' ==~ /foo/)
|
||||||
|
}
|
||||||
|
|
||||||
|
def "find operator example"() {
|
||||||
|
when: "using the find operator"
|
||||||
|
def matcher = 'foo and bar, baz and buz' =~ /(\w+) and (\w+)/
|
||||||
|
|
||||||
|
then: "will find groups"
|
||||||
|
matcher.size() == 2
|
||||||
|
|
||||||
|
and: "can access groups using array"
|
||||||
|
matcher[0][0] == 'foo and bar'
|
||||||
|
matcher[1][2] == 'buz'
|
||||||
|
|
||||||
|
and: "you can use it as a predicate"
|
||||||
|
'foobarbaz' =~ /bar/
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -6,3 +6,4 @@
|
|||||||
- [Java 11 Nest Based Access Control](https://www.baeldung.com/java-nest-based-access-control)
|
- [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)
|
- [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)
|
- [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>
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.guava</groupId>
|
||||||
|
<artifactId>guava</artifactId>
|
||||||
|
<version>${guava.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
@@ -31,6 +39,7 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.source.version>11</maven.compiler.source.version>
|
<maven.compiler.source.version>11</maven.compiler.source.version>
|
||||||
<maven.compiler.target.version>11</maven.compiler.target.version>
|
<maven.compiler.target.version>11</maven.compiler.target.version>
|
||||||
|
<guava.version>27.1-jre</guava.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</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>
|
<configuration>
|
||||||
<source>${maven.compiler.source.version}</source>
|
<source>${maven.compiler.source.version}</source>
|
||||||
<target>${maven.compiler.target.version}</target>
|
<target>${maven.compiler.target.version}</target>
|
||||||
|
<compilerArgs>--enable-preview</compilerArgs>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</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}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
=========
|
||||||
|
|
||||||
|
## Core Java 8 Cookbooks and Examples (part 2)
|
||||||
|
|
||||||
|
### Relevant Articles:
|
||||||
|
- [Anonymous Classes in Java](http://www.baeldung.com/)
|
||||||
@@ -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>
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
## Core Java 8 Cookbooks and Examples
|
## Core Java 8 Cookbooks and Examples
|
||||||
|
|
||||||
### Relevant Articles:
|
### 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)
|
- [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)
|
- [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)
|
- [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);
|
|
||||||
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user