commit
0909133437
|
@ -0,0 +1,3 @@
|
|||
### Relevant Articles:
|
||||
|
||||
- [AWS AppSync With Spring Boot](https://www.baeldung.com/aws-appsync-spring)
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-8-2</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>${project.parent.version}</version>
|
||||
<name>core-java-8-datetime</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>${project.parent.version}</version>
|
||||
<name>core-java-8-datetime</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-8</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-9-streams</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
<parent>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
|
|
@ -7,12 +7,11 @@
|
|||
<artifactId>core-java-collections-2</artifactId>
|
||||
<name>core-java-collections-2</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-collections-3</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-collections-array-list</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-collections-list-2</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-collections-list-3</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-collections-list</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -7,12 +7,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-collections-maps-2</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -7,12 +7,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-collections-maps-3</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -6,12 +6,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-collections-maps</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-collections-set</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-collections</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-concurrency-2</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-concurrency-advanced-2</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -12,4 +12,5 @@ This module contains articles about advanced topics about multithreading with co
|
|||
- [Asynchronous Programming in Java](https://www.baeldung.com/java-asynchronous-programming)
|
||||
- [Java Thread Deadlock and Livelock](https://www.baeldung.com/java-deadlock-livelock)
|
||||
- [Guide to AtomicStampedReference in Java](https://www.baeldung.com/java-atomicstampedreference)
|
||||
- [The ABA Problem in Concurrency](https://www.baeldung.com/cs/aba-concurrency)
|
||||
- [[<-- previous]](/core-java-modules/core-java-concurrency-advanced-2)
|
||||
|
|
|
@ -9,12 +9,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-concurrency-advanced-3</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-concurrency-advanced</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-concurrency-basic-2</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-concurrency-basic</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-concurrency-collections</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>${project.parent.version}</version>
|
||||
<name>core-java-date-operations-1</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>${project.parent.version}</version>
|
||||
<name>core-java-date-operations-2</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>${project.parent.version}</version>
|
||||
<name>core-java-datetime-conversion</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>${project.parent.version}</version>
|
||||
<name>core-java-datetime-string</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -7,12 +7,11 @@
|
|||
<artifactId>core-java-exceptions-2</artifactId>
|
||||
<name>core-java-exceptions-2</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -9,12 +9,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-exceptions</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-function</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-io-2</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-io-apis</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-io-conversions-2</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@ -22,6 +21,11 @@
|
|||
<artifactId>commons-lang3</artifactId>
|
||||
<version>${commons-lang3.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>20200518</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -0,0 +1,48 @@
|
|||
package com.baeldung.bufferedreadertojsonobject;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.json.JSONTokener;
|
||||
import org.junit.Test;
|
||||
|
||||
public class JavaBufferedReaderToJSONObjectUnitTest {
|
||||
|
||||
@Test
|
||||
public void givenValidJson_whenUsingBufferedReader_thenJSONTokenerConverts() {
|
||||
byte[] b = "{ \"name\" : \"John\", \"age\" : 18 }".getBytes(StandardCharsets.UTF_8);
|
||||
InputStream is = new ByteArrayInputStream(b);
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(is));
|
||||
JSONTokener tokener = new JSONTokener(bufferedReader);
|
||||
JSONObject json = new JSONObject(tokener);
|
||||
|
||||
assertNotNull(json);
|
||||
assertEquals("John", json.get("name"));
|
||||
assertEquals(18, json.get("age"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenValidJson_whenUsingString_thenJSONObjectConverts() throws IOException {
|
||||
byte[] b = "{ \"name\" : \"John\", \"age\" : 18 }".getBytes(StandardCharsets.UTF_8);
|
||||
InputStream is = new ByteArrayInputStream(b);
|
||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(is));
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String line;
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
sb.append(line);
|
||||
}
|
||||
JSONObject json = new JSONObject(sb.toString());
|
||||
|
||||
assertNotNull(json);
|
||||
assertEquals("John", json.get("name"));
|
||||
assertEquals(18, json.get("age"));
|
||||
}
|
||||
}
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-io-conversions</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-io</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-jar</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<parent>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<parent>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<modules>
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-modules</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<relativePath>../../</relativePath>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-lambdas</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,19 +8,23 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-lang-2</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.9</version>
|
||||
<version>${commons-lang3.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>${guava.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-beanutils</groupId>
|
||||
|
@ -65,6 +69,8 @@
|
|||
<jmh-generator.version>1.19</jmh-generator.version>
|
||||
<assertj.version>3.12.2</assertj.version>
|
||||
<commons.beanutils.version>1.9.4</commons.beanutils.version>
|
||||
<commons-lang3.version>3.10</commons-lang3.version>
|
||||
<guava.version>29.0-jre</guava.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
package com.baeldung.comparing;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Objects;
|
||||
|
||||
public class PersonWithEquals {
|
||||
private String firstName;
|
||||
private String lastName;
|
||||
private LocalDate birthDate;
|
||||
|
||||
public PersonWithEquals(String firstName, String lastName) {
|
||||
if (firstName == null || lastName == null) {
|
||||
throw new NullPointerException("Names can't be null");
|
||||
}
|
||||
this.firstName = firstName;
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
public PersonWithEquals(String firstName, String lastName, LocalDate birthDate) {
|
||||
this(firstName, lastName);
|
||||
|
||||
this.birthDate = birthDate;
|
||||
}
|
||||
|
||||
public String firstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public String lastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public LocalDate birthDate() {
|
||||
return birthDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
PersonWithEquals that = (PersonWithEquals) o;
|
||||
return firstName.equals(that.firstName) &&
|
||||
lastName.equals(that.lastName) &&
|
||||
Objects.equals(birthDate, that.birthDate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(firstName, lastName);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package com.baeldung.comparing;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Objects;
|
||||
|
||||
public class PersonWithEqualsAndComparable implements Comparable<PersonWithEqualsAndComparable> {
|
||||
private String firstName;
|
||||
private String lastName;
|
||||
private LocalDate birthDate;
|
||||
|
||||
public PersonWithEqualsAndComparable(String firstName, String lastName) {
|
||||
if (firstName == null || lastName == null) {
|
||||
throw new NullPointerException("Names can't be null");
|
||||
}
|
||||
this.firstName = firstName;
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
public PersonWithEqualsAndComparable(String firstName, String lastName, LocalDate birthDate) {
|
||||
this(firstName, lastName);
|
||||
|
||||
this.birthDate = birthDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
PersonWithEqualsAndComparable that = (PersonWithEqualsAndComparable) o;
|
||||
return firstName.equals(that.firstName) &&
|
||||
lastName.equals(that.lastName) &&
|
||||
Objects.equals(birthDate, that.birthDate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(firstName, lastName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(PersonWithEqualsAndComparable o) {
|
||||
int lastNamesComparison = this.lastName.compareTo(o.lastName);
|
||||
if (lastNamesComparison == 0) {
|
||||
int firstNamesComparison = this.firstName.compareTo(o.firstName);
|
||||
if (firstNamesComparison == 0) {
|
||||
if (this.birthDate != null && o.birthDate != null) {
|
||||
return this.birthDate.compareTo(o.birthDate);
|
||||
} else if (this.birthDate != null) {
|
||||
return 1;
|
||||
} else if (o.birthDate != null) {
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
return firstNamesComparison;
|
||||
}
|
||||
} else {
|
||||
return lastNamesComparison;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package com.baeldung.comparing;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Comparator;
|
||||
import java.util.Objects;
|
||||
|
||||
public class PersonWithEqualsAndComparableUsingComparator implements Comparable<PersonWithEqualsAndComparableUsingComparator> {
|
||||
private String firstName;
|
||||
private String lastName;
|
||||
private LocalDate birthDate;
|
||||
|
||||
public PersonWithEqualsAndComparableUsingComparator(String firstName, String lastName) {
|
||||
if (firstName == null || lastName == null) {
|
||||
throw new NullPointerException("Names can't be null");
|
||||
}
|
||||
this.firstName = firstName;
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
public PersonWithEqualsAndComparableUsingComparator(String firstName, String lastName, LocalDate birthDate) {
|
||||
this(firstName, lastName);
|
||||
|
||||
this.birthDate = birthDate;
|
||||
}
|
||||
|
||||
public String firstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public String lastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public LocalDate birthDate() {
|
||||
return birthDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
PersonWithEqualsAndComparableUsingComparator that = (PersonWithEqualsAndComparableUsingComparator) o;
|
||||
return firstName.equals(that.firstName) &&
|
||||
lastName.equals(that.lastName) &&
|
||||
Objects.equals(birthDate, that.birthDate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(firstName, lastName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(PersonWithEqualsAndComparableUsingComparator o) {
|
||||
return Comparator.comparing(PersonWithEqualsAndComparableUsingComparator::lastName)
|
||||
.thenComparing(PersonWithEqualsAndComparableUsingComparator::firstName)
|
||||
.thenComparing(PersonWithEqualsAndComparableUsingComparator::birthDate, Comparator.nullsLast(Comparator.naturalOrder()))
|
||||
.compare(this, o);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
package com.baeldung.comparing;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.Objects;
|
||||
|
||||
public class PersonWithEqualsAndWrongComparable implements Comparable<PersonWithEqualsAndWrongComparable> {
|
||||
private String firstName;
|
||||
private String lastName;
|
||||
private LocalDate birthDate;
|
||||
|
||||
public PersonWithEqualsAndWrongComparable(String firstName, String lastName) {
|
||||
if (firstName == null || lastName == null) {
|
||||
throw new NullPointerException("Names can't be null");
|
||||
}
|
||||
this.firstName = firstName;
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
public PersonWithEqualsAndWrongComparable(String firstName, String lastName, LocalDate birthDate) {
|
||||
this(firstName, lastName);
|
||||
|
||||
this.birthDate = birthDate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
PersonWithEqualsAndWrongComparable that = (PersonWithEqualsAndWrongComparable) o;
|
||||
return firstName.equals(that.firstName) &&
|
||||
lastName.equals(that.lastName) &&
|
||||
Objects.equals(birthDate, that.birthDate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(firstName, lastName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(PersonWithEqualsAndWrongComparable o) {
|
||||
return this.lastName.compareTo(o.lastName);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.baeldung.comparing;
|
||||
|
||||
public class PersonWithoutEquals {
|
||||
private String firstName;
|
||||
private String lastName;
|
||||
|
||||
public PersonWithoutEquals(String firstName, String lastName) {
|
||||
this.firstName = firstName;
|
||||
this.lastName = lastName;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package com.baeldung.inttoenum;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public enum PizzaStatus {
|
||||
ORDERED(5),
|
||||
READY(2),
|
||||
DELIVERED(0);
|
||||
|
||||
private int timeToDelivery;
|
||||
|
||||
PizzaStatus(int timeToDelivery) {
|
||||
this.timeToDelivery = timeToDelivery;
|
||||
}
|
||||
|
||||
public int getTimeToDelivery() {
|
||||
return timeToDelivery;
|
||||
}
|
||||
|
||||
private static Map<Integer, PizzaStatus> timeToDeliveryToEnumValuesMapping = new HashMap<>();
|
||||
|
||||
static {
|
||||
PizzaStatus[] pizzaStatuses = PizzaStatus.values();
|
||||
for (int pizzaStatusIndex = 0; pizzaStatusIndex < pizzaStatuses.length; pizzaStatusIndex++) {
|
||||
timeToDeliveryToEnumValuesMapping.put(
|
||||
pizzaStatuses[pizzaStatusIndex].getTimeToDelivery(),
|
||||
pizzaStatuses[pizzaStatusIndex]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public static PizzaStatus castIntToEnum(int timeToDelivery) {
|
||||
return timeToDeliveryToEnumValuesMapping.get(timeToDelivery);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,59 @@
|
|||
package com.baeldung.comparing;
|
||||
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class ApacheCommonsObjectUtilsUnitTest {
|
||||
|
||||
@Test
|
||||
void givenTwoStringsWithSameValues_whenApacheCommonsEqualityMethods_thenEqualsTrueNotEqualsFalse() {
|
||||
String a = new String("Hello!");
|
||||
String b = new String("Hello!");
|
||||
|
||||
assertThat(ObjectUtils.equals(a, b)).isTrue();
|
||||
assertThat(ObjectUtils.notEqual(a, b)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoStringsWithDifferentValues_whenApacheCommonsEqualityMethods_thenEqualsFalseNotEqualsTrue() {
|
||||
String a = new String("Hello!");
|
||||
String b = new String("Hello World!");
|
||||
|
||||
assertThat(ObjectUtils.equals(a, b)).isFalse();
|
||||
assertThat(ObjectUtils.notEqual(a, b)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoStringsWithConsecutiveValues_whenApacheCommonsCompare_thenNegative() {
|
||||
String first = new String("Hello!");
|
||||
String second = new String("How are you?");
|
||||
|
||||
assertThat(ObjectUtils.compare(first, second)).isNegative();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoStringsWithSameValues_whenApacheCommonsEqualityMethods_thenEqualsFalseNotEqualsTrue() {
|
||||
String first = new String("Hello!");
|
||||
String second = new String("Hello!");
|
||||
|
||||
assertThat(ObjectUtils.compare(first, second)).isZero();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoStringsWithConsecutiveValues_whenApacheCommonsCompareReversed_thenPositive() {
|
||||
String first = new String("Hello!");
|
||||
String second = new String("How are you?");
|
||||
|
||||
assertThat(ObjectUtils.compare(second, first)).isPositive();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoStringsOneNull_whenApacheCommonsCompare_thenPositive() {
|
||||
String first = new String("Hello!");
|
||||
String second = null;
|
||||
|
||||
assertThat(ObjectUtils.compare(first, second, false)).isPositive();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,107 @@
|
|||
package com.baeldung.comparing;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class ComparableInterfaceUnitTest {
|
||||
|
||||
@Test
|
||||
void givenTwoConsecutiveStrings_whenCompareTo_thenNegative() {
|
||||
String first = "Google";
|
||||
String second = "Microsoft";
|
||||
|
||||
assertThat(first.compareTo(second)).isNegative();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoEqualsStrings_whenCompareTo_thenZero() {
|
||||
String first = "Google";
|
||||
String second = "Google";
|
||||
|
||||
assertThat(first.compareTo(second)).isZero();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoConsecutiveStrings_whenReversedCompareTo_thenPositive() {
|
||||
String first = "Google";
|
||||
String second = "Microsoft";
|
||||
|
||||
assertThat(second.compareTo(first)).isPositive();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoPersonWithEqualsAndWrongComparableAndConsecutiveLastNames_whenCompareTo_thenNegative() {
|
||||
PersonWithEqualsAndWrongComparable richard = new PersonWithEqualsAndWrongComparable("Richard", "Jefferson");
|
||||
PersonWithEqualsAndWrongComparable joe = new PersonWithEqualsAndWrongComparable("Joe", "Portman");
|
||||
|
||||
assertThat(richard.compareTo(joe)).isNegative();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoPersonWithEqualsAndWrongComparableAndSameLastNames_whenReversedCompareTo_thenZero() {
|
||||
PersonWithEqualsAndWrongComparable richard = new PersonWithEqualsAndWrongComparable("Richard", "Jefferson");
|
||||
PersonWithEqualsAndWrongComparable mike = new PersonWithEqualsAndWrongComparable("Mike", "Jefferson");
|
||||
|
||||
assertThat(richard.compareTo(mike)).isZero();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoPersonWithEqualsAndWrongComparableAndConsecutiveLastNames_whenReversedCompareTo_thenPositive() {
|
||||
PersonWithEqualsAndWrongComparable richard = new PersonWithEqualsAndWrongComparable("Richard", "Jefferson");
|
||||
PersonWithEqualsAndWrongComparable joe = new PersonWithEqualsAndWrongComparable("Joe", "Portman");
|
||||
|
||||
assertThat(joe.compareTo(richard)).isPositive();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoPersonWithEqualsAndWrongComparableAndSameLastNames_whenSortedSet_thenProblem() {
|
||||
PersonWithEqualsAndWrongComparable richard = new PersonWithEqualsAndWrongComparable("Richard", "Jefferson");
|
||||
PersonWithEqualsAndWrongComparable mike = new PersonWithEqualsAndWrongComparable("Mike", "Jefferson");
|
||||
|
||||
SortedSet<PersonWithEqualsAndWrongComparable> people = new TreeSet<>();
|
||||
people.add(richard);
|
||||
people.add(mike);
|
||||
|
||||
assertThat(people).containsExactly(richard);
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoPersonWithEqualsAndComparableAndConsecutiveLastNames_whenCompareTo_thenNegative() {
|
||||
PersonWithEqualsAndComparable richard = new PersonWithEqualsAndComparable("Richard", "Jefferson");
|
||||
PersonWithEqualsAndComparable joe = new PersonWithEqualsAndComparable("Joe", "Portman");
|
||||
|
||||
assertThat(richard.compareTo(joe)).isNegative();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoPersonWithEqualsAndComparableAndSameLastNames_whenReversedCompareTo_thenZero() {
|
||||
PersonWithEqualsAndComparable richard = new PersonWithEqualsAndComparable("Richard", "Jefferson");
|
||||
PersonWithEqualsAndComparable mike = new PersonWithEqualsAndComparable("Mike", "Jefferson");
|
||||
|
||||
assertThat(richard.compareTo(mike)).isPositive();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoPersonWithEqualsAndComparableAndConsecutiveLastNames_whenReversedCompareTo_thenPositive() {
|
||||
PersonWithEqualsAndComparable richard = new PersonWithEqualsAndComparable("Richard", "Jefferson");
|
||||
PersonWithEqualsAndComparable joe = new PersonWithEqualsAndComparable("Joe", "Portman");
|
||||
|
||||
assertThat(joe.compareTo(richard)).isPositive();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoPersonWithEqualsAndComparableAndSameLastNames_whenSortedSet_thenProblem() {
|
||||
PersonWithEqualsAndComparable richard = new PersonWithEqualsAndComparable("Richard", "Jefferson");
|
||||
PersonWithEqualsAndComparable mike = new PersonWithEqualsAndComparable("Mike", "Jefferson");
|
||||
|
||||
SortedSet<PersonWithEqualsAndComparable> people = new TreeSet<>();
|
||||
people.add(richard);
|
||||
people.add(mike);
|
||||
|
||||
assertThat(people).containsExactly(mike, richard);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,81 @@
|
|||
package com.baeldung.comparing;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class ComparatorInterfaceUnitTest {
|
||||
|
||||
@Test
|
||||
void givenListOfTwoPersonWithEqualsAndComparatorByFirstName_whenSort_thenSortedByFirstNames() {
|
||||
PersonWithEquals joe = new PersonWithEquals("Joe", "Portman");
|
||||
PersonWithEquals allan = new PersonWithEquals("Allan", "Dale");
|
||||
|
||||
List<PersonWithEquals> people = new ArrayList<>();
|
||||
people.add(joe);
|
||||
people.add(allan);
|
||||
|
||||
Comparator<PersonWithEquals> compareByFirstNames = new Comparator<PersonWithEquals>() {
|
||||
@Override
|
||||
public int compare(PersonWithEquals o1, PersonWithEquals o2) {
|
||||
return o1.firstName().compareTo(o2.firstName());
|
||||
}
|
||||
};
|
||||
people.sort(compareByFirstNames);
|
||||
|
||||
assertThat(people).containsExactly(allan, joe);
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenListOfTwoPersonWithEqualsAndComparatorByFirstNameFunctionalStyle_whenSort_thenSortedByFirstNames() {
|
||||
PersonWithEquals joe = new PersonWithEquals("Joe", "Portman");
|
||||
PersonWithEquals allan = new PersonWithEquals("Allan", "Dale");
|
||||
|
||||
List<PersonWithEquals> people = new ArrayList<>();
|
||||
people.add(joe);
|
||||
people.add(allan);
|
||||
|
||||
Comparator<PersonWithEquals> compareByFirstNames = Comparator.comparing(PersonWithEquals::firstName);
|
||||
people.sort(compareByFirstNames);
|
||||
|
||||
assertThat(people).containsExactly(allan, joe);
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoPersonWithEqualsAndComparableUsingComparatorAndConsecutiveLastNames_whenCompareTo_thenNegative() {
|
||||
PersonWithEqualsAndComparableUsingComparator richard = new PersonWithEqualsAndComparableUsingComparator("Richard", "Jefferson");
|
||||
PersonWithEqualsAndComparableUsingComparator joe = new PersonWithEqualsAndComparableUsingComparator("Joe", "Portman");
|
||||
|
||||
assertThat(richard.compareTo(joe)).isNegative();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoPersonWithEqualsAndComparableUsingComparatorAndSameLastNames_whenReversedCompareTo_thenZero() {
|
||||
PersonWithEqualsAndComparableUsingComparator richard = new PersonWithEqualsAndComparableUsingComparator("Richard", "Jefferson");
|
||||
PersonWithEqualsAndComparableUsingComparator mike = new PersonWithEqualsAndComparableUsingComparator("Mike", "Jefferson");
|
||||
|
||||
assertThat(richard.compareTo(mike)).isPositive();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoPersonWithEqualsAndComparableUsingComparatorAndConsecutiveLastNames_whenReversedCompareTo_thenPositive() {
|
||||
PersonWithEqualsAndComparableUsingComparator richard = new PersonWithEqualsAndComparableUsingComparator("Richard", "Jefferson");
|
||||
PersonWithEqualsAndComparableUsingComparator joe = new PersonWithEqualsAndComparableUsingComparator("Joe", "Portman");
|
||||
|
||||
assertThat(joe.compareTo(richard)).isPositive();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoPersonWithEqualsAndComparableUsingComparatorAndSameLastNames_whenSortedSet_thenProblem() {
|
||||
PersonWithEqualsAndComparableUsingComparator richard = new PersonWithEqualsAndComparableUsingComparator("Richard", "Jefferson");
|
||||
PersonWithEqualsAndComparableUsingComparator mike = new PersonWithEqualsAndComparableUsingComparator("Mike", "Jefferson");
|
||||
|
||||
SortedSet<PersonWithEqualsAndComparableUsingComparator> people = new TreeSet<>();
|
||||
people.add(richard);
|
||||
people.add(mike);
|
||||
|
||||
assertThat(people).containsExactly(mike, richard);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,116 @@
|
|||
package com.baeldung.comparing;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class EqualityOperatorUnitTest {
|
||||
|
||||
@Test
|
||||
void givenTwoIntsWithSameValues_whenEqualityOperators_thenConsideredSame() {
|
||||
int a = 1;
|
||||
int b = 1;
|
||||
|
||||
assertThat(a == b).isTrue();
|
||||
assertThat(a != b).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoIntsWithDifferentValues_whenEqualityOperators_thenNotConsideredSame() {
|
||||
int a = 1;
|
||||
int b = 2;
|
||||
|
||||
assertThat(a == b).isFalse();
|
||||
assertThat(a != b).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoIntsWithSameValuesOneWrapped_whenEqualityOperators_thenConsideredSame() {
|
||||
int a = 1;
|
||||
Integer b = new Integer(1);
|
||||
|
||||
assertThat(a == b).isTrue();
|
||||
assertThat(a != b).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoIntsWithDifferentValuesOneWrapped_whenEqualityOperators_thenNotConsideredSame() {
|
||||
int a = 1;
|
||||
Integer b = new Integer(2);
|
||||
|
||||
assertThat(a == b).isFalse();
|
||||
assertThat(a != b).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoIntegersWithSameValues_whenEqualityOperators_thenNotConsideredSame() {
|
||||
Integer a = new Integer(1);
|
||||
Integer b = new Integer(1);
|
||||
|
||||
assertThat(a == b).isFalse();
|
||||
assertThat(a != b).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoIntegersWithDifferentValues_whenEqualityOperators_thenNotConsideredSame() {
|
||||
Integer a = new Integer(1);
|
||||
Integer b = new Integer(2);
|
||||
|
||||
assertThat(a == b).isFalse();
|
||||
assertThat(a != b).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoIntegersWithSameReference_whenEqualityOperators_thenConsideredSame() {
|
||||
Integer a = new Integer(1);
|
||||
Integer b = a;
|
||||
|
||||
assertThat(a == b).isTrue();
|
||||
assertThat(a != b).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoIntegersFromValueOfWithSameValues_whenEqualityOperators_thenConsideredSame() {
|
||||
Integer a = Integer.valueOf(1);
|
||||
Integer b = Integer.valueOf(1);
|
||||
|
||||
assertThat(a == b).isTrue();
|
||||
assertThat(a != b).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoStringsWithSameValues_whenEqualityOperators_thenNotConsideredSame() {
|
||||
String a = new String("Hello!");
|
||||
String b = new String("Hello!");
|
||||
|
||||
assertThat(a == b).isFalse();
|
||||
assertThat(a != b).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoStringsFromLiteralsWithSameValues_whenEqualityOperators_thenConsideredSame() {
|
||||
String a = "Hello!";
|
||||
String b = "Hello!";
|
||||
|
||||
assertThat(a == b).isTrue();
|
||||
assertThat(a != b).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoNullObjects_whenEqualityOperators_thenConsideredSame() {
|
||||
Object a = null;
|
||||
Object b = null;
|
||||
|
||||
assertThat(a == b).isTrue();
|
||||
assertThat(a != b).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoObjectsOneNull_whenEqualityOperators_thenNotConsideredSame() {
|
||||
Object a = null;
|
||||
Object b = "Hello!";
|
||||
|
||||
assertThat(a == b).isFalse();
|
||||
assertThat(a != b).isTrue();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package com.baeldung.comparing;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
class EqualsMethodUnitTest {
|
||||
|
||||
@Test
|
||||
void givenTwoIntegersWithSameValue_whenEquals_thenTrue() {
|
||||
Integer a = new Integer(1);
|
||||
Integer b = new Integer(1);
|
||||
|
||||
assertThat(a.equals(b)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoStringsWithSameValue_whenEquals_thenTrue() {
|
||||
String a = new String("Hello!");
|
||||
String b = new String("Hello!");
|
||||
|
||||
assertThat(a.equals(b)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoStringsWithDifferentValue_whenEquals_thenFalse() {
|
||||
String a = new String("Hello!");
|
||||
String b = new String("Hello World!");
|
||||
|
||||
assertThat(a.equals(b)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoObjectsFirstNull_whenEquals_thenNullPointerExceptionThrown() {
|
||||
Object a = null;
|
||||
Object b = new String("Hello!");
|
||||
|
||||
assertThrows(NullPointerException.class, () -> a.equals(b));
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoObjectsSecondNull_whenEquals_thenFalse() {
|
||||
Object a = new String("Hello!");
|
||||
Object b = null;
|
||||
|
||||
assertThat(a.equals(b)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoPersonWithoutEqualsWithSameNames_whenEquals_thenFalse() {
|
||||
PersonWithoutEquals joe = new PersonWithoutEquals("Joe", "Portman");
|
||||
PersonWithoutEquals joeAgain = new PersonWithoutEquals("Joe", "Portman");
|
||||
|
||||
assertThat(joe.equals(joeAgain)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoPersonWithEqualsWithSameNames_whenEquals_thenTrue() {
|
||||
PersonWithEquals joe = new PersonWithEquals("Joe", "Portman");
|
||||
PersonWithEquals joeAgain = new PersonWithEquals("Joe", "Portman");
|
||||
|
||||
assertThat(joe.equals(joeAgain)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoPersonWittEqualsWithDifferentNames_whenEquals_thenFalse() {
|
||||
PersonWithEquals joe = new PersonWithEquals("Joe", "Portman");
|
||||
PersonWithEquals natalie = new PersonWithEquals("Natalie", "Portman");
|
||||
|
||||
assertThat(joe.equals(natalie)).isFalse();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package com.baeldung.comparing;
|
||||
|
||||
import com.google.common.base.Objects;
|
||||
import com.google.common.collect.ComparisonChain;
|
||||
import com.google.common.primitives.Ints;
|
||||
import org.junit.jupiter.api.Nested;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class GuavaUnitTest {
|
||||
|
||||
@Nested
|
||||
class ObjectsEqualMethod {
|
||||
@Test
|
||||
void givenTwoStringsWithSameValues_whenObjectsEqualMethods_thenTrue() {
|
||||
String a = new String("Hello!");
|
||||
String b = new String("Hello!");
|
||||
|
||||
assertThat(Objects.equal(a, b)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoStringsWithDifferentValues_whenObjectsEqualMethods_thenFalse() {
|
||||
String a = new String("Hello!");
|
||||
String b = new String("Hello World!");
|
||||
|
||||
assertThat(Objects.equal(a, b)).isFalse();
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
class ComparisonMethods {
|
||||
@Test
|
||||
void givenTwoIntsWithConsecutiveValues_whenIntsCompareMethods_thenNegative() {
|
||||
int first = 1;
|
||||
int second = 2;
|
||||
assertThat(Ints.compare(first, second)).isNegative();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoIntsWithSameValues_whenIntsCompareMethods_thenZero() {
|
||||
int first = 1;
|
||||
int second = 1;
|
||||
|
||||
assertThat(Ints.compare(first, second)).isZero();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoIntsWithConsecutiveValues_whenIntsCompareMethodsReversed_thenNegative() {
|
||||
int first = 1;
|
||||
int second = 2;
|
||||
|
||||
assertThat(Ints.compare(second, first)).isPositive();
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
class ComparisonChainClass {
|
||||
@Test
|
||||
void givenTwoPersonWithEquals_whenComparisonChainByLastNameThenFirstName_thenSortedJoeFirstAndNatalieSecond() {
|
||||
PersonWithEquals natalie = new PersonWithEquals("Natalie", "Portman");
|
||||
PersonWithEquals joe = new PersonWithEquals("Joe", "Portman");
|
||||
|
||||
int comparisonResult = ComparisonChain.start()
|
||||
.compare(natalie.lastName(), joe.lastName())
|
||||
.compare(natalie.firstName(), joe.firstName())
|
||||
.result();
|
||||
|
||||
assertThat(comparisonResult).isPositive();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package com.baeldung.comparing;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class ObjectsEqualsStaticMethodUnitTest {
|
||||
|
||||
@Test
|
||||
void givenTwoPersonWithEqualsWithSameNames_whenObjectsEquals_thenTrue() {
|
||||
PersonWithEquals joe = new PersonWithEquals("Joe", "Portman");
|
||||
PersonWithEquals joeAgain = new PersonWithEquals("Joe", "Portman");
|
||||
|
||||
assertThat(Objects.equals(joe, joeAgain)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoPersonWithEqualsWithDifferentNames_whenObjectsEquals_thenFalse() {
|
||||
PersonWithEquals joe = new PersonWithEquals("Joe", "Portman");
|
||||
PersonWithEquals natalie = new PersonWithEquals("Natalie", "Portman");
|
||||
|
||||
assertThat(Objects.equals(joe, natalie)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoPersonWithEqualsFirstNull_whenObjectsEquals_thenFalse() {
|
||||
PersonWithEquals nobody = null;
|
||||
PersonWithEquals joe = new PersonWithEquals("Joe", "Portman");
|
||||
|
||||
assertThat(Objects.equals(nobody, joe)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoObjectsSecondtNull_whenObjectsEquals_thenFalse() {
|
||||
PersonWithEquals joe = new PersonWithEquals("Joe", "Portman");
|
||||
PersonWithEquals nobody = null;
|
||||
|
||||
assertThat(Objects.equals(joe, nobody)).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
void givenTwoObjectsNull_whenObjectsEquals_thenTrue() {
|
||||
PersonWithEquals nobody = null;
|
||||
PersonWithEquals nobodyAgain = null;
|
||||
|
||||
assertThat(Objects.equals(nobody, nobodyAgain)).isTrue();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.baeldung.inttoenum;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class IntToEnumUnitTest {
|
||||
|
||||
@Test
|
||||
public void whenIntToEnumUsingValuesMethod_thenReturnEnumObject() {
|
||||
int timeToDeliveryForOrderedPizzaStatus = 5;
|
||||
PizzaStatus[] pizzaStatuses = PizzaStatus.values();
|
||||
PizzaStatus pizzaOrderedStatus = null;
|
||||
for (int pizzaStatusIndex = 0; pizzaStatusIndex < pizzaStatuses.length; pizzaStatusIndex++) {
|
||||
if (pizzaStatuses[pizzaStatusIndex].getTimeToDelivery() == timeToDeliveryForOrderedPizzaStatus) {
|
||||
pizzaOrderedStatus = pizzaStatuses[pizzaStatusIndex];
|
||||
}
|
||||
}
|
||||
assertEquals(pizzaOrderedStatus, PizzaStatus.ORDERED);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenIntToEnumUsingMap_thenReturnEnumObject() {
|
||||
int timeToDeliveryForOrderedPizzaStatus = 5;
|
||||
assertEquals(PizzaStatus.castIntToEnum(timeToDeliveryForOrderedPizzaStatus), PizzaStatus.ORDERED);
|
||||
}
|
||||
}
|
|
@ -5,12 +5,11 @@
|
|||
<artifactId>core-java-lang-math-2</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>core-java-lang-math-2</name>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-lang-math</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package com.baeldung.supertype;
|
||||
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
public abstract class TypeReference<T> {
|
||||
|
||||
private final Type type;
|
||||
|
||||
public TypeReference() {
|
||||
Type superclass = getClass().getGenericSuperclass();
|
||||
type = ((ParameterizedType) superclass).getActualTypeArguments()[0];
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return type;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.baeldung.supertype;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.lang.reflect.ParameterizedType;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class TypeReferenceUnitTest {
|
||||
|
||||
@Test
|
||||
public void givenGenericToken_whenUsingSuperTypeToken_thenPreservesTheTypeInfo() {
|
||||
TypeReference<Map<String, Integer>> token = new TypeReference<Map<String, Integer>>() {};
|
||||
Type type = token.getType();
|
||||
|
||||
assertEquals("java.util.Map<java.lang.String, java.lang.Integer>", type.getTypeName());
|
||||
|
||||
Type[] typeArguments = ((ParameterizedType) type).getActualTypeArguments();
|
||||
assertEquals("java.lang.String", typeArguments[0].getTypeName());
|
||||
assertEquals("java.lang.Integer", typeArguments[1].getTypeName());
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<parent>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-lang-operators</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-lang-syntax-2</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-lang-syntax</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-lang</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -7,12 +7,11 @@
|
|||
<artifactId>core-java-networking-2</artifactId>
|
||||
<name>core-java-networking-2</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-networking</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-nio-2</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
</project>
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-nio</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
</project>
|
|
@ -12,7 +12,7 @@
|
|||
<parent>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-os</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-perf</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-reflection</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-regex</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-security-2</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-security</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>1.0</version>
|
||||
<name>core-java-streams-2</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-streams-3</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-streams</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-string-algorithms-2</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -7,12 +7,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
<name>core-java-string-algorithms-3</name>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
@ -31,8 +30,7 @@
|
|||
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter-api</artifactId>
|
||||
<version>${junit-jupiter-api.version}</version>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
@ -64,7 +62,6 @@
|
|||
<commons-lang3.version>3.8.1</commons-lang3.version>
|
||||
<assertj.version>3.6.1</assertj.version>
|
||||
<guava.version>28.1-jre</guava.version>
|
||||
<junit-jupiter-api.version>5.3.1</junit-jupiter-api.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-string-algorithms</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-string-apis</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
|
@ -8,12 +8,11 @@
|
|||
<version>0.1.0-SNAPSHOT</version>
|
||||
<name>core-java-string-conversions-2</name>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>parent-java</artifactId>
|
||||
<groupId>com.baeldung.core-java-modules</groupId>
|
||||
<artifactId>core-java-modules</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../parent-java</relativePath>
|
||||
<relativePath>../</relativePath>
|
||||
</parent>
|
||||
|
||||
<dependencies>
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue