Skip to content

Commit 410ce3d

Browse files
committed
merge from upstream
2 parents 3960410 + 12124f3 commit 410ce3d

449 files changed

Lines changed: 5846 additions & 3486 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.

‎JGit/pom.xml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
44
<modelVersion>4.0.0</modelVersion>
55
<groupId>com.baeldung</groupId>
6-
<artifactId>JGitSnippets</artifactId>
6+
<artifactId>JGit</artifactId>
77
<version>1.0-SNAPSHOT</version>
88
<packaging>jar</packaging>
99
<url>http://maven.apache.org</url>
10+
<name>JGit</name>
1011

1112
<parent>
1213
<groupId>com.baeldung</groupId>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.baeldung.algorithms.distancebetweenpoints;
2+
3+
import java.awt.geom.Point2D;
4+
5+
public class DistanceBetweenPointsService {
6+
7+
public double calculateDistanceBetweenPoints(
8+
double x1,
9+
double y1,
10+
double x2,
11+
double y2) {
12+
13+
return Math.sqrt((y2 - y1) * (y2 - y1) + (x2 - x1) * (x2 - x1));
14+
}
15+
16+
public double calculateDistanceBetweenPointsWithHypot(
17+
double x1,
18+
double y1,
19+
double x2,
20+
double y2) {
21+
22+
double ac = Math.abs(y2 - y1);
23+
double cb = Math.abs(x2 - x1);
24+
25+
return Math.hypot(ac, cb);
26+
}
27+
28+
public double calculateDistanceBetweenPointsWithPoint2D(
29+
double x1,
30+
double y1,
31+
double x2,
32+
double y2) {
33+
34+
return Point2D.distance(x1, y1, x2, y2);
35+
36+
}
37+
38+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package com.baeldung.algorithms.rectanglesoverlap;
2+
3+
public class Point {
4+
5+
private int x;
6+
private int y;
7+
8+
public Point(int x, int y) {
9+
this.x = x;
10+
this.y = y;
11+
}
12+
13+
public int getX() {
14+
return x;
15+
}
16+
17+
public void setX(int x) {
18+
this.x = x;
19+
}
20+
21+
public int getY() {
22+
return y;
23+
}
24+
25+
public void setY(int y) {
26+
this.y = y;
27+
}
28+
29+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.baeldung.algorithms.rectanglesoverlap;
2+
3+
public class Rectangle {
4+
5+
private Point bottomLeft;
6+
private Point topRight;
7+
8+
public Rectangle(Point bottomLeft, Point topRight) {
9+
this.bottomLeft = bottomLeft;
10+
this.topRight = topRight;
11+
}
12+
13+
public Point getBottomLeft() {
14+
return bottomLeft;
15+
}
16+
17+
public void setBottomLeft(Point bottomLeft) {
18+
this.bottomLeft = bottomLeft;
19+
}
20+
21+
public Point getTopRight() {
22+
return topRight;
23+
}
24+
25+
public void setTopRight(Point topRight) {
26+
this.topRight = topRight;
27+
}
28+
29+
public boolean isOverlapping(Rectangle other) {
30+
// one rectangle is to the top of the other
31+
if (this.topRight.getY() < other.bottomLeft.getY() || this.bottomLeft.getY() > other.topRight.getY()) {
32+
return false;
33+
}
34+
// one rectangle is to the left of the other
35+
if (this.topRight.getX() < other.bottomLeft.getX() || this.bottomLeft.getX() > other.topRight.getX()) {
36+
return false;
37+
}
38+
return true;
39+
}
40+
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package com.baeldung.algorithms.distancebetweenpoints;
2+
3+
import org.junit.Test;
4+
5+
import com.baeldung.algorithms.distancebetweenpoints.DistanceBetweenPointsService;
6+
7+
import static org.junit.Assert.assertEquals;
8+
9+
public class DistanceBetweenPointsServiceUnitTest {
10+
11+
private DistanceBetweenPointsService service = new DistanceBetweenPointsService();
12+
13+
@Test
14+
public void givenTwoPoints_whenCalculateDistanceByFormula_thenCorrect() {
15+
16+
double x1 = 3;
17+
double y1 = 4;
18+
double x2 = 7;
19+
double y2 = 1;
20+
21+
double distance = service.calculateDistanceBetweenPoints(x1, y1, x2, y2);
22+
23+
assertEquals(distance, 5, 0.001);
24+
25+
}
26+
27+
@Test
28+
public void givenTwoPoints_whenCalculateDistanceWithHypot_thenCorrect() {
29+
30+
double x1 = 3;
31+
double y1 = 4;
32+
double x2 = 7;
33+
double y2 = 1;
34+
35+
double distance = service.calculateDistanceBetweenPointsWithHypot(x1, y1, x2, y2);
36+
37+
assertEquals(distance, 5, 0.001);
38+
39+
}
40+
41+
@Test
42+
public void givenTwoPoints_whenCalculateDistanceWithPoint2D_thenCorrect() {
43+
44+
double x1 = 3;
45+
double y1 = 4;
46+
double x2 = 7;
47+
double y2 = 1;
48+
49+
double distance = service.calculateDistanceBetweenPointsWithPoint2D(x1, y1, x2, y2);
50+
51+
assertEquals(distance, 5, 0.001);
52+
53+
}
54+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package com.baeldung.algorithms.rectanglesoverlap;
2+
3+
import static org.junit.Assert.assertTrue;
4+
import static org.junit.Assert.assertFalse;
5+
import org.junit.Test;
6+
7+
import com.baeldung.algorithms.rectanglesoverlap.Point;
8+
import com.baeldung.algorithms.rectanglesoverlap.Rectangle;
9+
10+
public class RectangleUnitTest {
11+
12+
@Test
13+
public void givenTwoOverlappingRectangles_whenisOverlappingCalled_shouldReturnTrue() {
14+
Rectangle rectangle1 = new Rectangle(new Point(2, 1), new Point(4, 3));
15+
Rectangle rectangle2 = new Rectangle(new Point(1, 1), new Point(6, 4));
16+
assertTrue(rectangle1.isOverlapping(rectangle2));
17+
18+
rectangle1 = new Rectangle(new Point(-5, -2), new Point(2, 3));
19+
rectangle2 = new Rectangle(new Point(-2, -1), new Point(5, 2));
20+
assertTrue(rectangle1.isOverlapping(rectangle2));
21+
22+
rectangle1 = new Rectangle(new Point(-5, 1), new Point(2, 4));
23+
rectangle2 = new Rectangle(new Point(-2, -2), new Point(5, 5));
24+
assertTrue(rectangle1.isOverlapping(rectangle2));
25+
}
26+
27+
@Test
28+
public void givenTwoNonOverlappingRectangles_whenisOverlappingCalled_shouldReturnFalse() {
29+
Rectangle rectangle1 = new Rectangle(new Point(-5, 1), new Point(-3, 4));
30+
Rectangle rectangle2 = new Rectangle(new Point(-2, -2), new Point(5, 5));
31+
assertFalse(rectangle1.isOverlapping(rectangle2));
32+
33+
rectangle1 = new Rectangle(new Point(-5, 1), new Point(3, 4));
34+
rectangle2 = new Rectangle(new Point(-2, -2), new Point(5, -1));
35+
assertFalse(rectangle1.isOverlapping(rectangle2));
36+
37+
rectangle1 = new Rectangle(new Point(-2, 1), new Point(0, 3));
38+
rectangle2 = new Rectangle(new Point(3, 1), new Point(5, 4));
39+
assertFalse(rectangle1.isOverlapping(rectangle2));
40+
}
41+
42+
}

‎apache-avro/pom.xml‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<modelVersion>4.0.0</modelVersion>
66
<groupId>com.baeldung</groupId>
7-
<artifactId>apache-avro-tutorial</artifactId>
7+
<artifactId>apache-avro</artifactId>
88
<version>0.0.1-SNAPSHOT</version>
9+
<name>Apache Avro</version>
910

1011
<properties>
1112
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

‎apache-cxf/README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
- [Apache CXF Support for RESTful Web Services](http://www.baeldung.com/apache-cxf-rest-api)
44
- [A Guide to Apache CXF with Spring](http://www.baeldung.com/apache-cxf-with-spring)
55
- [Introduction to Apache CXF](http://www.baeldung.com/introduction-to-apache-cxf)
6+
- [Server-Sent Events (SSE) In JAX-RS](https://www.baeldung.com/java-ee-jax-rs-sse)

‎apache-cxf/sse-jaxrs/sse-jaxrs-server/pom.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
</properties>
2121

2222
<build>
23-
<finalName>${artifactId}</finalName>
23+
<finalName>${project.artifactId}</finalName>
2424
<plugins>
2525
<plugin>
2626
<groupId>net.wasdev.wlp.maven.plugins</groupId>

‎aws/.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/target/
2+
.idea/

0 commit comments

Comments
 (0)