Merge branch 'master' of https://github.com/eugenp/tutorials into BAEL-4883

This commit is contained in:
Nguyen Nam Thai 2021-08-07 01:30:19 +07:00
commit fa7fa84eba
197 changed files with 2173 additions and 535 deletions

View File

@ -20,19 +20,16 @@
<version>${org.assertj.core.version}</version> <version>${org.assertj.core.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId> <artifactId>commons-collections4</artifactId>
<version>${commons-collections4.version}</version> <version>${commons-collections4.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.google.guava</groupId> <groupId>com.google.guava</groupId>
<artifactId>guava</artifactId> <artifactId>guava</artifactId>
<version>${guava.version}</version> <version>${guava.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.squareup.retrofit2</groupId> <groupId>com.squareup.retrofit2</groupId>
<artifactId>retrofit</artifactId> <artifactId>retrofit</artifactId>
@ -43,13 +40,11 @@
<artifactId>converter-jackson</artifactId> <artifactId>converter-jackson</artifactId>
<version>${retrofit.version}</version> <version>${retrofit.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId> <artifactId>commons-lang3</artifactId>
<version>${commons.lang3.version}</version> <version>${commons.lang3.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>pl.pragmatists</groupId> <groupId>pl.pragmatists</groupId>
<artifactId>JUnitParams</artifactId> <artifactId>JUnitParams</artifactId>

View File

@ -39,7 +39,6 @@
<artifactId>junit-platform-commons</artifactId> <artifactId>junit-platform-commons</artifactId>
<version>${junit.platform.version}</version> <version>${junit.platform.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.assertj</groupId> <groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId> <artifactId>assertj-core</artifactId>

View File

@ -14,7 +14,6 @@
</parent> </parent>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>javax.ws.rs</groupId> <groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId> <artifactId>javax.ws.rs-api</artifactId>
@ -33,7 +32,6 @@
<version>${bind-api.version}</version> <version>${bind-api.version}</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -183,7 +183,6 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<!-- meecrowave --> <!-- meecrowave -->
<plugin> <plugin>
<groupId>org.apache.meecrowave</groupId> <groupId>org.apache.meecrowave</groupId>

View File

@ -25,4 +25,5 @@
<geode.core>1.6.0</geode.core> <geode.core>1.6.0</geode.core>
<rocketmq.version>2.0.4</rocketmq.version> <rocketmq.version>2.0.4</rocketmq.version>
</properties> </properties>
</project> </project>

View File

@ -91,7 +91,7 @@
</plugins> </plugins>
</build> </build>
<repositories> <repositories>
<repository> <repository>
<id>SparkPackagesRepo</id> <id>SparkPackagesRepo</id>
<url>https://repos.spark-packages.org</url> <url>https://repos.spark-packages.org</url>

View File

@ -77,7 +77,6 @@
<optimize>true</optimize> <optimize>true</optimize>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
@ -88,7 +87,6 @@
</systemPropertyVariables> </systemPropertyVariables>
</configuration> </configuration>
</plugin> </plugin>
<!-- Run the application using "mvn jetty:run" --> <!-- Run the application using "mvn jetty:run" -->
<plugin> <plugin>
<groupId>org.mortbay.jetty</groupId> <groupId>org.mortbay.jetty</groupId>
@ -119,7 +117,6 @@
<id>jboss</id> <id>jboss</id>
<url>http://repository.jboss.org/nexus/content/groups/public/</url> <url>http://repository.jboss.org/nexus/content/groups/public/</url>
</repository> </repository>
<!-- This repository is only needed when the Tapestry version is a preview release, rather than <!-- This repository is only needed when the Tapestry version is a preview release, rather than
a final release. --> a final release. -->
<repository> <repository>

View File

@ -1,4 +1,5 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>helloworld</groupId> <groupId>helloworld</groupId>
@ -6,10 +7,6 @@
<version>1.0</version> <version>1.0</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>ToDoFunction</name> <name>ToDoFunction</name>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies> <dependencies>
<dependency> <dependency>
@ -18,9 +15,9 @@
<version>1.2.1</version> <version>1.2.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.amazonaws</groupId> <groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-events</artifactId> <artifactId>aws-lambda-java-events</artifactId>
<version>3.6.0</version> <version>3.6.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>uk.org.webcompere</groupId> <groupId>uk.org.webcompere</groupId>
@ -58,10 +55,10 @@
<version>5.0.1</version> <version>5.0.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
<version>4.13.1</version> <version>4.13.1</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>uk.org.webcompere</groupId> <groupId>uk.org.webcompere</groupId>
@ -84,22 +81,28 @@
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId> <artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version> <version>3.2.4</version>
<configuration> <configuration>
</configuration> </configuration>
<executions> <executions>
<execution> <execution>
<phase>package</phase> <phase>package</phase>
<goals> <goals>
<goal>shade</goal> <goal>shade</goal>
</goals> </goals>
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
</project> </project>

View File

@ -93,4 +93,5 @@
<spring.version>2.2.1.RELEASE</spring.version> <spring.version>2.2.1.RELEASE</spring.version>
<awssdk.version>2.10.27</awssdk.version> <awssdk.version>2.10.27</awssdk.version>
</properties> </properties>
</project> </project>

View File

@ -83,7 +83,6 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin> <plugin>
<artifactId>maven-assembly-plugin</artifactId> <artifactId>maven-assembly-plugin</artifactId>
<version>${assembly.plugin.version}</version> <version>${assembly.plugin.version}</version>

View File

@ -48,13 +48,11 @@
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId> <artifactId>maven-shade-plugin</artifactId>
<version>${maven-shade-plugin.version}</version> <version>${maven-shade-plugin.version}</version>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -1,49 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>core-java-12</artifactId> <artifactId>core-java-12</artifactId>
<version>0.1.0-SNAPSHOT</version> <version>0.1.0-SNAPSHOT</version>
<name>core-java-12</name> <name>core-java-12</name>
<packaging>jar</packaging> <packaging>jar</packaging>
<url>http://maven.apache.org</url> <url>http://maven.apache.org</url>
<parent> <parent>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId> <artifactId>parent-modules</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>1.0.0-SNAPSHOT</version>
<relativePath>../../</relativePath> <relativePath>../../</relativePath>
</parent> </parent>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.assertj</groupId> <groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId> <artifactId>assertj-core</artifactId>
<version>${assertj.version}</version> <version>${assertj.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> <dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.11.0</version>
</dependency>
</dependencies>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version> <version>${maven-compiler-plugin.version}</version>
<configuration> <configuration>
<source>${maven.compiler.source.version}</source> <source>${maven.compiler.source.version}</source>
<target>${maven.compiler.target.version}</target> <target>${maven.compiler.target.version}</target>
<compilerArgs>--enable-preview</compilerArgs> <compilerArgs>--enable-preview</compilerArgs>
</configuration> </configuration>
</plugin> </plugin>
</plugins> <plugin>
</build> <artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>--enable-preview</argLine>
</configuration>
</plugin>
</plugins>
</build>
<properties> <properties>
<maven.compiler.source.version>12</maven.compiler.source.version> <maven.compiler.source.version>12</maven.compiler.source.version>
<maven.compiler.target.version>12</maven.compiler.target.version> <maven.compiler.target.version>12</maven.compiler.target.version>
<assertj.version>3.6.1</assertj.version> <assertj.version>3.6.1</assertj.version>
</properties> </properties>
</project> </project>

View File

@ -0,0 +1,88 @@
package com.baeldung.file.content.comparison;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel;
import java.nio.file.Files;
import java.nio.file.Path;
public class CompareFileContents {
public static long filesCompareByByte(Path path1, Path path2) throws IOException {
if (path1.getFileSystem()
.provider()
.isSameFile(path1, path2)) {
return -1;
}
try (BufferedInputStream fis1 = new BufferedInputStream(new FileInputStream(path1.toFile()));
BufferedInputStream fis2 = new BufferedInputStream(new FileInputStream(path2.toFile()))) {
int ch = 0;
long pos = 1;
while ((ch = fis1.read()) != -1) {
if (ch != fis2.read()) {
return pos;
}
pos++;
}
if (fis2.read() == -1) {
return -1;
} else {
return pos;
}
}
}
public static long filesCompareByLine(Path path1, Path path2) throws IOException {
if (path1.getFileSystem()
.provider()
.isSameFile(path1, path2)) {
return -1;
}
try (BufferedReader bf1 = Files.newBufferedReader(path1);
BufferedReader bf2 = Files.newBufferedReader(path2)) {
long lineNumber = 1;
String line1 = "", line2 = "";
while ((line1 = bf1.readLine()) != null) {
line2 = bf2.readLine();
if (line2 == null || !line1.equals(line2)) {
return lineNumber;
}
lineNumber++;
}
if (bf2.readLine() == null) {
return -1;
} else {
return lineNumber;
}
}
}
public static boolean compareByMemoryMappedFiles(Path path1, Path path2) throws IOException {
try (RandomAccessFile randomAccessFile1 = new RandomAccessFile(path1.toFile(), "r");
RandomAccessFile randomAccessFile2 = new RandomAccessFile(path2.toFile(), "r")) {
FileChannel ch1 = randomAccessFile1.getChannel();
FileChannel ch2 = randomAccessFile2.getChannel();
if (ch1.size() != ch2.size()) {
return false;
}
long size = ch1.size();
MappedByteBuffer m1 = ch1.map(FileChannel.MapMode.READ_ONLY, 0L, size);
MappedByteBuffer m2 = ch2.map(FileChannel.MapMode.READ_ONLY, 0L, size);
return m1.equals(m2);
}
}
}

View File

@ -0,0 +1,88 @@
package com.baeldung.file.content.comparison;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.Reader;
import java.nio.file.Files;
import java.nio.file.Path;
import org.apache.commons.io.IOUtils;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
public class CampareFileContentsApacheIOUnitTest {
public static Path path1 = null;
public static Path path2 = null;
@BeforeAll
public static void setup() throws IOException {
path1 = Files.createTempFile("file1Test", ".txt");
path2 = Files.createTempFile("file2Test", ".txt");
}
@Test
public void whenFilesIdentical_thenReturnTrue() throws IOException {
InputStream inputStream1 = new FileInputStream(path1.toFile());
InputStream inputStream2 = new FileInputStream(path2.toFile());
Files.writeString(path1, "testing line 1" + System.lineSeparator() + "line 2");
Files.writeString(path2, "testing line 1" + System.lineSeparator() + "line 2");
assertTrue(IOUtils.contentEquals(inputStream1, inputStream2));
}
@Test
public void whenFilesDifferent_thenReturnFalse() throws IOException {
InputStream inputStream1 = new FileInputStream(path1.toFile());
InputStream inputStream2 = new FileInputStream(path2.toFile());
Files.writeString(path1, "testing line " + System.lineSeparator() + "line 2");
Files.writeString(path2, "testing line 1" + System.lineSeparator() + "line 2");
assertFalse(IOUtils.contentEquals(inputStream1, inputStream2));
}
@Test
public void whenFilesIdenticalIgnoreEOF_thenReturnTrue() throws IOException {
Files.writeString(path1, "testing line 1 \n line 2");
Files.writeString(path2, "testing line 1 \r\n line 2");
Reader reader1 = new BufferedReader(new FileReader(path1.toFile()));
Reader reader2 = new BufferedReader(new FileReader(path2.toFile()));
assertTrue(IOUtils.contentEqualsIgnoreEOL(reader1, reader2));
}
@Test
public void whenFilesNotIdenticalIgnoreEOF_thenReturnFalse() throws IOException {
Files.writeString(path1, "testing line \n line 2");
Files.writeString(path2, "testing line 1 \r\n line 2");
Reader reader1 = new BufferedReader(new FileReader(path1.toFile()));
Reader reader2 = new BufferedReader(new FileReader(path2.toFile()));
assertFalse(IOUtils.contentEqualsIgnoreEOL(reader1, reader2));
}
@AfterAll
public static void shutDown() {
path1.toFile()
.deleteOnExit();
path2.toFile()
.deleteOnExit();
}
}

View File

@ -0,0 +1,42 @@
package com.baeldung.file.content.comparison;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
public class CompareByMemoryMappedFilesUnitTest {
public static Path path1 = null;
public static Path path2 = null;
@BeforeAll
public static void setup() throws IOException {
path1 = Files.createTempFile("file1Test", ".txt");
path2 = Files.createTempFile("file2Test", ".txt");
}
@Test
public void whenFilesIdentical_thenReturnTrue() throws IOException {
Files.writeString(path1, "testing line 1" + System.lineSeparator() + "line 2");
Files.writeString(path2, "testing line 1" + System.lineSeparator() + "line 2");
assertTrue(CompareFileContents.compareByMemoryMappedFiles(path1, path2));
}
@Test
public void whenFilesDifferent_thenReturnFalse() throws IOException {
Files.writeString(path1, "testing line " + System.lineSeparator() + "line 2");
Files.writeString(path2, "testing line 1" + System.lineSeparator() + "line 2");
assertFalse(CompareFileContents.compareByMemoryMappedFiles(path1, path2));
}
}

View File

@ -0,0 +1,96 @@
package com.baeldung.file.content.comparison;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
public class CompareFileContentsByBytesUnitTest {
public static Path path1 = null;
public static Path path2 = null;
@BeforeAll
public static void setup() throws IOException {
path1 = Files.createTempFile("file1Test", ".txt");
path2 = Files.createTempFile("file2Test", ".txt");
}
@Test
public void whenFirstFileShorter_thenPositionInSecondFile() throws IOException {
Files.writeString(path1, "testing");
Files.writeString(path2, "testing1");
assertEquals(8, CompareFileContents.filesCompareByByte(path1, path2));
}
@Test
public void whenSecondFileShorter_thenPositionInFirstFile() throws IOException {
Files.writeString(path1, "testing1");
Files.writeString(path2, "testing");
assertEquals(8, CompareFileContents.filesCompareByByte(path1, path2));
}
@Test
public void whenFilesIdentical_thenSuccess() throws IOException {
Files.writeString(path1, "testing");
Files.writeString(path2, "testing");
assertEquals(-1, CompareFileContents.filesCompareByByte(path1, path2));
}
@Test
public void whenFilesDifferent_thenPosition() throws IOException {
Files.writeString(path1, "tesXing");
Files.writeString(path2, "testing");
assertEquals(4, CompareFileContents.filesCompareByByte(path1, path2));
}
@Test
public void whenBothFilesEmpty_thenEqual() throws IOException {
Files.writeString(path1, "");
Files.writeString(path2, "");
assertEquals(-1, CompareFileContents.filesCompareByByte(path1, path2));
}
@Test
public void whenFirstEmpty_thenPositionFirst() throws IOException {
Files.writeString(path1, "");
Files.writeString(path2, "test");
assertEquals(1, CompareFileContents.filesCompareByByte(path1, path2));
}
@Test
public void whenSecondEmpty_thenPositionFirst() throws IOException {
Files.writeString(path1, "test");
Files.writeString(path2, "");
assertEquals(1, CompareFileContents.filesCompareByByte(path1, path2));
}
@AfterAll
public static void shutDown() {
path1.toFile().deleteOnExit();
path2.toFile().deleteOnExit();
}
}

View File

@ -0,0 +1,94 @@
package com.baeldung.file.content.comparison;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
public class CompareFileContentsByLinesUnitTest {
public static Path path1 = null;
public static Path path2 = null;
@BeforeAll
public static void setup() throws IOException {
path1 = Files.createTempFile("file1Test", ".txt");
path2 = Files.createTempFile("file2Test", ".txt");
}
@Test
public void whenFirstFileShorter_thenLineNumbersFirstFile() throws IOException {
Files.writeString(path1, "testing line 1");
Files.writeString(path2, "testing1 line 1" + System.lineSeparator() + "line 2");
assertEquals(1, CompareFileContents.filesCompareByLine(path1, path2));
}
@Test
public void whenSecondFileShorter_thenLineNumbersSecondFile() throws IOException {
Files.writeString(path1, "testing1 line 1" + System.lineSeparator() + "line 2");
Files.writeString(path2, "testing line 1");
assertEquals(1, CompareFileContents.filesCompareByLine(path1, path2));
}
@Test
public void whenFileIdentical_thenLineSuccess() throws IOException {
Files.writeString(path1, "testing1 line 1" + System.lineSeparator() + "line 2");
Files.writeString(path2, "testing1 line 1" + System.lineSeparator() + "line 2");
assertEquals(-1, CompareFileContents.filesCompareByLine(path1, path2));
}
@Test
public void whenFilesDifferent_thenLineNumber() throws IOException {
Files.writeString(path1, "testing1 line 1" + System.lineSeparator() + "line 2");
Files.writeString(path2, "testing1 line 1" + System.lineSeparator() + "linX 2");
assertEquals(2, CompareFileContents.filesCompareByLine(path1, path2));
}
@Test
public void whenBothFilesEmpty_thenEqual() throws IOException {
Files.writeString(path1, "");
Files.writeString(path2, "");
assertEquals(-1, CompareFileContents.filesCompareByByte(path1, path2));
}
@Test
public void whenFirstEmpty_thenPositionFirst() throws IOException {
Files.writeString(path1, "");
Files.writeString(path2, "testing1 line 1" + System.lineSeparator() + "line 2");
assertEquals(1, CompareFileContents.filesCompareByByte(path1, path2));
}
@Test
public void whenSecondEmpty_thenPositionFirst() throws IOException {
Files.writeString(path1, "testing1 line 1" + System.lineSeparator() + "line 2");
Files.writeString(path2, "");
assertEquals(1, CompareFileContents.filesCompareByByte(path1, path2));
}
@AfterAll
public static void shutDown() {
path1.toFile().deleteOnExit();
path2.toFile().deleteOnExit();
}
}

View File

@ -1,6 +1,6 @@
package java.com.baeldung.newfeatures; package com.baeldung.newfeatures;
import org.junit.Test; import org.junit.jupiter.api.Test;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.util.Locale; import java.util.Locale;
@ -16,6 +16,6 @@ public class CompactNumbersUnitTest {
assertEquals("2.59K", likesShort.format(2592)); assertEquals("2.59K", likesShort.format(2592));
NumberFormat likesLong = NumberFormat.getCompactNumberInstance(new Locale("en", "US"), NumberFormat.Style.LONG); NumberFormat likesLong = NumberFormat.getCompactNumberInstance(new Locale("en", "US"), NumberFormat.Style.LONG);
likesLong.setMaximumFractionDigits(2); likesLong.setMaximumFractionDigits(2);
assertEquals("2.59 thousand", likesShort.format(2592)); assertEquals("2.59 thousand", likesLong.format(2592));
} }
} }

View File

@ -1,6 +1,6 @@
package java.com.baeldung.newfeatures; package com.baeldung.newfeatures;
import org.junit.Test; import org.junit.jupiter.api.Test;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;

View File

@ -1,6 +1,6 @@
package java.com.baeldung.newfeatures; package com.baeldung.newfeatures;
import org.junit.Test; import org.junit.jupiter.api.Test;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;

View File

@ -1,6 +1,6 @@
package java.com.baeldung.newfeatures; package com.baeldung.newfeatures;
import org.junit.Test; import org.junit.jupiter.api.Test;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
@ -13,6 +13,6 @@ public class TeeingCollectorUnitTest {
public void givenSetOfNumbers_thenCalculateAverage() { public void givenSetOfNumbers_thenCalculateAverage() {
double mean = Stream.of(1, 2, 3, 4, 5) double mean = Stream.of(1, 2, 3, 4, 5)
.collect(Collectors.teeing(Collectors.summingDouble(i -> i), Collectors.counting(), (sum, count) -> sum / count)); .collect(Collectors.teeing(Collectors.summingDouble(i -> i), Collectors.counting(), (sum, count) -> sum / count));
assertEquals(3.0, mean); assertEquals(3.0, mean, 0);
} }
} }

View File

@ -31,7 +31,6 @@
<artifactId>jmh-generator-annprocess</artifactId> <artifactId>jmh-generator-annprocess</artifactId>
<version>${jmh-generator.version}</version> <version>${jmh-generator.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.assertj</groupId> <groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId> <artifactId>assertj-core</artifactId>

View File

@ -49,7 +49,6 @@
<filtering>true</filtering> <filtering>true</filtering>
</resource> </resource>
</resources> </resources>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>

View File

@ -48,7 +48,6 @@
<filtering>true</filtering> <filtering>true</filtering>
</resource> </resource>
</resources> </resources>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>

View File

@ -7,6 +7,7 @@
<version>0.1.0-SNAPSHOT</version> <version>0.1.0-SNAPSHOT</version>
<name>core-java-io-conversions</name> <name>core-java-io-conversions</name>
<packaging>jar</packaging> <packaging>jar</packaging>
<parent> <parent>
<groupId>com.baeldung.core-java-modules</groupId> <groupId>com.baeldung.core-java-modules</groupId>
<artifactId>core-java-modules</artifactId> <artifactId>core-java-modules</artifactId>

View File

@ -97,6 +97,7 @@
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
<profiles> <profiles>
<profile> <profile>
<id>integration</id> <id>integration</id>

View File

@ -7,6 +7,7 @@
<version>0.1.0-SNAPSHOT</version> <version>0.1.0-SNAPSHOT</version>
<name>core-java-jar</name> <name>core-java-jar</name>
<packaging>jar</packaging> <packaging>jar</packaging>
<parent> <parent>
<groupId>com.baeldung.core-java-modules</groupId> <groupId>com.baeldung.core-java-modules</groupId>
<artifactId>core-java-modules</artifactId> <artifactId>core-java-modules</artifactId>

View File

@ -48,4 +48,5 @@
</resource> </resource>
</resources> </resources>
</build> </build>
</project> </project>

View File

@ -62,4 +62,5 @@
<target.version>1.8</target.version> <target.version>1.8</target.version>
<spring.version>5.3.4</spring.version> <spring.version>5.3.4</spring.version>
</properties> </properties>
</project> </project>

View File

@ -38,7 +38,6 @@
<filtering>true</filtering> <filtering>true</filtering>
</resource> </resource>
</resources> </resources>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>

View File

@ -91,7 +91,6 @@
<filtering>true</filtering> <filtering>true</filtering>
</resource> </resource>
</resources> </resources>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>

View File

@ -27,7 +27,6 @@
<artifactId>guava</artifactId> <artifactId>guava</artifactId>
<version>${guava.version}</version> <version>${guava.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.junit.jupiter</groupId> <groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId> <artifactId>junit-jupiter</artifactId>

View File

@ -33,33 +33,29 @@
<version>${hamcrest.version}</version> <version>${hamcrest.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.ibm.icu</groupId> <groupId>com.ibm.icu</groupId>
<artifactId>icu4j</artifactId> <artifactId>icu4j</artifactId>
<version>${icu.version}</version> <version>${icu.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId> <artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version> <version>${commons-lang3.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId> <artifactId>commons-text</artifactId>
<version>${commons-text.version}</version> <version>${commons-text.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.assertj</groupId> <groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId> <artifactId>assertj-core</artifactId>
<version>${assertj.version}</version> <version>${assertj.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<properties> <properties>
<icu.version>64.2</icu.version> <icu.version>64.2</icu.version>
<assertj.version>3.12.2</assertj.version> <assertj.version>3.12.2</assertj.version>

View File

@ -5,7 +5,6 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>core-java-string-operations-3</artifactId> <artifactId>core-java-string-operations-3</artifactId>
<version>0.1.0-SNAPSHOT</version> <version>0.1.0-SNAPSHOT</version>
<name>core-java-string-operations-3</name> <name>core-java-string-operations-3</name>
<packaging>jar</packaging> <packaging>jar</packaging>
@ -58,6 +57,13 @@
</plugins> </plugins>
</build> </build>
<repositories>
<repository>
<id>gradle-repo</id>
<url>https://repo.gradle.org/gradle/libs-releases-local/</url>
</repository>
</repositories>
<properties> <properties>
<maven.compiler.source>11</maven.compiler.source> <maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target> <maven.compiler.target>11</maven.compiler.target>
@ -68,10 +74,4 @@
<semver4j.version>3.1.0</semver4j.version> <semver4j.version>3.1.0</semver4j.version>
</properties> </properties>
<repositories>
<repository>
<id>gradle-repo</id>
<url>https://repo.gradle.org/gradle/libs-releases-local/</url>
</repository>
</repositories>
</project> </project>

View File

@ -101,4 +101,5 @@
<properties> <properties>
<joda-money.version>1.0.1</joda-money.version> <joda-money.version>1.0.1</joda-money.version>
</properties> </properties>
</project> </project>

View File

@ -56,4 +56,5 @@
<tomcat-jdbc.version>8.5.33</tomcat-jdbc.version> <tomcat-jdbc.version>8.5.33</tomcat-jdbc.version>
<javax.annotation-api.version>1.3.2</javax.annotation-api.version> <javax.annotation-api.version>1.3.2</javax.annotation-api.version>
</properties> </properties>
</project> </project>

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -77,4 +77,5 @@
<os-maven-plugin.version>1.6.1</os-maven-plugin.version> <os-maven-plugin.version>1.6.1</os-maven-plugin.version>
<protobuf-maven-plugin.version>0.6.1</protobuf-maven-plugin.version> <protobuf-maven-plugin.version>0.6.1</protobuf-maven-plugin.version>
</properties> </properties>
</project> </project>

View File

@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>guava-concurrency</artifactId>
<parent> <parent>
<artifactId>guava-modules</artifactId> <artifactId>guava-modules</artifactId>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>guava-concurrency</artifactId>
</project> </project>

View File

@ -92,7 +92,6 @@
<artifactId>webcam-capture</artifactId> <artifactId>webcam-capture</artifactId>
<version>${webcam-capture.version}</version> <version>${webcam-capture.version}</version>
</dependency> </dependency>
</dependencies> </dependencies>
<properties> <properties>

View File

@ -49,7 +49,6 @@
<artifactId>vavr</artifactId> <artifactId>vavr</artifactId>
<version>0.10.3</version> <version>0.10.3</version>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -40,4 +40,5 @@
<assertj.version>3.6.1</assertj.version> <assertj.version>3.6.1</assertj.version>
<spring.version>5.2.5.RELEASE</spring.version> <spring.version>5.2.5.RELEASE</spring.version>
</properties> </properties>
</project> </project>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>java-jdi</artifactId> <artifactId>java-jdi</artifactId>
<version>0.1.0-SNAPSHOT</version> <version>0.1.0-SNAPSHOT</version>

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 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> <modelVersion>4.0.0</modelVersion>
<groupId>org.baeldung</groupId> <groupId>org.baeldung</groupId>
<artifactId>java-lite</artifactId> <artifactId>java-lite</artifactId>

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>plugins</artifactId> <artifactId>plugins</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
@ -12,7 +13,7 @@
<groupId>org.jenkins-ci.plugins</groupId> <groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId> <artifactId>plugin</artifactId>
<version>2.33</version> <version>2.33</version>
<relativePath/> <relativePath />
</parent> </parent>
<dependencies> <dependencies>
@ -80,9 +81,9 @@
</pluginRepositories> </pluginRepositories>
<properties> <properties>
<!-- Baseline Jenkins version you use to build the plugin. Users must have this version or newer to run. --> <!-- Baseline Jenkins version you use to build the plugin. Users must have this version or newer
to run. -->
<jenkins.version>2.7.3</jenkins.version> <jenkins.version>2.7.3</jenkins.version>
<structs.version>1.7</structs.version> <structs.version>1.7</structs.version>
<workflow-step-api.version>2.12</workflow-step-api.version> <workflow-step-api.version>2.12</workflow-step-api.version>
<workflow-cps.version>2.39</workflow-cps.version> <workflow-cps.version>2.39</workflow-cps.version>

View File

@ -51,7 +51,6 @@
<artifactId>commons-lang3</artifactId> <artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version> <version>${commons-lang3.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId> <artifactId>jackson-annotations</artifactId>

View File

@ -3,6 +3,9 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>k8s-admission-controller</artifactId>
<name>k8s-admission-controller</name>
<description>Demo project for Spring Boot</description>
<parent> <parent>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
@ -11,16 +14,11 @@
<relativePath>./../../parent-boot-2</relativePath> <relativePath>./../../parent-boot-2</relativePath>
</parent> </parent>
<artifactId>k8s-admission-controller</artifactId>
<name>k8s-admission-controller</name>
<description>Demo project for Spring Boot</description>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId> <artifactId>spring-boot-starter-webflux</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
@ -31,13 +29,11 @@
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>io.projectreactor</groupId> <groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId> <artifactId>reactor-test</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId> <artifactId>spring-boot-starter-actuator</artifactId>
@ -54,7 +50,6 @@
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>

View File

@ -1,5 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <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> <modelVersion>4.0.0</modelVersion>
<artifactId>kubernetes</artifactId> <artifactId>kubernetes</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
@ -12,6 +14,7 @@
<modules> <modules>
<module>k8s-intro</module> <module>k8s-intro</module>
<module>k8s-admission-controller</module> <module>k8s-admission-controller</module>
</modules> </modules>
</project> </project>

View File

@ -230,4 +230,5 @@
<plexus-compiler.version>2.8</plexus-compiler.version> <plexus-compiler.version>2.8</plexus-compiler.version>
<errorprone.version>2.1.3</errorprone.version> <errorprone.version>2.1.3</errorprone.version>
</properties> </properties>
</project> </project>

View File

@ -10,5 +10,6 @@ This module contains articles about HTTP libraries.
- [Adding Interceptors in OkHTTP](https://www.baeldung.com/java-okhttp-interceptors) - [Adding Interceptors in OkHTTP](https://www.baeldung.com/java-okhttp-interceptors)
- [A Guide to Events in OkHTTP](https://www.baeldung.com/java-okhttp-events) - [A Guide to Events in OkHTTP](https://www.baeldung.com/java-okhttp-events)
- [Download a Binary File Using OkHttp](https://www.baeldung.com/java-okhttp-download-binary-file) - [Download a Binary File Using OkHttp](https://www.baeldung.com/java-okhttp-download-binary-file)
- [Trusting a Self-Signed Certificate in OkHttp](https://www.baeldung.com/okhttp-self-signed-cert)
- More articles [[<-- prev]](/libraries-http) - More articles [[<-- prev]](/libraries-http)

View File

@ -2,4 +2,5 @@
### Relevant Articles: ### Relevant Articles:
- [Transferring a File Through SFTP in Java](https://www.baeldung.com/java-file-sftp) - [Transferring a File Through SFTP in Java](https://www.baeldung.com/java-file-sftp)
- [How to Create Password-Protected Zip Files and Unzip Them in Java](https://www.baeldung.com/java-password-protected-zip-unzip)

View File

@ -29,6 +29,11 @@
<artifactId>commons-vfs2</artifactId> <artifactId>commons-vfs2</artifactId>
<version>${vfs.version}</version> <version>${vfs.version}</version>
</dependency> </dependency>
<dependency>
<groupId>net.lingala.zip4j</groupId>
<artifactId>zip4j</artifactId>
<version>2.9.0</version>
</dependency>
</dependencies> </dependencies>
<properties> <properties>

View File

@ -0,0 +1,22 @@
package com.baeldung.java.io.zip4j;
import net.lingala.zip4j.ZipFile;
import net.lingala.zip4j.exception.ZipException;
import net.lingala.zip4j.model.ZipParameters;
import net.lingala.zip4j.model.enums.EncryptionMethod;
import java.io.File;
import java.util.Arrays;
public class CreateSplitZipFile {
public static void main(String[] args) throws ZipException {
ZipParameters zipParameters = new ZipParameters();
zipParameters.setEncryptFiles(true);
zipParameters.setEncryptionMethod(EncryptionMethod.AES);
ZipFile zipFile = new ZipFile("compressed.zip", "password".toCharArray());
int splitLength = 1024 * 1024 * 10; //10MB
zipFile.createSplitZipFile(Arrays.asList(new File("aFile.txt")), zipParameters, true, splitLength);
zipFile.createSplitZipFileFromFolder(new File("/users/folder_to_add"), zipParameters, true, splitLength);
}
}

View File

@ -0,0 +1,12 @@
package com.baeldung.java.io.zip4j;
import net.lingala.zip4j.ZipFile;
import net.lingala.zip4j.exception.ZipException;
public class ExtractAllFile {
public static void main(String[] args) throws ZipException {
ZipFile zipFile = new ZipFile("compressed.zip", "password".toCharArray());
zipFile.extractAll("/destination_directory");
}
}

View File

@ -0,0 +1,12 @@
package com.baeldung.java.io.zip4j;
import net.lingala.zip4j.ZipFile;
import net.lingala.zip4j.exception.ZipException;
public class ExtractSingleFile {
public static void main(String[] args) throws ZipException {
ZipFile zipFile = new ZipFile("compressed.zip", "password".toCharArray());
zipFile.extractFile("aFile.txt", "/destination_directory");
}
}

View File

@ -0,0 +1,19 @@
package com.baeldung.java.io.zip4j;
import net.lingala.zip4j.ZipFile;
import net.lingala.zip4j.exception.ZipException;
import net.lingala.zip4j.model.ZipParameters;
import net.lingala.zip4j.model.enums.EncryptionMethod;
import java.io.File;
public class ZipFolder {
public static void main(String[] args) throws ZipException {
ZipParameters zipParameters = new ZipParameters();
zipParameters.setEncryptFiles(true);
zipParameters.setEncryptionMethod(EncryptionMethod.AES);
ZipFile zipFile = new ZipFile("compressed.zip", "password".toCharArray());
zipFile.addFolder(new File("/users/folder_to_add"), zipParameters);
}
}

View File

@ -0,0 +1,27 @@
package com.baeldung.java.io.zip4j;
import net.lingala.zip4j.ZipFile;
import net.lingala.zip4j.exception.ZipException;
import net.lingala.zip4j.model.ZipParameters;
import net.lingala.zip4j.model.enums.EncryptionMethod;
import java.io.File;
import java.util.Arrays;
import java.util.List;
public class ZipMultiFile {
public static void main(String[] args) throws ZipException {
ZipParameters zipParameters = new ZipParameters();
zipParameters.setEncryptFiles(true);
zipParameters.setEncryptionMethod(EncryptionMethod.AES);
List<File> filesToAdd = Arrays.asList(
new File("aFile.txt"),
new File("bFile.txt")
);
ZipFile zipFile = new ZipFile("compressed.zip", "password".toCharArray());
zipFile.addFiles(filesToAdd, zipParameters);
}
}

View File

@ -0,0 +1,21 @@
package com.baeldung.java.io.zip4j;
import net.lingala.zip4j.ZipFile;
import net.lingala.zip4j.exception.ZipException;
import net.lingala.zip4j.model.ZipParameters;
import net.lingala.zip4j.model.enums.CompressionLevel;
import net.lingala.zip4j.model.enums.EncryptionMethod;
import java.io.File;
public class ZipSingleFile {
public static void main(String[] args) throws ZipException {
ZipParameters zipParameters = new ZipParameters();
zipParameters.setEncryptFiles(true);
zipParameters.setCompressionLevel(CompressionLevel.HIGHER);
zipParameters.setEncryptionMethod(EncryptionMethod.AES);
ZipFile zipFile = new ZipFile("compressed.zip", "password".toCharArray());
zipFile.addFile(new File("aFile.txt"));
}
}

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 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> <modelVersion>4.0.0</modelVersion>
<artifactId>libraries-security</artifactId> <artifactId>libraries-security</artifactId>
<name>libraries-security</name> <name>libraries-security</name>

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 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> <modelVersion>4.0.0</modelVersion>
<artifactId>libraries-server</artifactId> <artifactId>libraries-server</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>

View File

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>lombok-custom</artifactId> <artifactId>lombok-custom</artifactId>
<name>lombok-custom</name>
<version>0.1-SNAPSHOT</version> <version>0.1-SNAPSHOT</version>
<name>lombok-custom</name>
<parent> <parent>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
@ -20,13 +20,11 @@
<version>${lombok.version}</version> <version>${lombok.version}</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.kohsuke.metainf-services</groupId> <groupId>org.kohsuke.metainf-services</groupId>
<artifactId>metainf-services</artifactId> <artifactId>metainf-services</artifactId>
<version>${metainf-services.version}</version> <version>${metainf-services.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.eclipse.jdt</groupId> <groupId>org.eclipse.jdt</groupId>
<artifactId>core</artifactId> <artifactId>core</artifactId>

View File

@ -1,9 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId> <groupId>org.example</groupId>
<artifactId>maven-builder-plugin</artifactId> <artifactId>maven-builder-plugin</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
@ -14,7 +13,6 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
@ -38,4 +36,5 @@
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
</project> </project>

View File

@ -1,20 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <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> <modelVersion>4.0.0</modelVersion>
<groupId>org.baeldung</groupId>
<artifactId>copy-rename-maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<name>copy-rename-maven-plugin</name>
<parent> <parent>
<artifactId>maven-copy-files</artifactId> <artifactId>maven-copy-files</artifactId>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</parent> </parent>
<groupId>org.baeldung</groupId>
<artifactId>copy-rename-maven-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<name>copy-rename-maven-plugin</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
@ -23,6 +22,7 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
@ -89,4 +89,11 @@
</plugins> </plugins>
</pluginManagement> </pluginManagement>
</build> </build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
</project> </project>

View File

@ -1,20 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <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> <modelVersion>4.0.0</modelVersion>
<groupId>org.baeldung</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<name>maven-antrun-plugin</name>
<parent> <parent>
<artifactId>maven-copy-files</artifactId> <artifactId>maven-copy-files</artifactId>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</parent> </parent>
<groupId>org.baeldung</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<name>maven-antrun-plugin</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
@ -23,6 +22,7 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
@ -35,7 +35,8 @@
<target> <target>
<mkdir dir="${basedir}/target/destination-folder" /> <mkdir dir="${basedir}/target/destination-folder" />
<copy todir="${basedir}/target/destination-folder"> <copy todir="${basedir}/target/destination-folder">
<fileset dir="${basedir}/source-files" includes="foo.txt" /> <fileset dir="${basedir}/source-files"
includes="foo.txt" />
</copy> </copy>
</target> </target>
</configuration> </configuration>
@ -91,4 +92,11 @@
</plugins> </plugins>
</pluginManagement> </pluginManagement>
</build> </build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
</project> </project>

View File

@ -1,20 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <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> <modelVersion>4.0.0</modelVersion>
<groupId>org.baeldung</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<name>maven-resoures-plugin</name>
<parent> <parent>
<artifactId>maven-copy-files</artifactId> <artifactId>maven-copy-files</artifactId>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</parent> </parent>
<groupId>org.baeldung</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>1.0-SNAPSHOT</version>
<name>maven-resources-plugin</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
@ -23,6 +22,7 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
<pluginManagement> <pluginManagement>
<!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --> <!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
@ -89,4 +89,11 @@
</plugins> </plugins>
</pluginManagement> </pluginManagement>
</build> </build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
</project> </project>

View File

@ -1,23 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <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> <modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung</groupId>
<artifactId>maven-copy-files</artifactId>
<version>1.0-SNAPSHOT</version>
<name>maven-copy-files</name>
<packaging>pom</packaging>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<parent> <parent>
<artifactId>maven-modules</artifactId> <artifactId>maven-modules</artifactId>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
</parent> </parent>
<groupId>com.baeldung</groupId>
<artifactId>maven-copy-files</artifactId> <modules>
<version>1.0-SNAPSHOT</version> <module>maven-resources-plugin</module>
<packaging>pom</packaging> <module>maven-antrun-plugin</module>
<name>maven-copy-files</name> <module>copy-rename-maven-plugin</module>
<!-- FIXME change it to the project's website --> </modules>
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
@ -26,6 +31,7 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
<pluginManagement> <pluginManagement>
<!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --> <!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
@ -72,9 +78,11 @@
</plugins> </plugins>
</pluginManagement> </pluginManagement>
</build> </build>
<modules>
<module>maven-resources-plugin</module> <properties>
<module>maven-antrun-plugin</module> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<module>copy-rename-maven-plugin</module> <maven.compiler.source>1.7</maven.compiler.source>
</modules> <maven.compiler.target>1.7</maven.compiler.target>
</properties>
</project> </project>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<artifactId>counter-maven-plugin</artifactId> <artifactId>counter-maven-plugin</artifactId>

View File

@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<artifactId>maven-pom-types</artifactId> <artifactId>maven-pom-types</artifactId>

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>maven-printing-plugins</artifactId> <artifactId>maven-printing-plugins</artifactId>
<name>maven-printing-plugins</name> <name>maven-printing-plugins</name>
@ -27,11 +27,12 @@
</goals> </goals>
<configuration> <configuration>
<target> <target>
<echo message="Hello, world"/> <echo message="Hello, world" />
<echo message="Embed a line break: ${line.separator}"/> <echo message="Embed a line break: ${line.separator}" />
<echo message="Build dir: ${project.build.directory}" level="info"/> <echo message="Build dir: ${project.build.directory}"
level="info" />
<echo file="${basedir}/logs/log-ant-run.txt" append="true" <echo file="${basedir}/logs/log-ant-run.txt" append="true"
message="Save to file!"/> message="Save to file!" />
</target> </target>
</configuration> </configuration>
</execution> </execution>
@ -84,4 +85,5 @@
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
</project> </project>

View File

@ -6,3 +6,4 @@ have their own dedicated modules.
### Relevant Articles ### Relevant Articles
- [Accessing Maven Properties in Java](https://www.baeldung.com/java-accessing-maven-properties) - [Accessing Maven Properties in Java](https://www.baeldung.com/java-accessing-maven-properties)
- [Default Values for Maven Properties](https://www.baeldung.com/maven-properties-defaults)

View File

@ -1,16 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>plugin-management</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<parent> <parent>
<artifactId>maven-modules</artifactId> <artifactId>maven-modules</artifactId>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
</parent> </parent>
<artifactId>plugin-management</artifactId>
<packaging>pom</packaging>
<modules> <modules>
<module>submodule-1</module> <module>submodule-1</module>

View File

@ -16,7 +16,7 @@
<modules> <modules>
<!-- <module>compiler-plugin-java-9</module> --> <!-- We haven't upgraded to java 9. --> <!-- <module>compiler-plugin-java-9</module> --> <!-- We haven't upgraded to java 9. -->
<module>maven-copy-files</module> <module>maven-copy-files</module>
<module>maven-custom-plugin</module> <module>maven-custom-plugin</module>
<module>maven-exec-plugin</module> <module>maven-exec-plugin</module>
<module>maven-integration-test</module> <module>maven-integration-test</module>
@ -32,7 +32,7 @@
<module>version-overriding-plugins</module> <module>version-overriding-plugins</module>
<module>versions-maven-plugin</module> <module>versions-maven-plugin</module>
<module>maven-printing-plugins</module> <module>maven-printing-plugins</module>
<module>maven-builder-plugin</module> <module>maven-builder-plugin</module>
<module>host-maven-repo-example</module> <module>host-maven-repo-example</module>
<module>plugin-management</module> <module>plugin-management</module>
</modules> </modules>

View File

@ -55,9 +55,10 @@
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<repositories> <repositories>
<repository> <repository>
<id>jcenter</id> <id>jcenter</id>
<url>https://jcenter.bintray.com/</url> <url>https://jcenter.bintray.com/</url>
</repository> </repository>
</repositories> </repositories>

View File

@ -111,4 +111,5 @@
<liberty.var.default.https.port>9443</liberty.var.default.https.port> <liberty.var.default.https.port>9443</liberty.var.default.https.port>
<testServerHttpPort>7070</testServerHttpPort> <testServerHttpPort>7070</testServerHttpPort>
</properties> </properties>
</project> </project>

View File

@ -2,3 +2,4 @@
- [Service Locator Pattern and Java Implementation](https://www.baeldung.com/java-service-locator-pattern) - [Service Locator Pattern and Java Implementation](https://www.baeldung.com/java-service-locator-pattern)
- [The DAO Pattern in Java](https://www.baeldung.com/java-dao-pattern) - [The DAO Pattern in Java](https://www.baeldung.com/java-dao-pattern)
- [DAO vs Repository Patterns](https://www.baeldung.com/java-dao-vs-repository) - [DAO vs Repository Patterns](https://www.baeldung.com/java-dao-vs-repository)
- [Difference Between MVC and MVP Patterns](https://www.baeldung.com/mvc-vs-mvp-pattern)

View File

@ -0,0 +1,24 @@
package com.baeldung.mvc_mvp.mvc;
public class MvcMainClass {
public static void main(String[] args) {
Product model = retrieveProductFromDatabase();
ProductView view = new ProductView();
model.setView(view);
model.showProduct();
ProductController controller = new ProductController(model);
controller.setName("SmartPhone");
model.showProduct();
}
private static Product retrieveProductFromDatabase() {
Product product = new Product();
product.setName("Mobile");
product.setDescription("New Brand");
product.setPrice(1000.0);
return product;
}
}

View File

@ -0,0 +1,45 @@
package com.baeldung.mvc_mvp.mvc;
public class Product {
private String name;
private String description;
private Double price;
private ProductView view;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Double getPrice() {
return price;
}
public void setPrice(Double price) {
this.price = price;
}
public ProductView getView() {
return view;
}
public void setView(ProductView view) {
this.view = view;
}
public void showProduct() {
view.printProductDetails(name, description, price);
}
}

View File

@ -0,0 +1,34 @@
package com.baeldung.mvc_mvp.mvc;
public class ProductController {
private final Product product;
public ProductController(Product product) {
this.product = product;
}
public String getName() {
return product.getName();
}
public void setName(String name) {
product.setName(name);
}
public String getDescription() {
return product.getDescription();
}
public void setDescription(String description) {
product.setDescription(description);
}
public Double getPrice() {
return product.getPrice();
}
public void setPrice(Double price) {
product.setPrice(price);
}
}

View File

@ -0,0 +1,15 @@
package com.baeldung.mvc_mvp.mvc;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ProductView {
private static Logger log = LoggerFactory.getLogger(ProductView.class);
public void printProductDetails(String name, String description, Double price) {
log.info("Product details:");
log.info("product Name: " + name);
log.info("product Description: " + description);
log.info("product price: " + price);
}
}

View File

@ -0,0 +1,22 @@
package com.baeldung.mvc_mvp.mvp;
public class MvpMainClass {
public static void main(String[] args) {
Product model = retrieveProductFromDatabase();
ProductView view = new ProductView();
ProductPresenter presenter = new ProductPresenter(model, view);
presenter.showProduct();
presenter.setName("SmartPhone");
presenter.showProduct();
}
private static Product retrieveProductFromDatabase() {
Product product = new Product();
product.setName("Mobile");
product.setDescription("New Brand");
product.setPrice(1000.0);
return product;
}
}

View File

@ -0,0 +1,32 @@
package com.baeldung.mvc_mvp.mvp;
public class Product {
private String name;
private String description;
private Double price;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Double getPrice() {
return price;
}
public void setPrice(Double price) {
this.price = price;
}
}

View File

@ -0,0 +1,40 @@
package com.baeldung.mvc_mvp.mvp;
public class ProductPresenter {
private final Product product;
private final ProductView view;
public ProductPresenter(Product product, ProductView view) {
this.product = product;
this.view = view;
}
public String getName() {
return product.getName();
}
public void setName(String name) {
product.setName(name);
}
public String getDescription() {
return product.getDescription();
}
public void setDescription(String description) {
product.setDescription(description);
}
public Double getProductPrice() {
return product.getPrice();
}
public void setPrice(Double price) {
product.setPrice(price);
}
public void showProduct() {
view.printProductDetails(product.getName(), product.getDescription(), product.getPrice());
}
}

View File

@ -0,0 +1,15 @@
package com.baeldung.mvc_mvp.mvp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ProductView {
private static Logger log = LoggerFactory.getLogger(ProductView.class);
public void printProductDetails(String name, String description, Double price) {
log.info("Product details:");
log.info("product Name: " + name);
log.info("product Description: " + description);
log.info("product price: " + price);
}
}

View File

@ -1,67 +1,67 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<parent> <artifactId>enterprise-patterns</artifactId>
<groupId>com.baeldung</groupId> <packaging>pom</packaging>
<artifactId>patterns</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<artifactId>enterprise-patterns</artifactId> <parent>
<packaging>pom</packaging> <groupId>com.baeldung</groupId>
<artifactId>patterns</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<properties> <modules>
<camel.version>3.7.4</camel.version> <module>wire-tap</module>
</properties>
<modules>
<module>wire-tap</module>
</modules> </modules>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.apache.camel.springboot</groupId> <groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-spring-boot-starter</artifactId> <artifactId>camel-spring-boot-starter</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.camel.springboot</groupId> <groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-activemq-starter</artifactId> <artifactId>camel-activemq-starter</artifactId>
</dependency> </dependency>
<!-- Test -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>2.2.2.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test-spring-junit5</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<!-- Test --> <dependencyManagement>
<dependency> <dependencies>
<groupId>org.springframework.boot</groupId> <dependency>
<artifactId>spring-boot-starter-test</artifactId> <groupId>org.apache.camel.springboot</groupId>
<version>2.2.2.RELEASE</version> <artifactId>camel-spring-boot-dependencies</artifactId>
<scope>test</scope> <version>${camel.version}</version>
</dependency> <type>pom</type>
<dependency> <scope>import</scope>
<groupId>org.apache.camel</groupId> </dependency>
<artifactId>camel-test-spring-junit5</artifactId> </dependencies>
<scope>test</scope> </dependencyManagement>
</dependency>
</dependencies>
<dependencyManagement> <build>
<dependencies> <plugins>
<dependency> <plugin>
<groupId>org.apache.camel.springboot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>camel-spring-boot-dependencies</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
<version>${camel.version}</version> </plugin>
<type>pom</type> </plugins>
<scope>import</scope> </build>
</dependency>
</dependencies> <properties>
</dependencyManagement> <camel.version>3.7.4</camel.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project> </project>

View File

@ -1,25 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<artifactId>wire-tap</artifactId> <artifactId>wire-tap</artifactId>
<version>1.0</version> <version>1.0</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<parent> <parent>
<artifactId>enterprise-patterns</artifactId> <artifactId>enterprise-patterns</artifactId>
<groupId>com.baeldung</groupId> <groupId>com.baeldung</groupId>
<version>1.0.0-SNAPSHOT</version> <version>1.0.0-SNAPSHOT</version>
</parent> </parent>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId> <artifactId>spring-boot-maven-plugin</artifactId>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
</project> </project>

View File

@ -21,7 +21,6 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId> <artifactId>spring-boot-starter-data-mongodb</artifactId>

View File

@ -0,0 +1,31 @@
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<version>1.0.0-SNAPSHOT</version>
<artifactId>simple-hexagonal-example</artifactId>
<name>simpleHexagonalExample</name>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-boot-2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../../parent-boot-2</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,32 @@
package com.baeldung.simplehexagonalex;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import com.baeldung.simplehexagonalex.controller.QuoteCliController;
import com.baeldung.simplehexagonalex.domain.QuoteOfTheDay;
@SpringBootApplication
public class DailyQuoteMain implements CommandLineRunner {
private static final Logger LOG = LoggerFactory.getLogger(DailyQuoteMain.class);
@Autowired
private QuoteCliController quoteCliController;
public static void main(final String[] args) {
SpringApplication.run(DailyQuoteMain.class, args);
}
@Override
public void run(String... args) throws Exception {
QuoteOfTheDay quoteOfTheDay = quoteCliController.getQuote("cliController");
LOG.info(quoteOfTheDay.toString());
}
}

View File

@ -0,0 +1,24 @@
package com.baeldung.simplehexagonalex.controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.baeldung.simplehexagonalex.domain.QuoteOfTheDay;
import com.baeldung.simplehexagonalex.domain.service.QuoteService;
@Component
public class QuoteCliController {
private static final Logger LOG = LoggerFactory.getLogger(QuoteCliController.class);
@Autowired
private QuoteService quoteService;
public QuoteOfTheDay getQuote(String userId) {
LOG.info("Getting quote");
return quoteService.getQuote(userId);
}
}

View File

@ -0,0 +1,24 @@
package com.baeldung.simplehexagonalex.controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.baeldung.simplehexagonalex.domain.QuoteOfTheDay;
import com.baeldung.simplehexagonalex.domain.service.QuoteService;
@RestController
@RequestMapping("/quote")
public class QuoteRestController {
@Autowired
private QuoteService quoteService;
@GetMapping(path = "/{userId}")
public QuoteOfTheDay getEmployee(@PathVariable("userId") String userId) {
return quoteService.getQuote(userId);
}
}

View File

@ -0,0 +1,56 @@
package com.baeldung.simplehexagonalex.domain;
import java.util.Objects;
public class QuoteOfTheDay {
private String userName;
private String quote;
private String provider;
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getQuote() {
return quote;
}
public void setQuote(String quote) {
this.quote = quote;
}
public String getProvider() {
return provider;
}
public void setProvider(String provider) {
this.provider = provider;
}
@Override
public int hashCode() {
return Objects.hash(provider, quote, userName);
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
QuoteOfTheDay other = (QuoteOfTheDay) obj;
return Objects.equals(provider, other.provider) && Objects.equals(quote, other.quote) && Objects.equals(userName, other.userName);
}
@Override
public String toString() {
return "QuoteOfTheDay [userName=" + userName + ", quote=" + quote + ", provider=" + provider + "]";
}
}

View File

@ -0,0 +1,8 @@
package com.baeldung.simplehexagonalex.domain.repository;
import com.baeldung.simplehexagonalex.domain.QuoteOfTheDay;
public interface QuoteOfTheDayFromProvider {
QuoteOfTheDay getQuote();
}

View File

@ -0,0 +1,22 @@
package com.baeldung.simplehexagonalex.domain.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baeldung.simplehexagonalex.domain.QuoteOfTheDay;
import com.baeldung.simplehexagonalex.domain.repository.QuoteOfTheDayFromProvider;
@Service
public class QuoteAggregator implements QuoteService {
@Autowired
private QuoteOfTheDayFromProvider quoteOfTheDayFromProvider;
@Override
public QuoteOfTheDay getQuote(String userName) {
QuoteOfTheDay quoteOfTheDay = quoteOfTheDayFromProvider.getQuote();
quoteOfTheDay.setUserName(userName);
return quoteOfTheDay;
}
}

View File

@ -0,0 +1,8 @@
package com.baeldung.simplehexagonalex.domain.service;
import com.baeldung.simplehexagonalex.domain.QuoteOfTheDay;
public interface QuoteService {
QuoteOfTheDay getQuote(String userName);
}

View File

@ -0,0 +1,109 @@
package com.baeldung.simplehexagonalex.repository.primary.quoteadapter;
import java.util.List;
import java.util.Objects;
public class ProviderQuote {
private String quote;
private String length;
private String author;
private List<String> tags;
private String category;
private String language;
private String date;
private String permalink;
private String id;
private String background;
private String title;
public ProviderQuote() {
}
public ProviderQuote(String quote, String length, String author, List<String> tags, String category, String language, String date, String permalink, String id, String background, String title) {
super();
this.quote = quote;
this.length = length;
this.author = author;
this.tags = tags;
this.category = category;
this.language = language;
this.date = date;
this.permalink = permalink;
this.id = id;
this.background = background;
this.title = title;
}
public String getQuote() {
return quote;
}
public String getLength() {
return length;
}
public String getAuthor() {
return author;
}
public List<String> getTags() {
return tags;
}
public String getCategory() {
return category;
}
public String getLanguage() {
return language;
}
public String getDate() {
return date;
}
public String getPermalink() {
return permalink;
}
public String getId() {
return id;
}
public String getBackground() {
return background;
}
public String getTitle() {
return title;
}
public void setId(String id) {
this.id = id;
}
@Override
public int hashCode() {
return Objects.hash(id);
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
ProviderQuote other = (ProviderQuote) obj;
return Objects.equals(id, other.id);
}
@Override
public String toString() {
return "TheysaysoQuote [quote=" + quote + ", length=" + length + ", " + "author=" + author + ", tags=" + tags + ", category=" + category + ", language=" + language + ", date=" + date + ", permalink=" + permalink + ", id=" + id + ", background="
+ background + ", title=" + title + "]";
}
}

View File

@ -0,0 +1,54 @@
package com.baeldung.simplehexagonalex.repository.primary.quoteadapter;
import java.net.URI;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
import com.baeldung.simplehexagonalex.domain.QuoteOfTheDay;
import com.baeldung.simplehexagonalex.domain.repository.QuoteOfTheDayFromProvider;
import com.fasterxml.jackson.databind.ObjectMapper;
@Service("providerQuoteAdapter")
@Primary
public class ProviderQuoteAdapter implements QuoteOfTheDayFromProvider {
@Autowired
private Environment env;
@Override
public QuoteOfTheDay getQuote() {
QuoteOfTheDay quoteOfTheDay = new QuoteOfTheDay();
ProviderQuoteEnvelope providerQuote;
try {
providerQuote = getProviderQuote();
quoteOfTheDay.setQuote(providerQuote.getContents()
.getQuotes()
.get(0)
.getQuote());
quoteOfTheDay.setProvider(providerQuote.getCopyright()
.getUrl());
} catch (Exception e) {
quoteOfTheDay.setQuote("Unable to get the quote");
quoteOfTheDay.setProvider("none");
}
return quoteOfTheDay;
}
private ProviderQuoteEnvelope getProviderQuote() throws Exception {
HttpGet request = new HttpGet(URI.create(env.getProperty("theysayso.quote.provider.url")));
CloseableHttpClient client = HttpClients.createDefault();
CloseableHttpResponse response = client.execute(request);
ProviderQuoteEnvelope providersQuote = new ObjectMapper().readValue(response.getEntity()
.getContent(), ProviderQuoteEnvelope.class);
return providersQuote;
}
}

View File

@ -0,0 +1,68 @@
package com.baeldung.simplehexagonalex.repository.primary.quoteadapter;
import java.util.List;
public class ProviderQuoteEnvelope {
private Success success;
private Contents contents;
private String baseurl;
private Copyright copyright;
public ProviderQuoteEnvelope() {
}
public ProviderQuoteEnvelope(Success success, Contents contents, String baseurl, Copyright copyright) {
super();
this.success = success;
this.contents = contents;
this.baseurl = baseurl;
this.copyright = copyright;
}
public Success getSuccess() {
return success;
}
public Contents getContents() {
return contents;
}
public String getBaseurl() {
return baseurl;
}
public Copyright getCopyright() {
return copyright;
}
public class Contents {
private List<ProviderQuote> quotes;
public List<ProviderQuote> getQuotes() {
return quotes;
}
}
public class Copyright {
private int year;
private String url;
public int getYear() {
return year;
}
public String getUrl() {
return url;
}
}
public class Success {
private int total;
public int getTotal() {
return total;
}
}
}

View File

@ -0,0 +1,20 @@
package com.baeldung.simplehexagonalex.reposity.mock.quoteadapter;
import org.springframework.stereotype.Service;
import com.baeldung.simplehexagonalex.domain.QuoteOfTheDay;
import com.baeldung.simplehexagonalex.domain.repository.QuoteOfTheDayFromProvider;
@Service
public class MockQuoteAdapter implements QuoteOfTheDayFromProvider {
@Override
public QuoteOfTheDay getQuote() {
QuoteOfTheDay quoteOfTheDay = new QuoteOfTheDay();
quoteOfTheDay.setQuote("Mock quote of the day");
quoteOfTheDay.setProvider("Mock Provider");
return quoteOfTheDay;
}
}

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