Merge remote-tracking branch 'origin/BAEL-16646' into BAEL-16646

# Conflicts:
#	core-java-modules/core-java-datetime/README.md
#	core-java-modules/core-java-datetime/pom.xml
This commit is contained in:
Alessio Stalla
2019-10-04 21:48:47 +02:00
1032 changed files with 8131 additions and 2920 deletions

View File

@@ -1,3 +1,3 @@
### Relevant articles
- [Guide to Akka Streams](http://www.baeldung.com/akka-streams)
- [Guide to Akka Streams](https://www.baeldung.com/akka-streams)

View File

@@ -1,6 +1,6 @@
## Relevant articles:
- [Introduction to Jenetics Library](http://www.baeldung.com/jenetics)
- [Ant Colony Optimization](http://www.baeldung.com/java-ant-colony-optimization)
- [Introduction to Jenetics Library](https://www.baeldung.com/jenetics)
- [Ant Colony Optimization](https://www.baeldung.com/java-ant-colony-optimization)
- [Design a Genetic Algorithm in Java](https://www.baeldung.com/java-genetic-algorithm)
- [The Traveling Salesman Problem in Java](https://www.baeldung.com/java-simulated-annealing-for-traveling-salesman)

View File

@@ -1,10 +1,10 @@
## Relevant articles:
- [Dijkstra Algorithm in Java](https://www.baeldung.com/java-dijkstra)
- [Dijkstra Shortest Path Algorithm in Java](https://www.baeldung.com/java-dijkstra)
- [Introduction to Cobertura](https://www.baeldung.com/cobertura)
- [Test a Linked List for Cyclicity](https://www.baeldung.com/java-linked-list-cyclicity)
- [Introduction to JGraphT](https://www.baeldung.com/jgrapht)
- [A Maze Solver in Java](https://www.baeldung.com/java-solve-maze)
- [Create a Sudoku Solver in Java](https://www.baeldung.com/java-sudoku)
- [Displaying Money Amounts in Words](https://www.baeldung.com/java-money-into-words)
- [A Collaborative Filtering Recommendation System in Java](https://www.baeldung.com/java-collaborative-filtering-recommendations)
- [A Collaborative Filtering Recommendation System in Java](https://www.baeldung.com/java-collaborative-filtering-recommendations)

View File

@@ -2,9 +2,10 @@
- [Java Two Pointer Technique](https://www.baeldung.com/java-two-pointer-technique)
- [Implementing Simple State Machines with Java Enums](https://www.baeldung.com/java-enum-simple-state-machine)
- [Converting Between Roman and Arabic Numerals in Java](http://www.baeldung.com/java-convert-roman-arabic)
- [Practical Java Examples of the Big O Notation](http://www.baeldung.com/java-algorithm-complexity)
- [Converting Between Roman and Arabic Numerals in Java](https://www.baeldung.com/java-convert-roman-arabic)
- [Practical Java Examples of the Big O Notation](https://www.baeldung.com/java-algorithm-complexity)
- [Checking If a List Is Sorted in Java](https://www.baeldung.com/java-check-if-list-sorted)
- [Checking if a Java Graph has a Cycle](https://www.baeldung.com/java-graph-has-a-cycle)
- [A Guide to the Folding Technique in Java](https://www.baeldung.com/folding-hashing-technique)
- [Creating a Triangle with for Loops in Java](https://www.baeldung.com/java-print-triangle)
- [Efficient Word Frequency Calculator in Java](https://www.baeldung.com/java-word-frequency)

View File

@@ -54,6 +54,21 @@
<version>1.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
<version>${jmh-core.version}</version>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>${jmh-generator.version}</version>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-bytecode</artifactId>
<version>${jmh-generator.version}</version>
</dependency>
</dependencies>
<build>
@@ -73,5 +88,7 @@
<commons-collections4.version>4.3</commons-collections4.version>
<guava.version>28.0-jre</guava.version>
<retrofit.version>2.6.0</retrofit.version>
<jmh-core.version>1.19</jmh-core.version>
<jmh-generator.version>1.19</jmh-generator.version>
</properties>
</project>

View File

@@ -1,9 +1,10 @@
## Relevant articles:
- [Bubble Sort in Java](http://www.baeldung.com/java-bubble-sort)
- [Bubble Sort in Java](https://www.baeldung.com/java-bubble-sort)
- [Merge Sort in Java](https://www.baeldung.com/java-merge-sort)
- [Quicksort Algorithm Implementation in Java](https://www.baeldung.com/java-quicksort)
- [Insertion Sort in Java](https://www.baeldung.com/java-insertion-sort)
- [Heap Sort in Java](https://www.baeldung.com/java-heap-sort)
- [Shell Sort in Java](https://www.baeldung.com/java-shell-sort)
- [Counting Sort in Java](https://www.baeldung.com/java-counting-sort)
- [Sorting Strings by Contained Numbers in Java](https://www.baeldung.com/java-sort-strings-contained-numbers)

View File

@@ -1,3 +1,3 @@
## Relevant articles:
[Introduction to Animal Sniffer Maven Plugin](http://www.baeldung.com/maven-animal-sniffer)
[Introduction to Animal Sniffer Maven Plugin](https://www.baeldung.com/maven-animal-sniffer)

View File

@@ -1,2 +1,2 @@
### Relevant Articles:
- [Java Annotation Processing and Creating a Builder](http://www.baeldung.com/java-annotation-processing-builder)
- [Java Annotation Processing and Creating a Builder](https://www.baeldung.com/java-annotation-processing-builder)

View File

@@ -1,3 +1,3 @@
### Relevant Articles:
- [Java with ANTLR](http://www.baeldung.com/java-antlr)
- [Java with ANTLR](https://www.baeldung.com/java-antlr)

View File

@@ -1,2 +1,2 @@
### Relevant Articles:
- [Guide to Apache Avro](http://www.baeldung.com/java-apache-avro)
- [Guide to Apache Avro](https://www.baeldung.com/java-apache-avro)

View File

@@ -1,2 +1,2 @@
### Relevant Articles:
- [Intro to Apache BVal](http://www.baeldung.com/apache-bval)
- [Intro to Apache BVal](https://www.baeldung.com/apache-bval)

View File

@@ -1,3 +1,3 @@
### Relevant Articles:
- [Introduction to Apache Curator](http://www.baeldung.com/apache-curator)
- [Introduction to Apache Curator](https://www.baeldung.com/apache-curator)

View File

@@ -1,6 +1,6 @@
## Relevant Articles:
- [Introduction to Apache CXF Aegis Data Binding](http://www.baeldung.com/aegis-data-binding-in-apache-cxf)
- [Apache CXF Support for RESTful Web Services](http://www.baeldung.com/apache-cxf-rest-api)
- [A Guide to Apache CXF with Spring](http://www.baeldung.com/apache-cxf-with-spring)
- [Introduction to Apache CXF](http://www.baeldung.com/introduction-to-apache-cxf)
- [Introduction to Apache CXF Aegis Data Binding](https://www.baeldung.com/aegis-data-binding-in-apache-cxf)
- [Apache CXF Support for RESTful Web Services](https://www.baeldung.com/apache-cxf-rest-api)
- [A Guide to Apache CXF with Spring](https://www.baeldung.com/apache-cxf-with-spring)
- [Introduction to Apache CXF](https://www.baeldung.com/introduction-to-apache-cxf)
- [Server-Sent Events (SSE) In JAX-RS](https://www.baeldung.com/java-ee-jax-rs-sse)

View File

@@ -1,3 +1,3 @@
### Relevant Articles:
================================
- [Building a Microservice with Apache Meecrowave](http://www.baeldung.com/apache-meecrowave)
- [Building a Microservice with Apache Meecrowave](https://www.baeldung.com/apache-meecrowave)

View File

@@ -1,3 +1,4 @@
## Relevant articles:
- [OData Protocol Guide](https://www.baeldung.com/odata)
- [Intro to OData with Olingo](https://www.baeldung.com/olingo)

View File

@@ -1,3 +1,3 @@
### Relevant Articles
- [Intro to Apache OpenNLP](http://www.baeldung.com/apache-open-nlp)
- [Intro to Apache OpenNLP](https://www.baeldung.com/apache-open-nlp)

View File

@@ -1,4 +1,4 @@
### Relevant Articles:
- [Microsoft Word Processing in Java with Apache POI](http://www.baeldung.com/java-microsoft-word-with-apache-poi)
- [Working with Microsoft Excel in Java](http://www.baeldung.com/java-microsoft-excel)
- [Creating a MS PowerPoint Presentation in Java](http://www.baeldung.com/apache-poi-slideshow)
- [Microsoft Word Processing in Java with Apache POI](https://www.baeldung.com/java-microsoft-word-with-apache-poi)
- [Working with Microsoft Excel in Java](https://www.baeldung.com/java-microsoft-excel)
- [Creating a MS PowerPoint Presentation in Java](https://www.baeldung.com/apache-poi-slideshow)

View File

@@ -1,2 +1,2 @@
### Relevant articles
- [Introduction to Apache Shiro](http://www.baeldung.com/apache-shiro)
- [Introduction to Apache Shiro](https://www.baeldung.com/apache-shiro)

View File

@@ -1,4 +1,4 @@
## Apache Solrj Tutorials Project
### Relevant Articles
- [Guide to Solr in Java with Apache Solrj](http://www.baeldung.com/apache-solrj)
- [Guide to Solr in Java with Apache Solrj](https://www.baeldung.com/apache-solrj)

View File

@@ -1,4 +1,4 @@
### Relevant articles
- [Introduction to Apache Spark](http://www.baeldung.com/apache-spark)
- [Introduction to Apache Spark](https://www.baeldung.com/apache-spark)
- [Building a Data Pipeline with Kafka, Spark Streaming and Cassandra](https://www.baeldung.com/kafka-spark-data-pipeline)

View File

@@ -1,3 +1,3 @@
## Relevant articles:
- [Working with Apache Thrift](http://www.baeldung.com/apache-thrift)
- [Working with Apache Thrift](https://www.baeldung.com/apache-thrift)

View File

@@ -1,3 +1,3 @@
## Relevant articles:
- [Content Analysis with Apache Tika](http://www.baeldung.com/apache-tika)
- [Content Analysis with Apache Tika](https://www.baeldung.com/apache-tika)

View File

@@ -1,3 +1,3 @@
## Relevant articles:
- [Introduction to Apache Velocity](http://www.baeldung.com/apache-velocity)
- [Introduction to Apache Velocity](https://www.baeldung.com/apache-velocity)

View File

@@ -1,3 +1,3 @@
## Relevant articles:
- [Getting Started with Java and Zookeeper](http://www.baeldung.com/java-zookeeper)
- [Getting Started with Java and Zookeeper](https://www.baeldung.com/java-zookeeper)

View File

@@ -1,4 +1,4 @@
### Relevant articles
- [Generating a Book with Asciidoctor](http://www.baeldung.com/asciidoctor-book)
- [Introduction to Asciidoctor in Java](http://www.baeldung.com/asciidoctor)
- [Generating a Book with Asciidoctor](https://www.baeldung.com/asciidoctor-book)
- [Introduction to Asciidoctor in Java](https://www.baeldung.com/asciidoctor)

View File

@@ -1,3 +1,3 @@
### Relevant Articles:
- [A Guide to Java Bytecode Manipulation with ASM](http://www.baeldung.com/java-asm)
- [A Guide to Java Bytecode Manipulation with ASM](https://www.baeldung.com/java-asm)

View File

@@ -1,3 +1,3 @@
## Relevant articles:
- [Introduction to Atomix](http://www.baeldung.com/atomix)
- [Introduction to Atomix](https://www.baeldung.com/atomix)

View File

@@ -1,4 +1,4 @@
### Relevant Articles:
- [Introduction to AutoValue](http://www.baeldung.com/introduction-to-autovalue)
- [Introduction to AutoFactory](http://www.baeldung.com/autofactory)
- [Introduction to AutoValue](https://www.baeldung.com/introduction-to-autovalue)
- [Introduction to AutoFactory](https://www.baeldung.com/autofactory)
- [Google AutoService](https://www.baeldung.com/google-autoservice)

View File

@@ -1,3 +1,3 @@
### Relevant Articles:
- [Using AWS Lambda with API Gateway](http://www.baeldung.com/aws-lambda-api-gateway)
- [Introduction to AWS Serverless Application Model](http://www.baeldung.com/aws-serverless)
- [Using AWS Lambda with API Gateway](https://www.baeldung.com/aws-lambda-api-gateway)
- [Introduction to AWS Serverless Application Model](https://www.baeldung.com/aws-serverless)

View File

@@ -1,11 +1,11 @@
### Relevant articles
- [AWS Lambda Using DynamoDB With Java](http://www.baeldung.com/aws-lambda-dynamodb-java)
- [AWS S3 with Java](http://www.baeldung.com/aws-s3-java)
- [AWS Lambda With Java](http://www.baeldung.com/java-aws-lambda)
- [Managing EC2 Instances in Java](http://www.baeldung.com/ec2-java)
- [Multipart Uploads in Amazon S3 with Java](http://www.baeldung.com/aws-s3-multipart-upload)
- [Integration Testing with a Local DynamoDB Instance](http://www.baeldung.com/dynamodb-local-integration-tests)
- [Using the JetS3t Java Client With Amazon S3](http://www.baeldung.com/jets3t-amazon-s3)
- [Managing Amazon SQS Queues in Java](http://www.baeldung.com/aws-queues-java)
- [AWS Lambda Using DynamoDB With Java](https://www.baeldung.com/aws-lambda-dynamodb-java)
- [AWS S3 with Java](https://www.baeldung.com/aws-s3-java)
- [AWS Lambda With Java](https://www.baeldung.com/java-aws-lambda)
- [Managing EC2 Instances in Java](https://www.baeldung.com/ec2-java)
- [Multipart Uploads in Amazon S3 with Java](https://www.baeldung.com/aws-s3-multipart-upload)
- [Integration Testing with a Local DynamoDB Instance](https://www.baeldung.com/dynamodb-local-integration-tests)
- [Using the JetS3t Java Client With Amazon S3](https://www.baeldung.com/jets3t-amazon-s3)
- [Managing Amazon SQS Queues in Java](https://www.baeldung.com/aws-queues-java)
- [Guide to AWS Aurora RDS with Java](https://www.baeldung.com/aws-aurora-rds-java)

View File

@@ -1,3 +1,3 @@
### Relevant articles
- [A Guide to the Axon Framework](http://www.baeldung.com/axon-cqrs-event-sourcing)
- [A Guide to the Axon Framework](https://www.baeldung.com/axon-cqrs-event-sourcing)

View File

@@ -1,4 +1,4 @@
### Relevant Articles:
- [Deploy a Spring Boot App to Azure](http://www.baeldung.com/spring-boot-azure)
- [Deploy a Spring Boot App to Azure](https://www.baeldung.com/spring-boot-azure)

View File

@@ -1,5 +1,5 @@
### Relevant Articles:
- [Blade A Complete Guidebook](http://www.baeldung.com/blade)
- [Blade A Complete Guidebook](https://www.baeldung.com/blade)
Run Integration Tests with `mvn integration-test`

View File

@@ -1,2 +1,2 @@
### Relevant Articles:
- [Introduction to Bootique](http://www.baeldung.com/bootique)
- [Introduction to Bootique](https://www.baeldung.com/bootique)

View File

@@ -1,5 +1,5 @@
### Relevant Articles:
- [CDI Interceptor vs Spring AspectJ](http://www.baeldung.com/cdi-interceptor-vs-spring-aspectj)
- [An Introduction to CDI (Contexts and Dependency Injection) in Java](http://www.baeldung.com/java-ee-cdi)
- [CDI Interceptor vs Spring AspectJ](https://www.baeldung.com/cdi-interceptor-vs-spring-aspectj)
- [An Introduction to CDI (Contexts and Dependency Injection) in Java](https://www.baeldung.com/java-ee-cdi)
- [Introduction to the Event Notification Model in CDI 2.0](https://www.baeldung.com/cdi-event-notification)

View File

@@ -1,15 +1,16 @@
package com.baeldung.cdi.cdi2observers.application;
import com.baeldung.cdi.cdi2observers.events.ExampleEvent;
import javax.enterprise.inject.se.SeContainer;
import javax.enterprise.inject.se.SeContainerInitializer;
public class BootstrappingApplication {
public static void main(String... args) {
SeContainerInitializer containerInitializer = SeContainerInitializer.newInstance();
try (SeContainer container = containerInitializer.initialize()) {
container.getBeanManager().fireEvent(new ExampleEvent("Welcome to Baeldung!"));
}
}
}
package com.baeldung.cdi2observers.application;
import com.baeldung.cdi2observers.events.ExampleEvent;
import javax.enterprise.inject.se.SeContainer;
import javax.enterprise.inject.se.SeContainerInitializer;
public class BootstrappingApplication {
public static void main(String... args) {
SeContainerInitializer containerInitializer = SeContainerInitializer.newInstance();
try (SeContainer container = containerInitializer.initialize()) {
container.getBeanManager().fireEvent(new ExampleEvent("Welcome to Baeldung!"));
}
}
}

View File

@@ -1,14 +1,14 @@
package com.baeldung.cdi.cdi2observers.events;
public class ExampleEvent {
private final String eventMessage;
public ExampleEvent(String eventMessage) {
this.eventMessage = eventMessage;
}
public String getEventMessage() {
return eventMessage;
}
}
package com.baeldung.cdi2observers.events;
public class ExampleEvent {
private final String eventMessage;
public ExampleEvent(String eventMessage) {
this.eventMessage = eventMessage;
}
public String getEventMessage() {
return eventMessage;
}
}

View File

@@ -1,14 +1,14 @@
package com.baeldung.cdi.cdi2observers.events;
import javax.enterprise.event.Event;
import javax.inject.Inject;
public class ExampleEventSource {
@Inject
Event<ExampleEvent> exampleEvent;
public void fireEvent() {
exampleEvent.fireAsync(new ExampleEvent("Welcome to Baeldung!"));
}
}
package com.baeldung.cdi2observers.events;
import javax.enterprise.event.Event;
import javax.inject.Inject;
public class ExampleEventSource {
@Inject
Event<ExampleEvent> exampleEvent;
public void fireEvent() {
exampleEvent.fireAsync(new ExampleEvent("Welcome to Baeldung!"));
}
}

View File

@@ -1,12 +1,13 @@
package com.baeldung.cdi.cdi2observers.observers;
import com.baeldung.cdi.cdi2observers.events.ExampleEvent;
import javax.annotation.Priority;
import javax.enterprise.event.Observes;
public class AnotherExampleEventObserver {
public String onEvent(@Observes @Priority(2) ExampleEvent event) {
return event.getEventMessage();
}
}
package com.baeldung.cdi2observers.observers;
import com.baeldung.cdi2observers.events.ExampleEvent;
import javax.annotation.Priority;
import javax.enterprise.event.Observes;
public class AnotherExampleEventObserver {
public String onEvent(@Observes @Priority(2) ExampleEvent event) {
return event.getEventMessage();
}
}

View File

@@ -1,13 +1,13 @@
package com.baeldung.cdi.cdi2observers.observers;
import com.baeldung.cdi.cdi2observers.events.ExampleEvent;
import com.baeldung.cdi.cdi2observers.services.TextService;
import javax.annotation.Priority;
import javax.enterprise.event.Observes;
public class ExampleEventObserver {
public String onEvent(@Observes @Priority(1) ExampleEvent event, TextService textService) {
return textService.parseText(event.getEventMessage());
}
}
package com.baeldung.cdi2observers.observers;
import com.baeldung.cdi2observers.events.ExampleEvent;
import com.baeldung.cdi2observers.services.TextService;
import javax.annotation.Priority;
import javax.enterprise.event.Observes;
public class ExampleEventObserver {
public String onEvent(@Observes @Priority(1) ExampleEvent event, TextService textService) {
return textService.parseText(event.getEventMessage());
}
}

View File

@@ -1,8 +1,8 @@
package com.baeldung.cdi.cdi2observers.services;
public class TextService {
public String parseText(String text) {
return text.toUpperCase();
}
}
package com.baeldung.cdi2observers.services;
public class TextService {
public String parseText(String text) {
return text.toUpperCase();
}
}

View File

@@ -1,7 +1,8 @@
<beans xmlns="http://java.sun.com/xml/ns/javaee"
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/beans_1_2.xsd">
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
bean-discovery-mode="all">
<interceptors>
<class>com.baeldung.interceptor.AuditedInterceptor</class>
</interceptors>

View File

@@ -1,14 +1,15 @@
package com.baeldung.cdi.cdi2observers.tests;
import com.baeldung.cdi.cdi2observers.services.TextService;
import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Test;
public class TextServiceUnitTest {
@Test
public void givenTextServiceInstance_whenCalledparseText_thenCorrect() {
TextService textService = new TextService();
assertThat(textService.parseText("Baeldung")).isEqualTo("BAELDUNG");
}
}
package com.baeldung.test.cdi2observers.tests;
import com.baeldung.cdi2observers.services.TextService;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class TextServiceUnitTest {
@Test
public void givenTextServiceInstance_whenCalledparseText_thenCorrect() {
TextService textService = new TextService();
assertThat(textService.parseText("Baeldung")).isEqualTo("BAELDUNG");
}
}

View File

@@ -6,7 +6,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import org.junit.Test;
public class TimeLoggerFactoryUnitTest {
@Test
public void givenTimeLoggerFactory_whenCalledgetTimeLogger_thenOneAssertion() {
TimeLoggerFactory timeLoggerFactory = new TimeLoggerFactory();

View File

@@ -1,3 +1,3 @@
### Relevant articles
- [The Checker Framework Pluggable Type Systems for Java](http://www.baeldung.com/checker-framework)
- [The Checker Framework Pluggable Type Systems for Java](https://www.baeldung.com/checker-framework)

View File

@@ -2,10 +2,10 @@
## Relevant articles:
- [String Matching in Groovy](http://www.baeldung.com/)
- [Template Engines in Groovy](https://www.baeldung.com/groovy-template-engines)
- [Groovy def Keyword](https://www.baeldung.com/groovy-def-keyword)
- [Pattern Matching in Strings in Groovy](https://www.baeldung.com/groovy-pattern-matching)
- [Working with XML in Groovy](https://www.baeldung.com/groovy-xml)
- [Integrating Groovy into Java Applications](https://www.baeldung.com/groovy-java-applications)
- [Concatenate Strings with Groovy](https://www.baeldung.com/groovy-concatenate-strings)
- [Metaprogramming in Groovy](https://www.baeldung.com/groovy-metaprogramming)

View File

@@ -0,0 +1,17 @@
package com.baeldung.category;
class BaeldungCategory {
public static String capitalize(String self) {
String capitalizedStr = self;
if (self.size() > 0) {
capitalizedStr = self.substring(0, 1).toUpperCase() + self.substring(1);
}
return capitalizedStr
}
public static double toThePower(Number self, Number exponent) {
return Math.pow(self, exponent);
}
}

View File

@@ -0,0 +1,17 @@
package com.baeldung.category;
import groovy.lang.Category
@Category(Number)
class NumberCategory {
public Number cube() {
return this*this*this
}
public int divideWithRoundUp(BigDecimal divisor, boolean isRoundUp) {
def mathRound = isRoundUp ? BigDecimal.ROUND_UP : BigDecimal.ROUND_DOWN
return (int)new BigDecimal(this).divide(divisor, 0, mathRound)
}
}

View File

@@ -0,0 +1,101 @@
package com.baeldung.category
import groovy.time.*
import java.text.SimpleDateFormat
import groovy.xml.*
import groovy.xml.dom.*
import com.baeldung.category.BaeldungCategory
import com.baeldung.category.NumberCategory
class CategoryUnitTest extends GroovyTestCase {
void test_whenUsingTimeCategory_thenOperationOnDate() {
def jan_1_2019 = new Date("01/01/2019")
use (TimeCategory) {
assert jan_1_2019 + 10.seconds == new Date("01/01/2019 00:00:10")
assert jan_1_2019 + 20.minutes == new Date("01/01/2019 00:20:00")
assert jan_1_2019 + 2.hours == new Date("01/01/2019 02:00:00")
assert jan_1_2019 - 1.day == new Date("12/31/2018")
assert jan_1_2019 + 2.weeks == new Date("01/15/2019")
assert jan_1_2019 - 2.months == new Date("11/01/2018")
assert jan_1_2019 + 3.years == new Date("01/01/2022")
}
}
void test_whenUsingTimeCategory_thenOperationOnNumber() {
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy")
use (TimeCategory) {
assert sdf.format(5.days.from.now) == sdf.format(new Date() + 5.days)
sdf = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss")
assert sdf.format(10.minutes.from.now) == sdf.format(new Date() + 10.minutes)
assert sdf.format(2.hours.ago) == sdf.format(new Date() - 2.hours)
}
}
void test_whenUsingDOMCategory_thenOperationOnXML() {
def baeldungArticlesText = """
<articles>
<article core-java="true">
<title>An Intro to the Java Debug Interface (JDI)</title>
<desc>A quick and practical overview of Java Debug Interface.</desc>
</article>
<article core-java="false">
<title>A Quick Guide to Working with Web Services in Groovy</title>
<desc>Learn how to work with Web Services in Groovy.</desc>
</article>
</articles>
"""
def baeldungArticlesDom = DOMBuilder.newInstance().parseText(baeldungArticlesText)
def root = baeldungArticlesDom.documentElement
use (DOMCategory) {
assert root.article.size() == 2
def articles = root.article
assert articles[0].title.text() == "An Intro to the Java Debug Interface (JDI)"
assert articles[1].desc.text() == "Learn how to work with Web Services in Groovy."
def articleNode3 = root.appendNode(new QName("article"), ["core-java": "false"])
articleNode3.appendNode("title", "Metaprogramming in Groovy")
articleNode3.appendNode("desc", "Explore the concept of runtime and compile-time metaprogramming in Groovy")
assert root.article.size() == 3
assert root.article[2].title.text() == "Metaprogramming in Groovy"
}
}
void test_whenUsingBaeldungCategory_thenCapitalizeString() {
use (BaeldungCategory) {
assert "norman".capitalize() == "Norman"
}
}
void test_whenUsingBaeldungCategory_thenOperationsOnNumber() {
use (BaeldungCategory) {
assert 50.toThePower(2) == 2500
assert 2.4.toThePower(4) == 33.1776
}
}
void test_whenUsingNumberCategory_thenOperationsOnNumber() {
use (NumberCategory) {
assert 3.cube() == 27
assert 25.divideWithRoundUp(6, true) == 5
assert 120.23.divideWithRoundUp(6.1, true) == 20
assert 150.9.divideWithRoundUp(12.1, false) == 12
}
}
}

View File

@@ -2,8 +2,8 @@
## Relevant articles:
- [JDBC with Groovy](http://www.baeldung.com/jdbc-groovy)
- [Working with JSON in Groovy](http://www.baeldung.com/groovy-json)
- [JDBC with Groovy](https://www.baeldung.com/jdbc-groovy)
- [Working with JSON in Groovy](https://www.baeldung.com/groovy-json)
- [Reading a File in Groovy](https://www.baeldung.com/groovy-file-read)
- [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)
@@ -12,4 +12,4 @@
- [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)

View File

@@ -5,6 +5,6 @@
### Relevant Articles:
- [Anonymous Classes in Java](http://www.baeldung.com/)
- [How to Delay Code Execution in Java](https://www.baeldung.com/java-delay-code-execution)
- [Run JAR Application With Command Line Arguments](https://www.baeldung.com/java-run-jar-with-arguments)
- [Run a Java Application from the Command Line](https://www.baeldung.com/java-run-jar-with-arguments)
- [Java 8 Stream skip() vs limit()](https://www.baeldung.com/java-stream-skip-vs-limit)
- [Guide to Java BiFunction Interface](https://www.baeldung.com/java-bifunction-interface)

View File

@@ -3,35 +3,12 @@
## Core Java 8 Cookbooks and Examples
### Relevant Articles:
- [Guide to Java 8s Collectors](http://www.baeldung.com/java-8-collectors)
- [New Features in Java 8](http://www.baeldung.com/java-8-new-features)
- [The Double Colon Operator in Java 8](http://www.baeldung.com/java-8-double-colon-operator)
- [Guide to Java 8 groupingBy Collector](http://www.baeldung.com/java-groupingby-collector)
- [Strategy Design Pattern in Java 8](http://www.baeldung.com/java-strategy-pattern)
- [Guide to Java 8 Comparator.comparing()](http://www.baeldung.com/java-8-comparator-comparing)
- [Guide To Java 8 Optional](http://www.baeldung.com/java-optional)
- [Guide to the Java 8 forEach](http://www.baeldung.com/foreach-java)
- [The Difference Between map() and flatMap()](http://www.baeldung.com/java-difference-map-and-flatmap)
- [Static and Default Methods in Interfaces in Java](http://www.baeldung.com/java-static-default-methods)
- [Efficient Word Frequency Calculator in Java](http://www.baeldung.com/java-word-frequency)
- [Introduction to Spliterator in Java](http://www.baeldung.com/java-spliterator)
- [Java 8 Math New Methods](http://www.baeldung.com/java-8-math)
- [Overview of Java Built-in Annotations](http://www.baeldung.com/java-default-annotations)
- [Finding Min/Max in an Array with Java](http://www.baeldung.com/java-array-min-max)
- [Internationalization and Localization in Java 8](http://www.baeldung.com/java-8-localization)
- [Java Optional orElse() vs orElseGet()](http://www.baeldung.com/java-optional-or-else-vs-or-else-get)
- [Java 8 Unsigned Arithmetic Support](http://www.baeldung.com/java-unsigned-arithmetic)
- [Generalized Target-Type Inference in Java](http://www.baeldung.com/java-generalized-target-type-inference)
- [Overriding System Time for Testing in Java](http://www.baeldung.com/java-override-system-time)
- [Set the Time Zone of a Date in Java](https://www.baeldung.com/java-set-date-time-zone)
- [An Overview of Regular Expressions Performance in Java](https://www.baeldung.com/java-regex-performance)
- [Java Primitives versus Objects](https://www.baeldung.com/java-primitives-vs-objects)
- [How to Use if/else Logic in Java 8 Streams](https://www.baeldung.com/java-8-streams-if-else-logic)
- [How to Replace Many if Statements in Java](https://www.baeldung.com/java-replace-if-statements)
- [Java @Override Annotation](https://www.baeldung.com/java-override)
- [Java @SuppressWarnings Annotation](https://www.baeldung.com/java-suppresswarnings)
- [Java @SafeVarargs Annotation](https://www.baeldung.com/java-safevarargs)
- [Java @Deprecated Annotation](https://www.baeldung.com/java-deprecated)
- [Java 8 Predicate Chain](https://www.baeldung.com/java-predicate-chain)
- [Creating a Custom Annotation in Java](https://www.baeldung.com/java-custom-annotation)
- [The Difference Between Collection.stream().forEach() and Collection.forEach()](https://www.baeldung.com/java-collection-stream-foreach)
- [New Features in Java 8](https://www.baeldung.com/java-8-new-features)
- [Guide to Java 8 groupingBy Collector](https://www.baeldung.com/java-groupingby-collector)
- [Strategy Design Pattern in Java 8](https://www.baeldung.com/java-strategy-pattern)
- [Guide to Java 8 Comparator.comparing()](https://www.baeldung.com/java-8-comparator-comparing)
- [Guide to the Java 8 forEach](https://www.baeldung.com/foreach-java)
- [Introduction to Spliterator in Java](https://www.baeldung.com/java-spliterator)
- [Finding Min/Max in an Array with Java](https://www.baeldung.com/java-array-min-max)
- [Internationalization and Localization in Java 8](https://www.baeldung.com/java-8-localization)
- [Generalized Target-Type Inference in Java](https://www.baeldung.com/java-generalized-target-type-inference)

View File

@@ -116,12 +116,6 @@
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jmockit</groupId>
<artifactId>jmockit</artifactId>
<version>${jmockit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
@@ -150,16 +144,6 @@
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven-surefire-plugin.version}</version>
<configuration>
<argLine>
-javaagent:${settings.localRepository}/org/jmockit/jmockit/${jmockit.version}/jmockit-${jmockit.version}.jar
</argLine>
<disableXmlReport>true</disableXmlReport>
</configuration>
</plugin>
</plugins>
</build>
@@ -176,7 +160,6 @@
<assertj.version>3.6.1</assertj.version>
<asspectj.version>1.8.9</asspectj.version>
<powermock.version>2.0.0-RC.4</powermock.version>
<jmockit.version>1.44</jmockit.version>
<avaitility.version>1.7.0</avaitility.version>
<jmh-core.version>1.19</jmh-core.version>
<jmh-generator.version>1.19</jmh-generator.version>

View File

@@ -0,0 +1,11 @@
=========
## Core Java 8 Cookbooks and Examples
### Relevant Articles:
- [Java @Override Annotation](https://www.baeldung.com/java-override)
- [Java @SuppressWarnings Annotation](https://www.baeldung.com/java-suppresswarnings)
- [Java @SafeVarargs Annotation](https://www.baeldung.com/java-safevarargs)
- [Java @Deprecated Annotation](https://www.baeldung.com/java-deprecated)
- [Overview of Java Built-in Annotations](https://www.baeldung.com/java-default-annotations)
- [Creating a Custom Annotation in Java](https://www.baeldung.com/java-custom-annotation)

View File

@@ -0,0 +1,72 @@
<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-annotations</artifactId>
<version>0.1.0-SNAPSHOT</version>
<name>core-java-annotations</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-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
<!-- test scoped -->
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>${assertj.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
<version>${jmh-core.version}</version>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
<version>${jmh-generator.version}</version>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-bytecode</artifactId>
<version>${jmh-generator.version}</version>
</dependency>
</dependencies>
<build>
<finalName>core-java-annotations</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<properties>
<!-- testing -->
<assertj.version>3.6.1</assertj.version>
<asspectj.version>1.8.9</asspectj.version>
<jmh-core.version>1.19</jmh-core.version>
<jmh-generator.version>1.19</jmh-generator.version>
<!-- plugins -->
<maven-surefire-plugin.version>2.22.1</maven-surefire-plugin.version>
</properties>
</project>

View File

@@ -1,25 +0,0 @@
*.class
0.*
#folders#
/target
/neoDb*
/data
/src/main/webapp/WEB-INF/classes
*/META-INF/*
.resourceCache
# Packaged files #
*.jar
*.war
*.ear
# Files generated by integration tests
backup-pom.xml
/bin/
/temp
#IntelliJ specific
.idea/
*.iml

View File

@@ -1,5 +1,10 @@
## Relevant Articles
- [Extending an Arrays Length](https://www.baeldung.com/java-array-add-element-at-the-end)
- [Checking If an Array Is Sorted in Java](https://www.baeldung.com/java-check-sorted-array)
- [Looping Diagonally Through a 2d Java Array](https://www.baeldung.com/java-loop-diagonal-array)
- [Converting Between Stream and Array in Java](https://www.baeldung.com/java-stream-to-array)
- [Convert a Float to a Byte Array in Java](https://www.baeldung.com/java-convert-float-to-byte-array)
- [Array Operations in Java](https://www.baeldung.com/java-common-array-operations)
- [Intersection Between two Integer Arrays](https://www.baeldung.com/java-array-intersection)
- [Removing an Element from an Array in Java](https://www.baeldung.com/java-array-remove-element)
- [Removing the First Element of an Array](https://www.baeldung.com/java-array-remove-first-element)

View File

@@ -1,19 +1,14 @@
package com.baeldung.array.operations;
import org.apache.commons.lang3.ArrayUtils;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.Random;
import java.util.Set;
import java.util.*;
import java.util.function.Function;
import java.util.function.IntPredicate;
import java.util.function.Predicate;
import java.util.stream.Stream;
import org.apache.commons.lang3.ArrayUtils;
public class ArrayOperations {
// Get the first and last item of an array

View File

@@ -1,13 +1,10 @@
package com.baeldung.array;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.apache.commons.lang3.ArrayUtils;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class RemoveElementFromAnArrayUnitTest {
private final RemoveElementFromAnArray sut = new RemoveElementFromAnArray();

View File

@@ -1,12 +1,10 @@
package com.baeldung.array.conversions;
import static com.baeldung.array.conversions.FloatToByteArray.byteArrayToFloat;
import static com.baeldung.array.conversions.FloatToByteArray.byteArrayToFloatWithByteBuffer;
import static com.baeldung.array.conversions.FloatToByteArray.floatToByteArray;
import static com.baeldung.array.conversions.FloatToByteArray.floatToByteArrayWithByteBuffer;
import org.junit.Test;
import static com.baeldung.array.conversions.FloatToByteArray.*;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
public class FloatToByteArrayUnitTest {

View File

@@ -1,13 +1,13 @@
package com.baeldung.array.operations;
import static org.assertj.core.api.Assertions.assertThat;
import java.util.Arrays;
import org.assertj.core.api.Condition;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.Arrays;
import static org.assertj.core.api.Assertions.assertThat;
public class ArrayOperationsUnitTest {
private Integer[] defaultObjectArray;

View File

@@ -2,9 +2,7 @@ package com.baeldung.array.operations;
import org.junit.jupiter.api.Test;
import static com.baeldung.array.operations.ArrayOperations.intersectionMultiSet;
import static com.baeldung.array.operations.ArrayOperations.intersectionSet;
import static com.baeldung.array.operations.ArrayOperations.intersectionSimple;
import static com.baeldung.array.operations.ArrayOperations.*;
import static org.assertj.core.api.Assertions.assertThat;
class IntersectionUnitTest {

View File

@@ -1,4 +1,4 @@
package com.baeldung.list.removefirst;
package com.baeldung.array.removefirst;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;

View File

@@ -1,25 +0,0 @@
*.class
0.*
#folders#
/target
/neoDb*
/data
/src/main/webapp/WEB-INF/classes
*/META-INF/*
.resourceCache
# Packaged files #
*.jar
*.war
*.ear
# Files generated by integration tests
backup-pom.xml
/bin/
/temp
#IntelliJ specific
.idea/
*.iml

View File

@@ -3,17 +3,14 @@
## Core Java Arrays Cookbooks and Examples
### Relevant Articles:
- [How to Copy an Array in Java](http://www.baeldung.com/java-array-copy)
- [Check if a Java Array Contains a Value](http://www.baeldung.com/java-array-contains-value)
- [Initializing Arrays in Java](http://www.baeldung.com/java-initialize-array)
- [Guide to the java.util.Arrays Class](http://www.baeldung.com/java-util-arrays)
- [Multi-Dimensional Arrays In Java](http://www.baeldung.com/java-jagged-arrays)
- [Find Sum and Average in a Java Array](http://www.baeldung.com/java-array-sum-average)
- [How to Copy an Array in Java](https://www.baeldung.com/java-array-copy)
- [Check if a Java Array Contains a Value](https://www.baeldung.com/java-array-contains-value)
- [Initializing Arrays in Java](https://www.baeldung.com/java-initialize-array)
- [Guide to the java.util.Arrays Class](https://www.baeldung.com/java-util-arrays)
- [Multi-Dimensional Arrays In Java](https://www.baeldung.com/java-jagged-arrays)
- [Find Sum and Average in a Java Array](https://www.baeldung.com/java-array-sum-average)
- [Arrays in Java: A Reference Guide](https://www.baeldung.com/java-arrays-guide)
- [How to Invert an Array in Java](http://www.baeldung.com/java-invert-array)
- [Array Operations in Java](http://www.baeldung.com/java-common-array-operations)
- [Intersection Between two Integer Arrays](https://www.baeldung.com/java-array-intersection)
- [Read and Write User Input in Java](https://www.baeldung.com/java-console-input-output)
- [How to Reverse an Array in Java](http://www.baeldung.com/java-invert-array)
- [Sorting Arrays in Java](https://www.baeldung.com/java-sorting-arrays)
- [Convert a Float to a Byte Array in Java](https://www.baeldung.com/java-convert-float-to-byte-array)
- [Converting Between Stream and Array in Java](https://www.baeldung.com/java-stream-to-array)
- [Removing an Element from an Array in Java](https://www.baeldung.com/java-array-remove-element)
- [Checking If an Array Is Sorted in Java](https://www.baeldung.com/java-check-sorted-array)

View File

@@ -0,0 +1,15 @@
=========
## Core Java Collections Cookbooks and Examples
### Relevant Articles:
- [Removing Elements from Java Collections](https://www.baeldung.com/java-collection-remove-elements)
- [How to Filter a Collection in Java](https://www.baeldung.com/java-collection-filtering)
- [Join and Split Arrays and Collections in Java](https://www.baeldung.com/java-join-and-split)
- [Java Combine Multiple Collections](https://www.baeldung.com/java-combine-multiple-collections)
- [Combining Different Types of Collections in Java](https://www.baeldung.com/java-combine-collections)
- [Shuffling Collections In Java](https://www.baeldung.com/java-shuffle-collection)
- [Sorting in Java](https://www.baeldung.com/java-sorting)
- [Getting the Size of an Iterable in Java](https://www.baeldung.com/java-iterable-size)
- [Java Null-Safe Streams from Collections](https://www.baeldung.com/java-null-safe-streams-from-collections)

View File

@@ -0,0 +1,58 @@
<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-2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>core-java-collections-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>
<dependencies>
<dependency>
<groupId>org.eclipse.collections</groupId>
<artifactId>eclipse-collections</artifactId>
<version>${eclipse.collections.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>${commons-collections4.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-exec</artifactId>
<version>${commons-exec.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.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>
</dependencies>
<properties>
<eclipse.collections.version>7.1.0</eclipse.collections.version>
<commons-collections4.version>4.1</commons-collections4.version>
<assertj.version>3.11.1</assertj.version>
<junit.platform.version>1.2.0</junit.platform.version>
<commons-exec.version>1.3</commons-exec.version>
</properties>
</project>

View File

@@ -1,4 +1,4 @@
package com.baeldung.combiningcollections;
package com.baeldung.collections.combiningcollections;
import java.util.Arrays;
import java.util.stream.Stream;

View File

@@ -1,4 +1,4 @@
package com.baeldung.combiningcollections;
package com.baeldung.collections.combiningcollections;
import java.util.ArrayList;
import java.util.Collection;

View File

@@ -1,4 +1,4 @@
package com.baeldung.combiningcollections;
package com.baeldung.collections.combiningcollections;
import java.util.Collection;
import java.util.HashMap;

View File

@@ -1,4 +1,4 @@
package com.baeldung.combiningcollections;
package com.baeldung.collections.combiningcollections;
import java.util.Collection;
import java.util.HashSet;

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