Skip to content

Commit a5bba1e

Browse files
authored
Merge branch 'master' into SpringReactiveKotlin
2 parents 08b0b80 + b43939d commit a5bba1e

162 files changed

Lines changed: 2919 additions & 1346 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.travis.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ before_install:
44
- echo "MAVEN_OPTS='-Xmx2048M -Xss128M -XX:+CMSClassUnloadingEnabled -XX:+UseG1GC -XX:-UseGCOverheadLimit'" > ~/.mavenrc
55

66
install: skip
7-
script: travis_wait 60 mvn -q install
7+
script: travis_wait 60 mvn -q install -Pdefault
88

99
sudo: required
1010

‎algorithms/README.md‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
- [Ant Colony Optimization](http://www.baeldung.com/java-ant-colony-optimization)
66
- [Validating Input With Finite Automata in Java](http://www.baeldung.com/java-finite-automata)
77
- [Introduction to Jenetics Library](http://www.baeldung.com/jenetics)
8-
- [Check If a Number Is Prime in Java](http://www.baeldung.com/java-prime-numbers)
98
- [Example of Hill Climbing Algorithm](http://www.baeldung.com/java-hill-climbing-algorithm)
109
- [Monte Carlo Tree Search for Tic-Tac-Toe Game](http://www.baeldung.com/java-monte-carlo-tree-search)
1110
- [String Search Algorithms for Large Texts](http://www.baeldung.com/java-full-text-search-algorithms)
@@ -21,7 +20,6 @@
2120
- [Create a Sudoku Solver in Java](http://www.baeldung.com/java-sudoku)
2221
- [Displaying Money Amounts in Words](http://www.baeldung.com/java-money-into-words)
2322
- [A Collaborative Filtering Recommendation System in Java](http://www.baeldung.com/java-collaborative-filtering-recommendations)
24-
- [Find All Pairs of Numbers in an Array That Add Up to a Given Sum](http://www.baeldung.com/java-algorithm-number-pairs-sum)
2523
- [Converting Between Roman and Arabic Numerals in Java](http://www.baeldung.com/java-convert-roman-arabic)
2624
- [Practical Java Examples of the Big O Notation](http://www.baeldung.com/java-algorithm-complexity)
2725
- [Find the Middle Element of a Linked List](http://www.baeldung.com/java-linked-list-middle-element)

‎algorithms/src/main/java/com/baeldung/algorithms/RunAlgorithm.java‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import com.baeldung.algorithms.ga.ant_colony.AntColonyOptimization;
77
import com.baeldung.algorithms.ga.binary.SimpleGeneticAlgorithm;
88
import com.baeldung.algorithms.slope_one.SlopeOne;
9-
import com.baeldung.algorithms.pairsaddupnumber.FindPairs;
109

1110
public class RunAlgorithm {
1211

@@ -39,12 +38,6 @@ public static void main(String[] args) throws InstantiationException, IllegalAcc
3938
case 5:
4039
System.out.println("Please run the DijkstraAlgorithmTest.");
4140
break;
42-
case 6:
43-
final FindPairs findPairs = new FindPairs();
44-
final int[] input = {1, 4, 3, 2, 1, 4, 4, 3, 3};
45-
final int sum = 6;
46-
findPairs.execute(input, sum);
47-
break;
4841
default:
4942
System.out.println("Unknown option");
5043
break;

‎algorithms/src/main/java/com/baeldung/algorithms/prime/PrimeGenerator.java‎

Lines changed: 0 additions & 59 deletions
This file was deleted.

‎algorithms/src/test/java/com/baeldung/algorithms/prime/PrimeGeneratorUnitTest.java‎

Lines changed: 0 additions & 28 deletions
This file was deleted.

‎bootique/pom.xml‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,16 +52,21 @@
5252

5353
<build>
5454
<plugins>
55+
5556
<plugin>
5657
<groupId>org.apache.maven.plugins</groupId>
5758
<artifactId>maven-shade-plugin</artifactId>
59+
<version>${maven-shade-plugin.version}</version>
5860
</plugin>
61+
5962
</plugins>
6063
</build>
6164

6265
<properties>
6366
<main.class>com.baeldung.bootique.App</main.class>
6467
<bootique-bom.version>0.23</bootique-bom.version>
68+
69+
<maven-shade-plugin.version>2.4.3</maven-shade-plugin.version>
6570
</properties>
6671

6772
</project>
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.baeldung.java10.list;
2+
3+
import org.junit.Test;
4+
5+
import java.util.Arrays;
6+
import java.util.List;
7+
8+
public class CopyListServiceUnitTest {
9+
10+
@Test(expected = UnsupportedOperationException.class)
11+
public void whenModifyCopyOfList_thenThrowsException() {
12+
List<Integer> copyList = List.copyOf(Arrays.asList(1, 2, 3, 4));
13+
}
14+
}

‎core-java-8/README.md‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
- [“Stream has already been operated upon or closed” Exception in Java](http://www.baeldung.com/java-stream-operated-upon-or-closed-exception)
3333
- [Display All Time Zones With GMT And UTC in Java](http://www.baeldung.com/java-time-zones)
3434
- [Copy a File with Java](http://www.baeldung.com/java-copy-file)
35-
- [Generating Prime Numbers in Java](http://www.baeldung.com/java-generate-prime-numbers)
3635
- [Static and Default Methods in Interfaces in Java](http://www.baeldung.com/java-static-default-methods)
3736
- [Iterable to Stream in Java](http://www.baeldung.com/java-iterable-to-stream)
3837
- [Converting String to Stream of chars](http://www.baeldung.com/java-string-to-stream)

‎core-java-8/pom.xml‎

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -128,77 +128,6 @@
128128
</executions>
129129
</plugin>
130130

131-
<plugin>
132-
<groupId>org.apache.maven.plugins</groupId>
133-
<artifactId>maven-jar-plugin</artifactId>
134-
<configuration>
135-
<archive>
136-
<manifest>
137-
<addClasspath>true</addClasspath>
138-
<classpathPrefix>libs/</classpathPrefix>
139-
<mainClass>org.baeldung.executable.ExecutableMavenJar</mainClass>
140-
</manifest>
141-
</archive>
142-
</configuration>
143-
</plugin>
144-
<plugin>
145-
<groupId>org.apache.maven.plugins</groupId>
146-
<artifactId>maven-assembly-plugin</artifactId>
147-
<executions>
148-
<execution>
149-
<phase>package</phase>
150-
<goals>
151-
<goal>single</goal>
152-
</goals>
153-
<configuration>
154-
<archiveBaseDirectory>${project.basedir}</archiveBaseDirectory>
155-
<archive>
156-
<manifest>
157-
<mainClass>org.baeldung.executable.ExecutableMavenJar</mainClass>
158-
</manifest>
159-
</archive>
160-
<descriptorRefs>
161-
<descriptorRef>jar-with-dependencies</descriptorRef>
162-
</descriptorRefs>
163-
</configuration>
164-
</execution>
165-
</executions>
166-
</plugin>
167-
<plugin>
168-
<groupId>org.apache.maven.plugins</groupId>
169-
<artifactId>maven-shade-plugin</artifactId>
170-
<executions>
171-
<execution>
172-
<goals>
173-
<goal>shade</goal>
174-
</goals>
175-
<configuration>
176-
<shadedArtifactAttached>true</shadedArtifactAttached>
177-
<transformers>
178-
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
179-
<mainClass>org.baeldung.executable.ExecutableMavenJar</mainClass>
180-
</transformer>
181-
</transformers>
182-
</configuration>
183-
</execution>
184-
</executions>
185-
</plugin>
186-
<plugin>
187-
<groupId>com.jolira</groupId>
188-
<artifactId>onejar-maven-plugin</artifactId>
189-
<executions>
190-
<execution>
191-
<configuration>
192-
<mainClass>org.baeldung.executable.ExecutableMavenJar</mainClass>
193-
<attachToBuild>true</attachToBuild>
194-
<filename>${project.build.finalName}-onejar.${project.packaging}</filename>
195-
</configuration>
196-
<goals>
197-
<goal>one-jar</goal>
198-
</goals>
199-
</execution>
200-
</executions>
201-
</plugin>
202131
<plugin>
203132
<groupId>org.apache.maven.plugins</groupId>
204133
<artifactId>maven-compiler-plugin</artifactId>
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
package com.baeldung.list;
2+
3+
import java.util.ArrayList;
4+
import java.util.Collections;
5+
import java.util.List;
6+
import java.util.Optional;
7+
import java.util.stream.Collectors;
8+
import java.util.stream.Stream;
9+
10+
public class CopyListService {
11+
12+
public List<Flower> copyListByConstructor(List<Flower> source) {
13+
return new ArrayList<Flower>(source);
14+
}
15+
16+
public List<Flower> copyListByConstructorAndEditOneFlowerInTheNewList(List<Flower> source) {
17+
List<Flower> flowers = new ArrayList<>(source);
18+
if(flowers.size() > 0) {
19+
flowers.get(0).setPetals(flowers.get(0).getPetals() * 3);
20+
}
21+
22+
return flowers;
23+
}
24+
25+
public List<Flower> copyListByAddAllMethod(List<Flower> source) {
26+
List<Flower> flowers = new ArrayList<>();
27+
flowers.addAll(source);
28+
return flowers;
29+
}
30+
31+
public List<Flower> copyListByAddAllMethodAndEditOneFlowerInTheNewList(List<Flower> source) {
32+
List<Flower> flowers = new ArrayList<>();
33+
flowers.addAll(source);
34+
35+
if(flowers.size() > 0) {
36+
flowers.get(0).setPetals(flowers.get(0).getPetals() * 3);
37+
}
38+
39+
return flowers;
40+
}
41+
42+
public List<Integer> copyListByCopyMethod(List<Integer> source, List<Integer> dest) {
43+
Collections.copy(dest, source);
44+
return dest;
45+
}
46+
47+
public List<Flower> copyListByStream(List<Flower> source) {
48+
return source.stream().collect(Collectors.toList());
49+
}
50+
51+
public List<Flower> copyListByStreamAndSkipFirstElement(List<Flower> source) {
52+
return source.stream().skip(1).collect(Collectors.toList());
53+
}
54+
55+
public List<Flower> copyListByStreamWithFilter(List<Flower> source, Integer moreThanPetals) {
56+
return source.stream().filter(f -> f.getPetals() > moreThanPetals).collect(Collectors.toList());
57+
}
58+
59+
public List<Flower> copyListByStreamWithOptional(List<Flower> source) {
60+
return Optional.ofNullable(source)
61+
.map(List::stream)
62+
.orElseGet(Stream::empty)
63+
.collect(Collectors.toList());
64+
}
65+
66+
public List<Flower> copyListByStreamWithOptionalAndSkip(List<Flower> source) {
67+
return Optional.ofNullable(source)
68+
.map(List::stream)
69+
.orElseGet(Stream::empty)
70+
.skip(1)
71+
.collect(Collectors.toList());
72+
}
73+
}

0 commit comments

Comments
 (0)