Skip to content

Commit 28c33f8

Browse files
authored
Merge pull request eugenp#7 from eugenp/master
getting latest changes
2 parents 04c255c + 6b0b190 commit 28c33f8

File tree

944 files changed

+20937
-3765
lines changed

Some content is hidden

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

944 files changed

+20937
-3765
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,5 @@ jmeter/src/main/resources/*-JMeter.csv
6262
**/dist
6363
**/tmp
6464
**/out-tsc
65+
**/nbproject/
66+
**/nb-configuration.xml

README.md

+7-26
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,22 @@
22
The "REST with Spring" Classes
33
==============================
44

5-
Here's the Master Class of REST With Spring (price changes permanently next Friday): <br/>
6-
**[>> THE REST WITH SPRING MASTER CLASS](http://www.baeldung.com/rest-with-spring-course?utm_source=github&utm_medium=social&utm_content=tutorials&utm_campaign=rws#master-class)**
5+
Here's the Master Class of REST With Spring (along with the newly announced Boot 2 material): <br/>
6+
**[>> THE REST WITH SPRING - MASTER CLASS](http://www.baeldung.com/rest-with-spring-course?utm_source=github&utm_medium=social&utm_content=tutorials&utm_campaign=rws#master-class)**
77

88
And here's the Master Class of Learn Spring Security: <br/>
9-
**[>> LEARN SPRING SECURITY MASTER CLASS](http://www.baeldung.com/learn-spring-security-course?utm_source=github&utm_medium=social&utm_content=tutorials&utm_campaign=lss#master-class)**
9+
**[>> LEARN SPRING SECURITY - MASTER CLASS](http://www.baeldung.com/learn-spring-security-course?utm_source=github&utm_medium=social&utm_content=tutorials&utm_campaign=lss#master-class)**
1010

1111

1212

13-
Spring Tutorials
13+
Java and Spring Tutorials
1414
================
1515

16-
This project is **a collection of small and focused tutorials** each covering a single and well defined area of development.
17-
Most of the tutorial projects are focused on the `Spring Framework` (and `Spring Security`).
16+
This project is **a collection of small and focused tutorials** - each covering a single and well defined area of development in the Java ecosystem.
17+
A strong focus of these is, of course, the Spring Framework - Spring, Spring Boot and Spring Securiyt.
1818
In additional to Spring, the following technologies are in focus: `core Java`, `Jackson`, `HttpClient`, `Guava`.
1919

20+
2021
Building the project
2122
====================
2223
To do the full build, do: `mvn install -Pdefault -Dgib.enabled=false`
23-
24-
25-
Working with the code in Eclipse
26-
================================
27-
Any IDE can be used to work with the projects, but if you're using Eclipse, consider the following.
28-
29-
- import the included **formatter** in Eclipse:
30-
`https://github.com/eugenp/tutorials/tree/master/eclipse`
31-
32-
33-
CI - Jenkins
34-
================================
35-
This tutorials project is being built **[>> HERE](https://rest-security.ci.cloudbees.com/job/tutorials-unit/)**
36-
37-
### Relevant Articles:
38-
================================
39-
40-
- [Apache Maven Standard Directory Layout](http://www.baeldung.com/maven-directory-structure)
41-
- [Apache Maven Tutorial](http://www.baeldung.com/maven)
42-
- [Designing a User Friendly Java Library](http://www.baeldung.com/design-a-user-friendly-java-library)

Twitter4J/pom.xml

-25
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
22
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
33
<modelVersion>4.0.0</modelVersion>
4-
5-
<groupId>com.mabsisa</groupId>
64
<artifactId>Twitter4J</artifactId>
75
<packaging>jar</packaging>
8-
<version>1.0-SNAPSHOT</version>
96
<name>Twitter4J</name>
10-
<url>http://maven.apache.org</url>
117

128
<parent>
139
<groupId>com.baeldung</groupId>
@@ -23,27 +19,6 @@
2319
</dependency>
2420
</dependencies>
2521

26-
<build>
27-
<finalName>${project.artifactId}</finalName>
28-
<resources>
29-
<resource>
30-
<directory>src/main/resources</directory>
31-
</resource>
32-
</resources>
33-
<plugins>
34-
<plugin>
35-
<groupId>org.apache.maven.plugins</groupId>
36-
<artifactId>maven-surefire-plugin</artifactId>
37-
<version>${maven-surefire-plugin.version}</version>
38-
<configuration>
39-
<excludes>
40-
<exclude>**/ApplicationTest.java</exclude>
41-
</excludes>
42-
</configuration>
43-
</plugin>
44-
</plugins>
45-
</build>
46-
4722
<properties>
4823
<twitter4j-stream.version>4.0.6</twitter4j-stream.version>
4924
</properties>

activejdbc/pom.xml

+1-46
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
22
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
33
<modelVersion>4.0.0</modelVersion>
4-
<groupId>com.baeldung</groupId>
54
<artifactId>activejdbc</artifactId>
65
<version>1.0-SNAPSHOT</version>
76
<packaging>jar</packaging>
@@ -79,55 +78,11 @@
7978
</dependency>
8079
</dependencies>
8180
</plugin>
82-
<plugin>
83-
<groupId>org.apache.maven.plugins</groupId>
84-
<artifactId>maven-surefire-plugin</artifactId>
85-
<version>${maven-surefire-plugin.version}</version>
86-
<configuration>
87-
<reportFormat>brief</reportFormat>
88-
<trimStackTrace>true</trimStackTrace>
89-
<useFile>false</useFile>
90-
<includes>
91-
<include>**/*Spec*.java</include>
92-
<include>**/*Test*.java</include>
93-
</includes>
94-
<excludes>
95-
<exclude>**/helpers/*</exclude>
96-
<exclude>**/*$*</exclude>
97-
</excludes>
98-
</configuration>
99-
</plugin>
10081
</plugins>
10182
</build>
10283

103-
<repositories>
104-
<repository>
105-
<id>snapshots1</id>
106-
<name>JavaLite Snapshots1</name>
107-
<url>http://repo.javalite.io/</url>
108-
<snapshots>
109-
<enabled>true</enabled>
110-
<updatePolicy>always</updatePolicy>
111-
<checksumPolicy>warn</checksumPolicy>
112-
</snapshots>
113-
</repository>
114-
</repositories>
115-
116-
<pluginRepositories>
117-
<pluginRepository>
118-
<id>snapshots2</id>
119-
<name>JavaLite Snapshots2</name>
120-
<url>http://repo.javalite.io/</url>
121-
<snapshots>
122-
<enabled>true</enabled>
123-
<updatePolicy>always</updatePolicy>
124-
<checksumPolicy>warn</checksumPolicy>
125-
</snapshots>
126-
</pluginRepository>
127-
</pluginRepositories>
128-
12984
<properties>
130-
<activejdbc.version>1.4.13</activejdbc.version>
85+
<activejdbc.version>2.0</activejdbc.version>
13186
<environments>development.test,development</environments>
13287
<mysql.connector.version>5.1.34</mysql.connector.version>
13388
</properties>

activejdbc/src/main/java/com/baeldung/model/Employee.java

+4
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,8 @@ public Employee(String firstName, String lastName, String gender, String created
1616
set("created_by",createdBy);
1717
}
1818

19+
public String getLastName() {
20+
return getString("last_name");
21+
}
22+
1923
}

activejdbc/src/main/java/com/baeldung/model/Role.java

+4
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,8 @@ public Role(String role,String createdBy){
1515
set("role_name",role);
1616
set("created_by",createdBy);
1717
}
18+
19+
public String getRoleName() {
20+
return getString("role_name");
21+
}
1822
}

activejdbc/src/test/java/com/baeldung/ActiveJDBCAppTest.java renamed to activejdbc/src/test/java/com/baeldung/ActiveJDBCAppManualTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import java.util.List;
99

10-
public class ActiveJDBCAppTest extends DBSpec
10+
public class ActiveJDBCAppManualTest extends DBSpec
1111
{
1212
@Test
1313
public void ifEmployeeCreated_thenIsValid() {

algorithms/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,7 @@
2424
- [Practical Java Examples of the Big O Notation](http://www.baeldung.com/java-algorithm-complexity)
2525
- [Find the Middle Element of a Linked List](http://www.baeldung.com/java-linked-list-middle-element)
2626
- [An Introduction to the Theory of Big-O Notation](http://www.baeldung.com/big-o-notation)
27+
- [Check If Two Rectangles Overlap In Java](https://www.baeldung.com/java-check-if-two-rectangles-overlap)
28+
- [Calculate the Distance Between Two Points in Java](https://www.baeldung.com/java-distance-between-two-points)
29+
- [Find the Intersection of Two Lines in Java](https://www.baeldung.com/java-intersection-of-two-lines)
30+
- [Check If a String Contains All The Letters of The Alphabet](https://www.baeldung.com/java-string-contains-all-letters)
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/bin/
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.java.src;
2+
3+
import java.util.Scanner;
4+
5+
public class RoundUpToHundred {
6+
7+
public static void main(String[] args) {
8+
Scanner scanner = new Scanner(System.in);
9+
double input = scanner.nextDouble();
10+
scanner.close();
11+
12+
RoundUpToHundred.round(input);
13+
}
14+
15+
static long round(double input) {
16+
long i = (long) Math.ceil(input);
17+
return ((i + 99) / 100) * 100;
18+
};
19+
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.java.src;
2+
3+
import static org.junit.Assert.assertEquals;
4+
5+
import org.junit.Test;
6+
7+
public class RoundUpToHundredTest {
8+
@Test
9+
public void givenInput_whenRound_thenRoundUpToTheNearestHundred() {
10+
assertEquals("Rounded up to hundred", 100, RoundUpToHundred.round(99));
11+
assertEquals("Rounded up to three hundred ", 300, RoundUpToHundred.round(200.2));
12+
assertEquals("Returns same rounded value", 400, RoundUpToHundred.round(400));
13+
}
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.baeldung.algorithms.insertionsort;
2+
3+
public class InsertionSort {
4+
5+
public static void insertionSortImperative(int[] input) {
6+
for (int i = 1; i < input.length; i++) {
7+
int key = input[i];
8+
int j = i - 1;
9+
while (j >= 0 && input[j] > key) {
10+
input[j + 1] = input[j];
11+
j = j - 1;
12+
}
13+
input[j + 1] = key;
14+
}
15+
}
16+
17+
public static void insertionSortRecursive(int[] input) {
18+
insertionSortRecursive(input, input.length);
19+
}
20+
21+
private static void insertionSortRecursive(int[] input, int i) {
22+
// base case
23+
if (i <= 1) {
24+
return;
25+
}
26+
27+
// sort the first i - 1 elements of the array
28+
insertionSortRecursive(input, i - 1);
29+
30+
// then find the correct position of the element at position i
31+
int key = input[i - 1];
32+
int j = i - 2;
33+
// shifting the elements from their position by 1
34+
while (j >= 0 && input[j] > key) {
35+
input[j + 1] = input[j];
36+
j = j - 1;
37+
}
38+
// inserting the key at the appropriate position
39+
input[j + 1] = key;
40+
}
41+
}

algorithms/src/main/java/com/baeldung/algorithms/kthlargest/FindKthLargest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public int findKthElementByRandomizedQuickSelect(Integer[] arr, int left, int ri
9898

9999
private int randomPartition(Integer arr[], int left, int right) {
100100
int n = right - left + 1;
101-
int pivot = (int) (Math.random()) % n;
101+
int pivot = (int) (Math.random() * n);
102102
swap(arr, left + pivot, right);
103103
return partition(arr, left, right);
104104
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package com.baeldung.algorithms.mergesort;
2+
3+
public class MergeSort {
4+
5+
public static void main(String[] args) {
6+
int[] a = { 5, 1, 6, 2, 3, 4 };
7+
mergeSort(a, a.length);
8+
for (int i = 0; i < a.length; i++)
9+
System.out.println(a[i]);
10+
}
11+
12+
public static void mergeSort(int[] a, int n) {
13+
if (n < 2)
14+
return;
15+
int mid = n / 2;
16+
int[] l = new int[mid];
17+
int[] r = new int[n - mid];
18+
19+
for (int i = 0; i < mid; i++) {
20+
l[i] = a[i];
21+
}
22+
for (int i = mid; i < n; i++) {
23+
r[i - mid] = a[i];
24+
}
25+
mergeSort(l, mid);
26+
mergeSort(r, n - mid);
27+
28+
merge(a, l, r, mid, n - mid);
29+
}
30+
31+
public static void merge(int[] a, int[] l, int[] r, int left, int right) {
32+
33+
int i = 0, j = 0, k = 0;
34+
35+
while (i < left && j < right) {
36+
37+
if (l[i] < r[j])
38+
a[k++] = l[i++];
39+
else
40+
a[k++] = r[j++];
41+
42+
}
43+
44+
while (i < left)
45+
a[k++] = l[i++];
46+
47+
while (j < right)
48+
a[k++] = r[j++];
49+
}
50+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package com.baeldung.algorithms.quicksort;
2+
3+
public class QuickSort {
4+
5+
public static void quickSort(int arr[], int begin, int end)
6+
{
7+
if (begin < end) {
8+
int partitionIndex = partition(arr, begin, end);
9+
10+
// Recursively sort elements of the 2 sub-arrays
11+
quickSort(arr, begin, partitionIndex-1);
12+
quickSort(arr, partitionIndex+1, end);
13+
}
14+
}
15+
16+
private static int partition(int arr[], int begin, int end)
17+
{
18+
int pivot = arr[end];
19+
int i = (begin-1);
20+
21+
for (int j=begin; j<end; j++)
22+
{
23+
if (arr[j] <= pivot) {
24+
i++;
25+
26+
int swapTemp = arr[i];
27+
arr[i] = arr[j];
28+
arr[j] = swapTemp;
29+
}
30+
}
31+
32+
int swapTemp = arr[i+1];
33+
arr[i+1] = arr[end];
34+
arr[end] = swapTemp;
35+
36+
return i+1;
37+
}
38+
39+
}

0 commit comments

Comments
 (0)