[JAVA-22519] Created new module libraries-stream and added 5 articles (#15403)

This commit is contained in:
panos-kakos 2023-12-13 09:40:13 +02:00 committed by GitHub
parent 0323a8168c
commit 8daf19c9ec
92 changed files with 718 additions and 430 deletions

View File

@ -1,7 +0,0 @@
## ASM
This module contains articles about ASM
### Relevant Articles:
- [A Guide to Java Bytecode Manipulation with ASM](https://www.baeldung.com/java-asm)

View File

@ -1,54 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung.examples</groupId>
<artifactId>asm</artifactId>
<version>1.0</version>
<name>asm</name>
<packaging>jar</packaging>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>${asm.version}</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-util</artifactId>
<version>${asm.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven-jar-plugin.version}</version>
<configuration>
<archive>
<manifestEntries>
<Premain-Class>
com.baeldung.examples.asm.instrumentation.Premain
</Premain-Class>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<asm.version>5.2</asm.version>
</properties>
</project>

View File

@ -10,13 +10,10 @@ Remember, for advanced libraries like [Jackson](/jackson) and [JUnit](/testing-m
### Relevant articles
- [A Guide to jBPM with Java](https://www.baeldung.com/jbpm-java)
- [Guide to Classgraph Library](https://www.baeldung.com/classgraph)
- [Create a Java Command Line Program with Picocli](https://www.baeldung.com/java-picocli-create-command-line-program)
- [Guide to Java Parallel Collectors Library](https://www.baeldung.com/java-parallel-collectors)
- [Templating with Handlebars](https://www.baeldung.com/handlebars)
- [A Guide to Crawler4j](https://www.baeldung.com/crawler4j)
- [Key Value Store with Chronicle Map](https://www.baeldung.com/java-chronicle-map)
- [Guide to MapDB](https://www.baeldung.com/mapdb)
- [A Guide to Apache Mesos](https://www.baeldung.com/apache-mesos)
- [JasperReports with Spring](https://www.baeldung.com/spring-jasper)
- More articles [[<-- prev]](/libraries) [[next -->]](/libraries-3)

View File

@ -18,11 +18,6 @@
<artifactId>mapdb</artifactId>
<version>${mapdb.version}</version>
</dependency>
<dependency>
<groupId>com.pivovarit</groupId>
<artifactId>parallel-collectors</artifactId>
<version>${parallel-collectors.version}</version>
</dependency>
<dependency>
<groupId>io.github.classgraph</groupId>
<artifactId>classgraph</artifactId>
@ -41,11 +36,6 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>info.picocli</groupId>
<artifactId>picocli</artifactId>
<version>${picocli.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
@ -83,17 +73,6 @@
<artifactId>mesos</artifactId>
<version>${mesos.library.version}</version>
</dependency>
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>${jasperreports.version}</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.hsqldb</groupId>
<artifactId>hsqldb</artifactId>
@ -133,14 +112,11 @@
<mapdb.version>3.0.8</mapdb.version>
<classgraph.version>4.8.153</classgraph.version>
<jbpm.version>7.20.0.Final</jbpm.version>
<picocli.version>4.7.0</picocli.version>
<chronicle.map.version>3.24ea1</chronicle.map.version>
<crawler4j.version>4.4.0</crawler4j.version>
<spring-boot-starter.version>2.7.8</spring-boot-starter.version>
<mesos.library.version>1.11.0</mesos.library.version>
<parallel-collectors.version>1.1.0</parallel-collectors.version>
<handlebars.version>4.3.1</handlebars.version>
<jasperreports.version>6.20.0</jasperreports.version>
<spring.version>5.3.25</spring.version>
<hsqldb.version>2.7.1</hsqldb.version>
</properties>

View File

@ -8,9 +8,7 @@ The code examples related to different libraries are each in their own module.
Remember, for advanced libraries like [Jackson](/jackson) and [JUnit](/testing-modules) we already have separate modules. Please make sure to have a look at the existing modules in such cases.
### Relevant Articles:
- [Parsing Command-Line Parameters with JCommander](https://www.baeldung.com/jcommander-parsing-command-line-parameters)
- [Guide to the Cactoos Library](https://www.baeldung.com/java-cactoos)
- [Parsing Command-Line Parameters with Airline](https://www.baeldung.com/java-airline)
- [Introduction to cache2k](https://www.baeldung.com/java-cache2k)
- [Introduction to the jcabi-aspects AOP Annotations Library](https://www.baeldung.com/java-jcabi-aspects)
- [Introduction to Takes](https://www.baeldung.com/java-takes)

View File

@ -13,21 +13,11 @@
</parent>
<dependencies>
<dependency>
<groupId>com.beust</groupId>
<artifactId>jcommander</artifactId>
<version>${jcommander.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>
<dependency>
<groupId>com.github.rvesse</groupId>
<artifactId>airline</artifactId>
<version>${airline.version}</version>
</dependency>
<dependency>
<groupId>org.cactoos</groupId>
<artifactId>cactoos</artifactId>
@ -125,7 +115,7 @@
<dependency>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<version>1.3.2</version>
<version>${javax.annotation-api.version}</version>
</dependency>
</dependencies>
@ -159,10 +149,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
<resources>
@ -214,9 +200,7 @@
</profiles>
<properties>
<jcommander.version>1.78</jcommander.version>
<cactoos.version>0.43</cactoos.version>
<airline.version>2.7.2</airline.version>
<cache2k.version>1.2.3.Final</cache2k.version>
<jcabi-aspects.version>0.22.6</jcabi-aspects.version>
<aspectjrt.version>1.9.20.1</aspectjrt.version>
@ -233,6 +217,7 @@
<structurizr.version>1.0.0</structurizr.version>
<immutables.version>2.5.6</immutables.version>
<mutabilitydetector.version>0.9.6</mutabilitydetector.version>
<javax.annotation-api.version>1.3.2</javax.annotation-api.version>
</properties>
</project>

View File

@ -11,9 +11,7 @@ Remember, for advanced libraries like [Jackson](/jackson) and [JUnit](/testing-m
- [Quick Guide to RSS with Rome](https://www.baeldung.com/rome-rss)
- [Introduction to PCollections](https://www.baeldung.com/java-pcollections)
- [Introduction to Eclipse Collections](https://www.baeldung.com/eclipse-collections)
- [DistinctBy in the Java Stream API](https://www.baeldung.com/java-streams-distinct-by)
- [Introduction to NoException](https://www.baeldung.com/no-exception)
- [Spring Yarg Integration](https://www.baeldung.com/spring-yarg)
- [Delete a Directory Recursively in Java](https://www.baeldung.com/java-delete-directory)
- [Guide to JDeferred](https://www.baeldung.com/jdeferred)
- [Introduction to MBassador](https://www.baeldung.com/mbassador)

View File

@ -22,17 +22,6 @@
<artifactId>eclipse-collections</artifactId>
<version>${eclipse-collections.version}</version>
</dependency>
<dependency>
<groupId>com.haulmont.yarg</groupId>
<artifactId>yarg</artifactId>
<version>${yarg.version}</version>
<exclusions>
<exclusion>
<groupId>org.olap4j</groupId>
<artifactId>olap4j</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.olap4j</groupId>
<artifactId>olap4j</artifactId>
@ -68,11 +57,6 @@
<artifactId>servlet-api</artifactId>
<version>${javax.servlet.version}</version>
</dependency>
<dependency>
<groupId>io.vavr</groupId>
<artifactId>vavr</artifactId>
<version>${vavr.version}</version>
</dependency>
<dependency>
<groupId>org.pcollections</groupId>
<artifactId>pcollections</artifactId>
@ -119,21 +103,33 @@
<artifactId>jackson-annotations</artifactId>
<version>${jackson-annotations.version}</version>
</dependency>
<dependency>
<groupId>io.vavr</groupId>
<artifactId>vavr</artifactId>
<version>${vavr.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons-lang3.version}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io.version}</version>
</dependency>
</dependencies>
<properties>
<jackson-annotations.version>2.14.2</jackson-annotations.version>
<jackson-core.version>2.14.2</jackson-core.version>
<jdeferred.version>1.2.6</jdeferred.version>
<eclipse-collections.version>8.2.0</eclipse-collections.version>
<noexception.version>1.1.0</noexception.version>
<yarg.version>2.0.12</yarg.version>
<mbassador.version>1.3.1</mbassador.version>
<rome.version>1.0</rome.version>
<spring.version>4.3.8.RELEASE</spring.version>
<javax.servlet.version>2.5</javax.servlet.version>
<javax.jdo.version>3.2.0-m7</javax.jdo.version>
<vavr.version>0.9.0</vavr.version>
<pcollections.version>2.1.2</pcollections.version>
<awaitility.version>3.0.0</awaitility.version>
<streamex.version>0.6.5</streamex.version>
@ -142,6 +138,8 @@
<olap4j.version>1.2.0</olap4j.version>
<javafx.version>19</javafx.version>
<spoon-core.version>10.3.0</spoon-core.version>
<eclipse-collections.version>8.2.0</eclipse-collections.version>
<vavr.version>0.9.0</vavr.version>
</properties>
</project>

View File

@ -9,10 +9,8 @@ Remember, for advanced libraries like [Jackson](/jackson) and [JUnit](/testing-m
### Relevant articles
- [Introduction to Caffeine](https://www.baeldung.com/java-caching-caffeine)
- [Introduction to StreamEx](https://www.baeldung.com/streamex)
- [A Docker Guide for Java](https://www.baeldung.com/docker-java-api)
- [Introduction to Akka Actors in Java](https://www.baeldung.com/akka-actors-java)
- [A Guide to Byte Buddy](https://www.baeldung.com/byte-buddy)
- [Introduction to jOOL](https://www.baeldung.com/jool)
- [Consumer Driven Contracts with Pact](https://www.baeldung.com/pact-junit-consumer-driven-contracts)
- [Introduction to Atlassian Fugue](https://www.baeldung.com/java-fugue)

View File

@ -49,21 +49,6 @@
<version>${typesafe-akka.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>one.util</groupId>
<artifactId>streamex</artifactId>
<version>${streamex.version}</version>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>${byte-buddy.version}</version>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy-agent</artifactId>
<version>${byte-buddy.version}</version>
</dependency>
<!--Java Docker API Client -->
<dependency>
<groupId>com.github.docker-java</groupId>
@ -139,7 +124,6 @@
<spring.version>4.3.8.RELEASE</spring.version>
<scala.version>2.12</scala.version>
<typesafe-akka.version>2.5.11</typesafe-akka.version>
<streamex.version>0.8.1</streamex.version>
<docker.version>3.0.14</docker.version>
<caffeine.version>3.1.8</caffeine.version>
<findbugs.version>3.0.2</findbugs.version>

View File

@ -12,7 +12,6 @@ Remember, for advanced libraries like [Jackson](/jackson) and [JUnit](/testing-m
- [Guide to Resilience4j](https://www.baeldung.com/resilience4j)
- [Implementing a FTP-Client in Java](https://www.baeldung.com/java-ftp-client)
- [Introduction to Functional Java](https://www.baeldung.com/java-functional-library)
- [Introduction to Protonpack](https://www.baeldung.com/java-protonpack)
- [Guide to Simple Binary Encoding](https://www.baeldung.com/java-sbe)
- [Java-R Integration](https://www.baeldung.com/java-r-integration)
- [Using libphonenumber to Validate Phone Numbers](https://www.baeldung.com/java-libphonenumber)

View File

@ -17,11 +17,6 @@
<artifactId>functionaljava-java8</artifactId>
<version>${functionaljava.version}</version>
</dependency>
<dependency>
<groupId>com.codepoetics</groupId>
<artifactId>protonpack</artifactId>
<version>${protonpack.version}</version>
</dependency>
<dependency>
<groupId>io.github.resilience4j</groupId>
<artifactId>resilience4j-circuitbreaker</artifactId>
@ -198,7 +193,6 @@
<mockftpserver.version>2.7.1</mockftpserver.version>
<functionaljava.version>4.8.1</functionaljava.version>
<resilience4j.version>2.1.0</resilience4j.version>
<protonpack.version>1.15</protonpack.version>
<commons-net.version>3.6</commons-net.version>
<renjin.version>3.5-beta72</renjin.version>
<rcaller.version>3.0</rcaller.version>

9
libraries-bytecode/.gitignore vendored Normal file
View File

@ -0,0 +1,9 @@
*.class
# Folders #
/gensrc
/target
# Packaged files #
*.jar
/bin/

View File

@ -0,0 +1,9 @@
## Server
This module contains articles about bytecode libraries.
### Relevant Articles:
- [Introduction to Javassist](https://www.baeldung.com/javassist)
- [A Guide to Byte Buddy](https://www.baeldung.com/byte-buddy)
- [A Guide to Java Bytecode Manipulation with ASM](https://www.baeldung.com/java-asm)

View File

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>libraries-bytecode</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>libraries-bytecode</name>
<packaging>jar</packaging>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>${javaassist.version}</version>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<version>${byte-buddy.version}</version>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy-agent</artifactId>
<version>${byte-buddy.version}</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>${asm.version}</version>
</dependency>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm-util</artifactId>
<version>${asm.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>
--add-exports=java.base/jdk.internal.ref=ALL-UNNAMED
--add-exports=java.base/sun.nio.ch=ALL-UNNAMED
--add-exports=jdk.unsupported/sun.misc=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
--add-opens=jdk.compiler/com.sun.tools.javac=ALL-UNNAMED
--add-opens=java.base/java.lang=ALL-UNNAMED
--add-opens=java.base/java.lang.reflect=ALL-UNNAMED
--add-opens=java.base/java.io=ALL-UNNAMED
--add-opens=java.base/java.util=ALL-UNNAMED
</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven-jar-plugin.version}</version>
<configuration>
<archive>
<manifestEntries>
<Premain-Class>
com.baeldung.examples.asm.instrumentation.Premain
</Premain-Class>
</manifestEntries>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<javaassist.version>3.29.2-GA</javaassist.version>
<asm.version>5.2</asm.version>
</properties>
</project>

View File

@ -1,160 +1,160 @@
package com.baeldung.examples.asm;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.MethodVisitor;
import static org.objectweb.asm.Opcodes.ACC_PUBLIC;
import static org.objectweb.asm.Opcodes.ACC_STATIC;
import static org.objectweb.asm.Opcodes.ASM4;
import static org.objectweb.asm.Opcodes.V1_5;
import org.objectweb.asm.Type;
import org.objectweb.asm.util.TraceClassVisitor;
/**
*
* @author baeldung
* @param <String>
*/
public class CustomClassWriter {
ClassReader reader;
ClassWriter writer;
AddFieldAdapter addFieldAdapter;
AddInterfaceAdapter addInterfaceAdapter;
PublicizeMethodAdapter pubMethAdapter;
final static String CLASSNAME = "java.lang.Integer";
final static String CLONEABLE = "java/lang/Cloneable";
public CustomClassWriter() {
try {
reader = new ClassReader(CLASSNAME);
writer = new ClassWriter(reader, 0);
} catch (IOException ex) {
Logger.getLogger(CustomClassWriter.class.getName()).log(Level.SEVERE, null, ex);
}
}
public CustomClassWriter(byte[] contents) {
reader = new ClassReader(contents);
writer = new ClassWriter(reader, 0);
}
public static void main(String[] args) {
CustomClassWriter ccw = new CustomClassWriter();
ccw.publicizeMethod();
}
public byte[] addField() {
addFieldAdapter = new AddFieldAdapter("aNewBooleanField", org.objectweb.asm.Opcodes.ACC_PUBLIC, writer);
reader.accept(addFieldAdapter, 0);
return writer.toByteArray();
}
public byte[] publicizeMethod() {
pubMethAdapter = new PublicizeMethodAdapter(writer);
reader.accept(pubMethAdapter, 0);
return writer.toByteArray();
}
public byte[] addInterface() {
addInterfaceAdapter = new AddInterfaceAdapter(writer);
reader.accept(addInterfaceAdapter, 0);
return writer.toByteArray();
}
public class AddInterfaceAdapter extends ClassVisitor {
public AddInterfaceAdapter(ClassVisitor cv) {
super(ASM4, cv);
}
@Override
public void visit(int version, int access, String name,
String signature, String superName, String[] interfaces) {
String[] holding = new String[interfaces.length + 1];
holding[holding.length - 1] = CLONEABLE;
System.arraycopy(interfaces, 0, holding, 0, interfaces.length);
cv.visit(V1_5, access, name, signature, superName, holding);
}
}
public class PublicizeMethodAdapter extends ClassVisitor {
final Logger logger = Logger.getLogger("PublicizeMethodAdapter");
TraceClassVisitor tracer;
PrintWriter pw = new PrintWriter(System.out);
public PublicizeMethodAdapter(ClassVisitor cv) {
super(ASM4, cv);
this.cv = cv;
tracer = new TraceClassVisitor(cv, pw);
}
@Override
public MethodVisitor visitMethod(int access,
String name,
String desc,
String signature,
String[] exceptions) {
if (name.equals("toUnsignedString0")) {
logger.info("Visiting unsigned method");
return tracer.visitMethod(ACC_PUBLIC + ACC_STATIC, name, desc, signature, exceptions);
}
return tracer.visitMethod(access, name, desc, signature, exceptions);
}
public void visitEnd() {
tracer.visitEnd();
System.out.println(tracer.p.getText());
}
}
public class AddFieldAdapter extends ClassVisitor {
String fieldName;
int access;
boolean isFieldPresent;
public AddFieldAdapter(String fieldName, int access, ClassVisitor cv) {
super(ASM4, cv);
this.cv = cv;
this.access = access;
this.fieldName = fieldName;
}
@Override
public FieldVisitor visitField(int access, String name, String desc,
String signature, Object value) {
if (name.equals(fieldName)) {
isFieldPresent = true;
}
return cv.visitField(access, name, desc, signature, value);
}
@Override
public void visitEnd() {
if (!isFieldPresent) {
FieldVisitor fv = cv.visitField(access, fieldName, Type.BOOLEAN_TYPE.toString(), null, null);
if (fv != null) {
fv.visitEnd();
}
}
cv.visitEnd();
}
}
}
package com.baeldung.asm;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.objectweb.asm.ClassReader;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.ClassWriter;
import org.objectweb.asm.FieldVisitor;
import org.objectweb.asm.MethodVisitor;
import static org.objectweb.asm.Opcodes.ACC_PUBLIC;
import static org.objectweb.asm.Opcodes.ACC_STATIC;
import static org.objectweb.asm.Opcodes.ASM4;
import static org.objectweb.asm.Opcodes.V1_5;
import org.objectweb.asm.Type;
import org.objectweb.asm.util.TraceClassVisitor;
/**
*
* @author baeldung
* @param <String>
*/
public class CustomClassWriter {
ClassReader reader;
ClassWriter writer;
AddFieldAdapter addFieldAdapter;
AddInterfaceAdapter addInterfaceAdapter;
PublicizeMethodAdapter pubMethAdapter;
final static String CLASSNAME = "java.lang.Integer";
final static String CLONEABLE = "java/lang/Cloneable";
public CustomClassWriter() {
try {
reader = new ClassReader(CLASSNAME);
writer = new ClassWriter(reader, 0);
} catch (IOException ex) {
Logger.getLogger(CustomClassWriter.class.getName()).log(Level.SEVERE, null, ex);
}
}
public CustomClassWriter(byte[] contents) {
reader = new ClassReader(contents);
writer = new ClassWriter(reader, 0);
}
public static void main(String[] args) {
CustomClassWriter ccw = new CustomClassWriter();
ccw.publicizeMethod();
}
public byte[] addField() {
addFieldAdapter = new AddFieldAdapter("aNewBooleanField", org.objectweb.asm.Opcodes.ACC_PUBLIC, writer);
reader.accept(addFieldAdapter, 0);
return writer.toByteArray();
}
public byte[] publicizeMethod() {
pubMethAdapter = new PublicizeMethodAdapter(writer);
reader.accept(pubMethAdapter, 0);
return writer.toByteArray();
}
public byte[] addInterface() {
addInterfaceAdapter = new AddInterfaceAdapter(writer);
reader.accept(addInterfaceAdapter, 0);
return writer.toByteArray();
}
public class AddInterfaceAdapter extends ClassVisitor {
public AddInterfaceAdapter(ClassVisitor cv) {
super(ASM4, cv);
}
@Override
public void visit(int version, int access, String name,
String signature, String superName, String[] interfaces) {
String[] holding = new String[interfaces.length + 1];
holding[holding.length - 1] = CLONEABLE;
System.arraycopy(interfaces, 0, holding, 0, interfaces.length);
cv.visit(V1_5, access, name, signature, superName, holding);
}
}
public class PublicizeMethodAdapter extends ClassVisitor {
final Logger logger = Logger.getLogger("PublicizeMethodAdapter");
TraceClassVisitor tracer;
PrintWriter pw = new PrintWriter(System.out);
public PublicizeMethodAdapter(ClassVisitor cv) {
super(ASM4, cv);
this.cv = cv;
tracer = new TraceClassVisitor(cv, pw);
}
@Override
public MethodVisitor visitMethod(int access,
String name,
String desc,
String signature,
String[] exceptions) {
if (name.equals("toUnsignedString0")) {
logger.info("Visiting unsigned method");
return tracer.visitMethod(ACC_PUBLIC + ACC_STATIC, name, desc, signature, exceptions);
}
return tracer.visitMethod(access, name, desc, signature, exceptions);
}
public void visitEnd() {
tracer.visitEnd();
System.out.println(tracer.p.getText());
}
}
public class AddFieldAdapter extends ClassVisitor {
String fieldName;
int access;
boolean isFieldPresent;
public AddFieldAdapter(String fieldName, int access, ClassVisitor cv) {
super(ASM4, cv);
this.cv = cv;
this.access = access;
this.fieldName = fieldName;
}
@Override
public FieldVisitor visitField(int access, String name, String desc,
String signature, Object value) {
if (name.equals(fieldName)) {
isFieldPresent = true;
}
return cv.visitField(access, name, desc, signature, value);
}
@Override
public void visitEnd() {
if (!isFieldPresent) {
FieldVisitor fv = cv.visitField(access, fieldName, Type.BOOLEAN_TYPE.toString(), null, null);
if (fv != null) {
fv.visitEnd();
}
}
cv.visitEnd();
}
}
}

View File

@ -1,6 +1,6 @@
package com.baeldung.examples.asm.instrumentation;
package com.baeldung.asm.instrumentation;
import com.baeldung.examples.asm.CustomClassWriter;
import com.baeldung.asm.CustomClassWriter;
import java.lang.instrument.ClassFileTransformer;
import java.lang.instrument.IllegalClassFormatException;
import java.lang.instrument.Instrumentation;

View File

@ -1,5 +1,16 @@
package com.baeldung.bytebuddy;
import static net.bytebuddy.matcher.ElementMatchers.isDeclaredBy;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.returns;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import org.junit.Test;
import net.bytebuddy.ByteBuddy;
import net.bytebuddy.agent.ByteBuddyAgent;
import net.bytebuddy.dynamic.DynamicType;
@ -8,14 +19,6 @@ import net.bytebuddy.dynamic.loading.ClassReloadingStrategy;
import net.bytebuddy.implementation.FixedValue;
import net.bytebuddy.implementation.MethodDelegation;
import net.bytebuddy.matcher.ElementMatchers;
import org.junit.Test;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import static net.bytebuddy.matcher.ElementMatchers.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
public class ByteBuddyUnitTest {

9
libraries-cli/.gitignore vendored Normal file
View File

@ -0,0 +1,9 @@
*.class
# Folders #
/gensrc
/target
# Packaged files #
*.jar
/bin/

9
libraries-cli/README.md Normal file
View File

@ -0,0 +1,9 @@
## Server
This module contains articles about cli libraries.
### Relevant Articles:
- [Create a Java Command Line Program with Picocli](https://www.baeldung.com/java-picocli-create-command-line-program)
- [Parsing Command-Line Parameters with JCommander](https://www.baeldung.com/jcommander-parsing-command-line-parameters)
- [Parsing Command-Line Parameters with Airline](https://www.baeldung.com/java-airline)

69
libraries-cli/pom.xml Normal file
View File

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>libraries-cli</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>libraries-cli</name>
<packaging>jar</packaging>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>${spring-boot-starter.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>info.picocli</groupId>
<artifactId>picocli</artifactId>
<version>${picocli.version}</version>
</dependency>
<dependency>
<groupId>com.beust</groupId>
<artifactId>jcommander</artifactId>
<version>${jcommander.version}</version>
</dependency>
<dependency>
<groupId>com.github.rvesse</groupId>
<artifactId>airline</artifactId>
<version>${airline.version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
</plugins>
</build>
<properties>
<picocli.version>4.7.0</picocli.version>
<jcommander.version>1.78</jcommander.version>
<airline.version>2.7.2</airline.version>
<spring-boot-starter.version>2.7.8</spring-boot-starter.version>
<spring.version>5.3.25</spring.version>
</properties>
</project>

View File

@ -1,5 +1,10 @@
package com.baeldung.jcommander.usagebilling.cli;
import static com.baeldung.jcommander.usagebilling.cli.UsageBasedBilling.FETCH_CMD;
import static com.baeldung.jcommander.usagebilling.service.FetchCurrentChargesService.getDefault;
import java.util.List;
import com.baeldung.jcommander.usagebilling.cli.splitter.ColonParameterSplitter;
import com.baeldung.jcommander.usagebilling.cli.validator.UUIDValidator;
import com.baeldung.jcommander.usagebilling.model.CurrentChargesRequest;
@ -7,13 +12,9 @@ import com.baeldung.jcommander.usagebilling.model.CurrentChargesResponse;
import com.baeldung.jcommander.usagebilling.service.FetchCurrentChargesService;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import lombok.Getter;
import java.util.List;
import static com.baeldung.jcommander.usagebilling.cli.UsageBasedBilling.*;
import static com.baeldung.jcommander.usagebilling.service.FetchCurrentChargesService.getDefault;
@Parameters(
commandNames = { FETCH_CMD },
commandDescription = "Fetch charges for a customer in the current month, can be itemized or aggregated"

View File

@ -1,5 +1,11 @@
package com.baeldung.jcommander.usagebilling.cli;
import static com.baeldung.jcommander.usagebilling.cli.UsageBasedBilling.SUBMIT_CMD;
import static com.baeldung.jcommander.usagebilling.service.SubmitUsageService.getDefault;
import java.math.BigDecimal;
import java.time.Instant;
import com.baeldung.jcommander.usagebilling.cli.converter.ISO8601TimestampConverter;
import com.baeldung.jcommander.usagebilling.cli.validator.UUIDValidator;
import com.baeldung.jcommander.usagebilling.model.UsageRequest;
@ -7,14 +13,9 @@ import com.baeldung.jcommander.usagebilling.model.UsageRequest.PricingType;
import com.baeldung.jcommander.usagebilling.service.SubmitUsageService;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.Parameters;
import lombok.Getter;
import java.math.BigDecimal;
import java.time.Instant;
import static com.baeldung.jcommander.usagebilling.cli.UsageBasedBilling.*;
import static com.baeldung.jcommander.usagebilling.service.SubmitUsageService.getDefault;
@Parameters(
commandNames = { SUBMIT_CMD },
commandDescription = "Submit usage for a given customer and subscription, accepts one usage item"

View File

@ -1,7 +1,6 @@
package com.baeldung.jcommander.usagebilling.cli.converter;
import com.beust.jcommander.ParameterException;
import com.beust.jcommander.converters.BaseConverter;
import static java.lang.String.format;
import java.time.Instant;
import java.time.LocalDateTime;
@ -9,7 +8,8 @@ import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import static java.lang.String.format;
import com.beust.jcommander.ParameterException;
import com.beust.jcommander.converters.BaseConverter;
public class ISO8601TimestampConverter extends BaseConverter<Instant> {

View File

@ -1,10 +1,10 @@
package com.baeldung.jcommander.usagebilling.cli.splitter;
import com.beust.jcommander.converters.IParameterSplitter;
import static java.util.Arrays.asList;
import java.util.List;
import static java.util.Arrays.asList;
import com.beust.jcommander.converters.IParameterSplitter;
public class ColonParameterSplitter implements IParameterSplitter {

View File

@ -1,10 +1,10 @@
package com.baeldung.jcommander.usagebilling.cli.validator;
import java.util.regex.Pattern;
import com.beust.jcommander.IParameterValidator;
import com.beust.jcommander.ParameterException;
import java.util.regex.Pattern;
public class UUIDValidator implements IParameterValidator {
private static final String UUID_REGEX =

View File

@ -1,9 +1,13 @@
package com.baeldung.jcommander.usagebilling.model;
import lombok.*;
import java.util.List;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
@NoArgsConstructor(access = AccessLevel.PACKAGE)
@AllArgsConstructor(access = AccessLevel.PACKAGE)
@Builder

View File

@ -1,11 +1,15 @@
package com.baeldung.jcommander.usagebilling.model;
import lombok.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
@NoArgsConstructor(access = AccessLevel.PACKAGE)
@AllArgsConstructor(access = AccessLevel.PACKAGE)
@Builder

View File

@ -1,10 +1,14 @@
package com.baeldung.jcommander.usagebilling.model;
import lombok.*;
import java.math.BigDecimal;
import java.time.Instant;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;
@NoArgsConstructor(access = AccessLevel.PACKAGE)
@AllArgsConstructor(access = AccessLevel.PACKAGE)
@Builder

View File

@ -1,13 +1,5 @@
package com.baeldung.jcommander.usagebilling.service;
import com.baeldung.jcommander.usagebilling.model.CurrentChargesRequest;
import com.baeldung.jcommander.usagebilling.model.CurrentChargesResponse;
import com.baeldung.jcommander.usagebilling.model.CurrentChargesResponse.LineItem;
import java.math.BigDecimal;
import java.util.List;
import java.util.UUID;
import static java.lang.String.format;
import static java.util.Arrays.asList;
import static java.util.Arrays.fill;
@ -15,6 +7,14 @@ import static java.util.Collections.emptyList;
import static java.util.concurrent.ThreadLocalRandom.current;
import static java.util.stream.Collectors.toList;
import java.math.BigDecimal;
import java.util.List;
import java.util.UUID;
import com.baeldung.jcommander.usagebilling.model.CurrentChargesRequest;
import com.baeldung.jcommander.usagebilling.model.CurrentChargesResponse;
import com.baeldung.jcommander.usagebilling.model.CurrentChargesResponse.LineItem;
class DefaultFetchCurrentChargesService implements FetchCurrentChargesService {
@Override

View File

@ -1,9 +1,9 @@
package com.baeldung.jcommander.usagebilling.service;
import com.baeldung.jcommander.usagebilling.model.UsageRequest;
import java.util.UUID;
import com.baeldung.jcommander.usagebilling.model.UsageRequest;
class DefaultSubmitUsageService implements SubmitUsageService {
@Override

View File

@ -1,13 +1,15 @@
package com.baeldung.picocli.git;
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.picocli.git.commands.programmative.GitCommand;
import com.baeldung.picocli.git.commands.subcommands.GitAddCommand;
import com.baeldung.picocli.git.commands.subcommands.GitCommitCommand;
import com.baeldung.picocli.git.commands.subcommands.GitConfigCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import picocli.CommandLine;
@SpringBootApplication

View File

@ -1,14 +1,15 @@
package com.baeldung.picocli.git.commands.declarative;
import com.baeldung.picocli.git.model.ConfigElement;
import com.baeldung.picocli.git.commands.subcommands.GitAddCommand;
import com.baeldung.picocli.git.commands.subcommands.GitCommitCommand;
import com.baeldung.picocli.git.commands.subcommands.GitConfigCommand;
import picocli.CommandLine;
import static picocli.CommandLine.*;
import static picocli.CommandLine.Command;
import com.baeldung.picocli.git.commands.subcommands.GitAddCommand;
import com.baeldung.picocli.git.commands.subcommands.GitCommitCommand;
import com.baeldung.picocli.git.commands.subcommands.GitConfigCommand;
import com.baeldung.picocli.git.model.ConfigElement;
import picocli.CommandLine;
@Command(
name = "git",
subcommands = {

View File

@ -1,9 +1,9 @@
package com.baeldung.picocli.git.commands.methods;
import picocli.CommandLine;
import static picocli.CommandLine.Command;
import picocli.CommandLine;
@Command(name = "git")
public class GitCommand implements Runnable {
public static void main(String[] args) {

View File

@ -1,13 +1,15 @@
package com.baeldung.picocli.git.commands.programmative;
import com.baeldung.picocli.git.commands.subcommands.GitAddCommand;
import com.baeldung.picocli.git.commands.subcommands.GitCommitCommand;
import org.springframework.stereotype.Component;
import picocli.CommandLine;
import static picocli.CommandLine.Command;
import static picocli.CommandLine.RunLast;
import org.springframework.stereotype.Component;
import com.baeldung.picocli.git.commands.subcommands.GitAddCommand;
import com.baeldung.picocli.git.commands.subcommands.GitCommitCommand;
import picocli.CommandLine;
@Command(name = "git")
@Component
public class GitCommand implements Runnable {

View File

@ -1,11 +1,11 @@
package com.baeldung.picocli.git.commands.subcommands;
import org.springframework.stereotype.Component;
import static picocli.CommandLine.*;
import java.nio.file.Path;
import java.util.List;
import static picocli.CommandLine.*;
import org.springframework.stereotype.Component;
@Command(
name = "add"

View File

@ -1,10 +1,10 @@
package com.baeldung.picocli.git.commands.subcommands;
import org.springframework.stereotype.Component;
import static picocli.CommandLine.Command;
import static picocli.CommandLine.Option;
import org.springframework.stereotype.Component;
@Command(
name = "commit"
)

View File

@ -1,11 +1,12 @@
package com.baeldung.picocli.git.commands.subcommands;
import com.baeldung.picocli.git.model.ConfigElement;
import org.springframework.stereotype.Component;
import static picocli.CommandLine.Command;
import static picocli.CommandLine.Parameters;
import org.springframework.stereotype.Component;
import com.baeldung.picocli.git.model.ConfigElement;
@Command(
name = "config"
)

View File

@ -1,9 +1,9 @@
package com.baeldung.picocli.helloworld;
import picocli.CommandLine;
import static picocli.CommandLine.Command;
import picocli.CommandLine;
@Command(
name = "hello",
description = "Says hello"

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</configuration>

View File

@ -1,9 +1,10 @@
package com.baeldung.jcommander.helloworld;
import com.beust.jcommander.JCommander;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import com.beust.jcommander.JCommander;
public class HelloWorldAppUnitTest {

View File

@ -1,11 +1,12 @@
package com.baeldung.jcommander.usagebilling.cli;
import com.beust.jcommander.JCommander;
import org.junit.Test;
import static org.hamcrest.collection.IsIterableContainingInOrder.contains;
import static org.junit.Assert.assertThat;
import org.junit.Test;
import com.beust.jcommander.JCommander;
public class FetchCurrentChargesCommandUnitTest {
private JCommander jc = JCommander.newBuilder()

View File

@ -1,12 +1,11 @@
package com.baeldung.jcommander.usagebilling.cli;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.Test;
import com.beust.jcommander.JCommander;
import com.beust.jcommander.ParameterException;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class SubmitUsageCommandUnitTest {

9
libraries-reporting/.gitignore vendored Normal file
View File

@ -0,0 +1,9 @@
*.class
# Folders #
/gensrc
/target
# Packaged files #
*.jar
/bin/

View File

@ -0,0 +1,8 @@
## Server
This module contains articles about reporting libraries.
### Relevant Articles:
- [JasperReports with Spring](https://www.baeldung.com/spring-jasper)
- [Spring Yarg Integration](https://www.baeldung.com/spring-yarg)

View File

@ -0,0 +1,75 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>libraries-reporting</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>libraries-reporting</name>
<packaging>jar</packaging>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>${spring-boot-starter.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>${javax.servlet.version}</version>
</dependency>
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>${jasperreports.version}</version>
<exclusions>
<exclusion>
<artifactId>commons-logging</artifactId>
<groupId>commons-logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.haulmont.yarg</groupId>
<artifactId>yarg</artifactId>
<version>${yarg.version}</version>
<exclusions>
<exclusion>
<groupId>org.olap4j</groupId>
<artifactId>olap4j</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<properties>
<spring-boot-starter.version>2.7.8</spring-boot-starter.version>
<spring.version>5.3.25</spring.version>
<javax.servlet.version>2.5</javax.servlet.version>
<jasperreports.version>6.20.0</jasperreports.version>
<yarg.version>2.0.12</yarg.version>
</properties>
</project>

View File

@ -5,6 +5,16 @@
*/
package com.baeldung.yarg;
import java.io.File;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.FileUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.haulmont.yarg.formatters.factory.DefaultFormatterFactory;
import com.haulmont.yarg.loaders.factory.DefaultLoaderFactory;
import com.haulmont.yarg.loaders.impl.JsonDataLoader;
@ -16,13 +26,6 @@ import com.haulmont.yarg.structure.ReportOutputType;
import com.haulmont.yarg.structure.impl.BandBuilder;
import com.haulmont.yarg.structure.impl.ReportBuilder;
import com.haulmont.yarg.structure.impl.ReportTemplateBuilder;
import java.io.File;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.io.FileUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class DocumentController {

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</configuration>

9
libraries-stream/.gitignore vendored Normal file
View File

@ -0,0 +1,9 @@
*.class
# Folders #
/gensrc
/target
# Packaged files #
*.jar
/bin/

View File

@ -0,0 +1,11 @@
## Server
This module contains articles about stream libraries.
### Relevant Articles:
- [Merging Streams in Java](https://www.baeldung.com/java-merge-streams)
- [Guide to Java Parallel Collectors Library](https://www.baeldung.com/java-parallel-collectors)
- [DistinctBy in the Java Stream API](https://www.baeldung.com/java-streams-distinct-by)
- [Introduction to StreamEx](https://www.baeldung.com/streamex)
- [Introduction to Protonpack](https://www.baeldung.com/java-protonpack)

59
libraries-stream/pom.xml Normal file
View File

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>libraries-stream</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>libraries-stream</name>
<packaging>jar</packaging>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-modules</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>
<dependencies>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jool</artifactId>
<version>${jool.version}</version>
</dependency>
<dependency>
<groupId>com.pivovarit</groupId>
<artifactId>parallel-collectors</artifactId>
<version>${parallel-collectors.version}</version>
</dependency>
<dependency>
<groupId>io.vavr</groupId>
<artifactId>vavr</artifactId>
<version>${vavr.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.collections</groupId>
<artifactId>eclipse-collections</artifactId>
<version>${eclipse-collections.version}</version>
</dependency>
<dependency>
<groupId>one.util</groupId>
<artifactId>streamex</artifactId>
<version>${streamex.version}</version>
</dependency>
<dependency>
<groupId>com.codepoetics</groupId>
<artifactId>protonpack</artifactId>
<version>${protonpack.version}</version>
</dependency>
</dependencies>
<properties>
<jool.version>0.9.12</jool.version>
<parallel-collectors.version>1.1.0</parallel-collectors.version>
<vavr.version>0.9.0</vavr.version>
<eclipse-collections.version>8.2.0</eclipse-collections.version>
<streamex.version>0.8.1</streamex.version>
<protonpack.version>1.15</protonpack.version>
</properties>
</project>

View File

@ -7,6 +7,7 @@ import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import one.util.streamex.DoubleStreamEx;
import one.util.streamex.EntryStream;
import one.util.streamex.IntStreamEx;

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</configuration>

View File

@ -1,7 +1,7 @@
package com.baeldung.distinct;
import static org.junit.Assert.assertTrue;
import static com.baeldung.distinct.DistinctWithJavaFunction.distinctByKey;
import static org.junit.Assert.assertTrue;
import java.util.List;
import java.util.stream.Collectors;

View File

@ -1,11 +1,9 @@
package com.baeldung.protonpack;
import com.codepoetics.protonpack.Indexed;
import com.codepoetics.protonpack.StreamUtils;
import com.codepoetics.protonpack.collectors.CollectorUtils;
import com.codepoetics.protonpack.collectors.NonUniqueValueException;
import com.codepoetics.protonpack.selectors.Selectors;
import org.junit.Test;
import static java.util.Arrays.asList;
import static java.util.Arrays.stream;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import java.util.List;
import java.util.Optional;
@ -13,10 +11,13 @@ import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static java.util.Arrays.asList;
import static java.util.Arrays.stream;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
import org.junit.Test;
import com.codepoetics.protonpack.Indexed;
import com.codepoetics.protonpack.StreamUtils;
import com.codepoetics.protonpack.collectors.CollectorUtils;
import com.codepoetics.protonpack.collectors.NonUniqueValueException;
import com.codepoetics.protonpack.selectors.Selectors;
public class ProtonpackUnitTest {
@Test

View File

@ -1,13 +1,14 @@
package com.baeldung.streamex;
import one.util.streamex.StreamEx;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import java.util.Arrays;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import one.util.streamex.StreamEx;
public class StreamExMergeStreamsUnitTest {

View File

@ -10,9 +10,7 @@ Remember, for advanced libraries like [Jackson](/jackson) and [JUnit](/testing-m
### Relevant articles
- [Introduction to Javatuples](https://www.baeldung.com/java-tuples)
- [Introduction to Javassist](https://www.baeldung.com/javassist)
- [Intro to JaVers](https://www.baeldung.com/javers)
- [Merging Streams in Java](https://www.baeldung.com/java-merge-streams)
- [Introduction to Quartz](https://www.baeldung.com/quartz)
- [How to Warm Up the JVM](https://www.baeldung.com/java-jvm-warmup)
- [Software Transactional Memory in Java Using Multiverse](https://www.baeldung.com/java-multiverse-stm)

View File

@ -40,11 +40,6 @@
<artifactId>javatuples</artifactId>
<version>${javatuples.version}</version>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>${javaassist.version}</version>
</dependency>
<dependency>
<groupId>org.javers</groupId>
<artifactId>javers-core</artifactId>
@ -120,11 +115,6 @@
<artifactId>quartz</artifactId>
<version>${quartz.version}</version>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jool</artifactId>
<version>${jool.version}</version>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
@ -289,8 +279,6 @@
<spring.version>4.3.8.RELEASE</spring.version>
<spring-mock-mvc.version>3.0.3</spring-mock-mvc.version>
<quartz.version>2.3.0</quartz.version>
<javaassist.version>3.29.2-GA</javaassist.version>
<jool.version>0.9.12</jool.version>
<commons-net.version>3.6</commons-net.version>
<commonsio.version>2.6</commonsio.version>
</properties>

10
pom.xml
View File

@ -709,7 +709,6 @@
<module>apache-tika</module>
<module>apache-velocity</module>
<module>asciidoctor</module>
<module>asm</module>
<module>atomix</module>
<module>aws-modules</module>
<module>azure</module>
@ -777,6 +776,8 @@
<module>libraries-apache-commons-collections</module>
<module>libraries-apache-commons-io</module>
<module>libraries-apache-commons</module>
<module>libraries-bytecode</module>
<module>libraries-cli</module>
<module>libraries-concurrency</module>
<module>libraries-data-2</module>
<module>libraries-data-db</module>
@ -788,10 +789,12 @@
<module>libraries-io</module>
<module>libraries-llms</module>
<module>libraries-primitive</module>
<module>libraries-reporting</module>
<module>libraries-rpc</module>
<module>libraries-security</module>
<module>libraries-server-2</module>
<module>libraries-server</module>
<module>libraries-stream</module>
<module>libraries-testing</module>
<module>libraries-transform</module>
<module>libraries</module> <!-- very long running -->
@ -956,7 +959,6 @@
<module>apache-tika</module>
<module>apache-velocity</module>
<module>asciidoctor</module>
<module>asm</module>
<module>atomix</module>
<module>aws-modules</module>
<module>azure</module>
@ -1024,6 +1026,8 @@
<module>libraries-apache-commons-collections</module>
<module>libraries-apache-commons-io</module>
<module>libraries-apache-commons</module>
<module>libraries-bytecode</module>
<module>libraries-cli</module>
<module>libraries-concurrency</module>
<module>libraries-data-2</module>
<module>libraries-data-db</module>
@ -1035,10 +1039,12 @@
<module>libraries-io</module>
<module>libraries-llms</module>
<module>libraries-primitive</module>
<module>libraries-reporting</module>
<module>libraries-rpc</module>
<module>libraries-security</module>
<module>libraries-server-2</module>
<module>libraries-server</module>
<module>libraries-stream</module>
<module>libraries-testing</module>
<module>libraries-transform</module>
<module>libraries</module> <!-- very long running -->