Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
133 commits
Select commit Hold shift + click to select a range
3af6986
BAEL-2804 JPA Query Parameters Usage - move article files to new module
tryncatch Jul 8, 2019
1c1cf0f
BAEL-2928 - Create new spring-di project with examples for Qualifier …
Jul 11, 2019
c498f08
BAEL-15951 Moved vavr, JHipster to default profiles
dkapil Jul 14, 2019
acd87d8
BAEL-2804 JPA Query Parameters Usage - formatting fixes
tryncatch Jul 14, 2019
7f747e4
Create an interface driven controller (BAEL-3095)
veontomo Jul 14, 2019
306c37c
BAEL-3014: Added sample code for lists
isaolmez Jul 15, 2019
fd0ef02
BAEL-3014: Added sample code for lists
isaolmez Jul 15, 2019
195c6bf
BAEL-3014: Added sample code for lists
isaolmez Jul 15, 2019
bc3ed26
BAEL-2990 Automatic generation of the Builder pattern with FreeBuilder
Jul 16, 2019
e409462
BAEL-2990 Automatic generation of the Builder pattern with FreeBuilder
Jul 17, 2019
ce7c306
BAEL-2990 Automatic generation of the Builder pattern with FreeBuilder
Jul 17, 2019
3671997
BAEL-3042 DynamicUpdate annotation example
kamleshkr Jul 14, 2019
b32a91a
Merge branch 'master' of https://github.com/eugenp/tutorials
Jul 24, 2019
97e38d3
BAEL-2990 Automatic generation of the Builder pattern with FreeBuilder
Jul 24, 2019
662208d
Merge branch 'master' of https://github.com/eugenp/tutorials
dkapil Jul 26, 2019
a49bd1a
BAEL-2781 - metaprogramming in groovy
SmartyAnsh Jul 27, 2019
6eb4d10
BAEL-2781 - metaprogramming in groovy
SmartyAnsh Jul 27, 2019
6a29eab
BAEL-2990 Automatic generation of the Builder pattern with FreeBuilder
Jul 28, 2019
3b3a0fc
Merge branch 'master' of https://github.com/eugenp/tutorials
Jul 28, 2019
f71224e
BAEL-2990 Automatic generation of the Builder pattern with FreeBuilder
Jul 29, 2019
6fe2a0f
BAEL-2781 - metaprogramming in groovy - review fixes
SmartyAnsh Jul 29, 2019
b040735
BAEL-3014: Updated the example
isaolmez Jul 31, 2019
46763c9
Merge branch 'master' of https://github.com/eugenp/tutorials
dkapil Jul 31, 2019
b91a78a
[BAEL-2996] Moved code from libraries2 to java-math
Aug 2, 2019
02223e6
Create README.md
johnA1331 Aug 2, 2019
1cf79d8
Update README.MD
johnA1331 Aug 2, 2019
b024a85
Update README.MD
johnA1331 Aug 2, 2019
2e41eae
Update README.md
johnA1331 Aug 2, 2019
0978e13
Update README.md
johnA1331 Aug 2, 2019
05321a2
Update README.md
johnA1331 Aug 2, 2019
6cfd5ad
Update README.md
johnA1331 Aug 2, 2019
3403f6d
Create README.MD
johnA1331 Aug 2, 2019
dbf5783
Update README.md
johnA1331 Aug 2, 2019
7c90eb4
Update README.md
johnA1331 Aug 2, 2019
7cb114e
Create README.MD
johnA1331 Aug 2, 2019
68d69c7
Create README.MD
johnA1331 Aug 2, 2019
87309f9
Update README.md
johnA1331 Aug 2, 2019
bc33ce4
Update README.md
johnA1331 Aug 2, 2019
394de10
Update README.md
johnA1331 Aug 2, 2019
364823c
Update README.md
johnA1331 Aug 2, 2019
7050b07
Update README.md
johnA1331 Aug 2, 2019
a2ed702
Update README.md
johnA1331 Aug 2, 2019
0308c28
Update README.md
johnA1331 Aug 2, 2019
d050369
Update README.md
johnA1331 Aug 2, 2019
8499cd1
Update and rename README.MD to README.md
johnA1331 Aug 2, 2019
93426ca
Update README.md
johnA1331 Aug 2, 2019
e2e5a0a
Create README.md
johnA1331 Aug 2, 2019
928727c
Update README.md
johnA1331 Aug 2, 2019
7155e21
Update README.md
johnA1331 Aug 2, 2019
56f64b9
Update README.md
johnA1331 Aug 2, 2019
cc7cd9b
Update README.md
johnA1331 Aug 2, 2019
841963c
Update README.md
johnA1331 Aug 2, 2019
cb3d029
Update README.md
johnA1331 Aug 2, 2019
e73adef
Update README.md
johnA1331 Aug 2, 2019
83458fb
Update README.md
johnA1331 Aug 2, 2019
c05afcf
Rename README.MD to README.md
johnA1331 Aug 2, 2019
d3c8e55
Rename README.MD to README.md
johnA1331 Aug 2, 2019
0905e07
Rename README.MD to README.md
johnA1331 Aug 2, 2019
67d88b9
[BAEL-16003] Moving article out of libraries (& flink from libraries-…
sam-tmtc Aug 2, 2019
2096feb
remove live test change from this branch
sam-tmtc Aug 2, 2019
0f06cd4
remove live test change from this branch
sam-tmtc Aug 2, 2019
4f948b2
BAEL-2688 Moved example code from spring-amqp-simple to spring-amqp p…
pcoates33 Aug 2, 2019
e3b4b5f
BAEL-2688 Moved example code from spring-amqp-simple to spring-amqp p…
pcoates33 Aug 2, 2019
76c0918
BAEL-2688 Add relative path to parent module ot pom.xml
pcoates33 Aug 2, 2019
168cd4a
BAEL-2688 Remove spring-amqp-simple project
pcoates33 Aug 2, 2019
67356a3
BAEL-2688 Allow specific app to be run from mvn
pcoates33 Aug 2, 2019
b8934b1
Merge remote-tracking branch 'upstream/master' into BAEL-2688
pcoates33 Aug 2, 2019
22c2e6b
BAEL-2688 Revert changes made to parent pom
pcoates33 Aug 2, 2019
7b7ae4e
BAEL-2688 Remove springboot plugin which is duplicated in parent
pcoates33 Aug 2, 2019
21d18c6
BAEL-2688 Remove references to spring-amqp-simple
pcoates33 Aug 2, 2019
e6a38aa
add scheduled async example
Doha2012 Aug 3, 2019
b467ee6
Merge branch 'master' of https://github.com/eugenp/tutorials
Aug 4, 2019
d45e50f
BAEL-2990 Automatic generation of the Builder pattern with FreeBuilder
Aug 4, 2019
1cfdd27
Update README.md
lor6 Aug 4, 2019
3ceaa25
Update README.md
lor6 Aug 4, 2019
143aff9
remove obsolete modules; appears to be from issue BAEL-119 which was …
lor6 Aug 4, 2019
f1e0397
update links in readmes
lor6 Aug 4, 2019
ea63ec6
Merge pull request #7497 from eugenp/lor6-patch-4
lor6 Aug 4, 2019
391c224
Merge pull request #7498 from eugenp/lor6-patch-5
lor6 Aug 4, 2019
329ab30
Merge pull request #7499 from eugenp/remove-module
lor6 Aug 4, 2019
2ab57b4
Merge pull request #7474 from johnA1331/master
lor6 Aug 4, 2019
c8e517f
Merge pull request #7428 from SmartyAnsh/master
eric-martin Aug 4, 2019
2a4adf2
BAEL-2804 JPA Query Parameters Usage - formatting issues fixed
tryncatch Aug 5, 2019
f767e46
BAEL-3184 (#7505)
vatsalgosar Aug 5, 2019
c366657
BAEL-16622 - updating intellij formatting rules
fanatixan Aug 5, 2019
4dbeaca
[BAEL-16003] renamed artifactId. Removed specified articles from libr…
sam-tmtc Aug 5, 2019
98f59f5
[BAEL-16003] Added missing dependencies - mvn clean install now succeeds
sam-tmtc Aug 5, 2019
c1920dd
BAEL-2928 - Solve conflicts in pom.xml
Aug 5, 2019
e485b0d
Merge branch 'master' into BAEL-2928
juanvaccari Aug 5, 2019
10163e4
Merge branch 'master' of https://github.com/eugenp/tutorials
dkapil Aug 5, 2019
1ccfdeb
Merge branch 'master' into BAEL-3095
veontomo Aug 5, 2019
4b7d77e
Get rid of custom.properties
veontomo Aug 5, 2019
780d6c7
Merge pull request #7510 from fanatixan/BAEL-16622
lor6 Aug 5, 2019
ab0477a
BAEL-3127 Binary Numbers in Java (#7469)
sumitsg34 Aug 5, 2019
a56d3b1
Merge pull request #7294 from juanvaccari/BAEL-2928
Aug 5, 2019
a02fcfb
UPDATE Added additional tests, security config, and fix format issues…
earth001 Aug 5, 2019
9acd42a
Merge pull request #7305 from kamleshkr/BAEL-3042-1
eric-martin Aug 6, 2019
f207512
Merge pull request #7467 from dupirefr/bael-2996-bis
Aug 6, 2019
88de49b
Merge pull request #7310 from veontomo/BAEL-3095
lor6 Aug 6, 2019
362b7fa
Merge pull request #7475 from sjmillington/library-move-pt-1
lor6 Aug 6, 2019
7997588
Merge pull request #7482 from Doha2012/master
lor6 Aug 6, 2019
e56c5f8
Merge branch 'master' of https://github.com/eugenp/tutorials
Aug 7, 2019
c302077
BAEL-2990 Automatic generation of the Builder pattern with FreeBuilder
Aug 7, 2019
fcc7ca0
Update pom.xml
dev-chirag Aug 7, 2019
ec8b02a
Update pom.xml
dev-chirag Aug 7, 2019
b72e8b3
[BAEL-16003] Moved missing docx test. Removed remaining docx folders.…
sam-tmtc Aug 7, 2019
81d12e2
[BAEL-16003] Added missing README and POM changes
sam-tmtc Aug 7, 2019
7749c4d
Update README.md
lor6 Aug 7, 2019
f90828b
Merge pull request #7327 from dev-chirag/master
eric-martin Aug 8, 2019
d25a282
Merge branch 'master' into BAEL-2804
tryncatch Aug 8, 2019
b7e02db
BAEL-2804 Fixed XML indentation
tryncatch Aug 8, 2019
71db72a
Selection Sort Implementation (#7454)
nikunjgandhi1987 Aug 8, 2019
69fb214
Adding source code for tutorial tracked under BAEL-3171. (#7523)
kcacademic Aug 8, 2019
7f7fd33
Adds after / before mapping example (#7518)
Nivedan-Bamal Aug 8, 2019
8ff8628
feat(BAEL-3044) Implement MyBatis with Spring/SpringBoot module (#7507)
FrancoCorleone Aug 8, 2019
650dabd
[BAEL-16685] -Upgrade parent-spring-4 to the latest version of Spring…
amit2103 Aug 8, 2019
20922db
Merge pull request #7533 from eugenp/lor6-patch-2
lor6 Aug 8, 2019
f4172c6
Merge pull request #7500 from eugenp/fix-readmes
lor6 Aug 8, 2019
ee120bf
Merge pull request #7531 from sjmillington/library-move-pt-1
lor6 Aug 8, 2019
1568159
Merge pull request #7538 from amit2103/BAEL-16685
lor6 Aug 8, 2019
abad789
Merge pull request #7318 from isaolmez/BAEL-3014
Aug 8, 2019
43cfd56
Merge pull request #7309 from tryncatch/BAEL-2804
Aug 8, 2019
c917691
[BAEL-3121] Added source for finding number of lines in a file
sreekanthsnair Aug 9, 2019
43ec1a7
Merge pull request #7539 from sreekanthsnair/master
Aug 9, 2019
86d70d7
Merge branch 'master' of https://github.com/eugenp/tutorials
dkapil Aug 9, 2019
243882b
Java GSS (#7541)
kcacademic Aug 9, 2019
2a9050e
BAEL-2904 Improvement: Move Lambda Related Articles (#7519)
priyeshmashelkar Aug 10, 2019
db411e3
BAEL-10672 Modules with Failing SpringContextTest
dkapil Aug 10, 2019
7211b74
create triangles with for loops - examples (#7513)
catalin-burcea Aug 10, 2019
2c47cd7
Merge pull request #7546 from dkapil/story/BAEL-10672
lor6 Aug 10, 2019
efd0d81
Merge pull request #7476 from pcoates33/BAEL-2688
rpvilao Aug 10, 2019
b891c53
BAEL-3141: Created new module for 'Converting Java String to Double' …
albanoj2 Aug 10, 2019
2aeb078
BAEL-3154 (#7479)
kevinkraus Aug 10, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion algorithms-miscellaneous-3/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Relevant articles:
## Relevant Articles:

- [Java Two Pointer Technique](https://www.baeldung.com/java-two-pointer-technique)
- [Implementing Simple State Machines with Java Enums](https://www.baeldung.com/java-enum-simple-state-machine)
Expand Down
13 changes: 13 additions & 0 deletions algorithms-miscellaneous-3/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@
<artifactId>guava</artifactId>
<version>${guava.version}</version>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.8.1</version>
</dependency>

<dependency>
<groupId>pl.pragmatists</groupId>
<artifactId>JUnitParams</artifactId>
<version>1.1.0</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.baeldung.algorithms.printtriangles;

import org.apache.commons.lang3.StringUtils;

public class PrintTriangleExamples {

public static String printARightAngledTriangle(int N) {
StringBuilder result = new StringBuilder();
for (int r = 1; r <= N; r++) {
for (int j = 1; j <= r; j++) {
result.append("*");
}
result.append(System.lineSeparator());
}
return result.toString();
}

public static String printAnIsoscelesTriangle(int N) {
StringBuilder result = new StringBuilder();
for (int r = 1; r <= N; r++) {
for (int sp = 1; sp <= N - r; sp++) {
result.append(" ");
}
for (int c = 1; c <= (r * 2) - 1; c++) {
result.append("*");
}
result.append(System.lineSeparator());
}
return result.toString();
}

public static String printAnIsoscelesTriangleUsingSubstring(int N) {
StringBuilder result = new StringBuilder();
String helperString = StringUtils.repeat(' ', N - 1) + StringUtils.repeat('*', N * 2 - 1);

for (int r = 0; r < N; r++) {
result.append(helperString.substring(r, N + 2 * r));
result.append(System.lineSeparator());
}
return result.toString();
}

public static void main(String[] args) {
System.out.println(printARightAngledTriangle(5));
System.out.println(printAnIsoscelesTriangle(5));
System.out.println(printAnIsoscelesTriangleUsingSubstring(5));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package com.baeldung.algorithms.printtriangles;

import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
import org.junit.Test;
import org.junit.runner.RunWith;

import static org.junit.Assert.assertEquals;

@RunWith(JUnitParamsRunner.class)
public class PrintTriangleExamplesUnitTest {

private static Object[][] rightAngledTriangles() {
String expected0 = "";

String expected2 = "*" + System.lineSeparator()
+ "**" + System.lineSeparator();

String expected5 = "*" + System.lineSeparator()
+ "**" + System.lineSeparator()
+ "***" + System.lineSeparator()
+ "****" + System.lineSeparator()
+ "*****" + System.lineSeparator();

String expected7 = "*" + System.lineSeparator()
+ "**" + System.lineSeparator()
+ "***" + System.lineSeparator()
+ "****" + System.lineSeparator()
+ "*****" + System.lineSeparator()
+ "******" + System.lineSeparator()
+ "*******" + System.lineSeparator();

return new Object[][] {
{ 0, expected0 },
{ 2, expected2 },
{ 5, expected5 },
{ 7, expected7 }
};
}

@Test
@Parameters(method = "rightAngledTriangles")
public void whenPrintARightAngledTriangleIsCalled_ThenTheCorrectStringIsReturned(int nrOfRows, String expected) {
String actual = PrintTriangleExamples.printARightAngledTriangle(nrOfRows);

assertEquals(expected, actual);
}

private static Object[][] isoscelesTriangles() {
String expected0 = "";

String expected2 = " *" + System.lineSeparator()
+ "***" + System.lineSeparator();

String expected5 = " *" + System.lineSeparator()
+ " ***" + System.lineSeparator()
+ " *****" + System.lineSeparator()
+ " *******" + System.lineSeparator()
+ "*********" + System.lineSeparator();

String expected7 = " *" + System.lineSeparator()
+ " ***" + System.lineSeparator()
+ " *****" + System.lineSeparator()
+ " *******" + System.lineSeparator()
+ " *********" + System.lineSeparator()
+ " ***********" + System.lineSeparator()
+ "*************" + System.lineSeparator();

return new Object[][] {
{ 0, expected0 },
{ 2, expected2 },
{ 5, expected5 },
{ 7, expected7 }
};
}

@Test
@Parameters(method = "isoscelesTriangles")
public void whenPrintAnIsoscelesTriangleIsCalled_ThenTheCorrectStringIsReturned(int nrOfRows, String expected) {
String actual = PrintTriangleExamples.printAnIsoscelesTriangle(nrOfRows);

assertEquals(expected, actual);
}

@Test
@Parameters(method = "isoscelesTriangles")
public void whenPrintAnIsoscelesTriangleUsingSubstringIsCalled_ThenTheCorrectStringIsReturned(int nrOfRows, String expected) {
String actual = PrintTriangleExamples.printAnIsoscelesTriangleUsingSubstring(nrOfRows);

assertEquals(expected, actual);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.baeldung.algorithms.selectionsort;

public class SelectionSort {

public static void sortAscending(final int[] arr) {
for (int i = 0; i < arr.length - 1; i++) {
int minElementIndex = i;
for (int j = i + 1; j < arr.length; j++) {
if (arr[minElementIndex] > arr[j]) {
minElementIndex = j;
}
}

if (minElementIndex != i) {
int temp = arr[i];
arr[i] = arr[minElementIndex];
arr[minElementIndex] = temp;
}
}
}

public static void sortDescending(final int[] arr) {
for (int i = 0; i < arr.length - 1; i++) {
int maxElementIndex = i;
for (int j = i + 1; j < arr.length; j++) {
if (arr[maxElementIndex] < arr[j]) {
maxElementIndex = j;
}
}

if (maxElementIndex != i) {
int temp = arr[i];
arr[i] = arr[maxElementIndex];
arr[maxElementIndex] = temp;
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.baeldung.algorithms.selectionsort;

import static org.junit.Assert.*;
import static org.junit.Assert.assertArrayEquals;

import org.junit.Test;

public class SelectionSortUnitTest {

@Test
public void givenUnsortedArray_whenSelectionSort_SortAscending_thenSortedAsc() {
int[] input = { 5, 4, 1, 6, 2 };
SelectionSort.sortAscending(input);
int[] expected = {1, 2, 4, 5, 6};
assertArrayEquals("the two arrays are not equal", expected, input);
}

@Test
public void givenUnsortedArray_whenSelectionSort_SortDescending_thenSortedDesc() {
int[] input = { 5, 4, 1, 6, 2 };
SelectionSort.sortDescending(input);
int[] expected = {6, 5, 4, 2, 1};
assertArrayEquals("the two arrays are not equal", expected, input);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.baeldung.metaprogramming

import groovy.transform.AutoClone
import groovy.transform.Canonical
import groovy.transform.EqualsAndHashCode
import groovy.transform.ToString
import groovy.transform.TupleConstructor
import groovy.util.logging.*

@Canonical
@TupleConstructor
@EqualsAndHashCode
@ToString(includePackage=false, excludes=['id'])
@Log
@AutoClone
class Employee {

long id
String firstName
String lastName
int age

//method to catch missing property's getter
def propertyMissing(String propertyName) {
log.info "$propertyName is not available"
"property '$propertyName' is not available"
}

//method to catch missing property's setter
def propertyMissing(String propertyName, propertyValue) {
println "property '$propertyName' is not available"
log.info "$propertyName is not available"
"property '$propertyName' is not available"
}

def methodMissing(String methodName, def methodArgs) {
log.info "$methodName is not defined"
"method '$methodName' is not defined"
}

def logEmp() {
log.info "Employee: $lastName, $firstName is of $age years age"
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package com.baeldung.metaprogramming.extension

import com.baeldung.metaprogramming.Employee

class BasicExtensions {

static int getYearOfBirth(Employee self) {
return (new Date().getYear() + 1900) - self.age;
}

static String capitalize(String self) {
return self.substring(0, 1).toUpperCase() + self.substring(1)
}

static void printCounter(Integer self) {
while (self>0) {
println self
self--
}
}

static Long square(Long self) {
return self*self
}

static BigDecimal cube(BigDecimal self) {
return self*self*self
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.baeldung.metaprogramming.extension

import com.baeldung.metaprogramming.Employee

class StaticEmployeeExtension {

static Employee getDefaultObj(Employee self) {
return new Employee(firstName: "firstName", lastName: "lastName", age: 20)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
moduleName=core-groovy-2
moduleVersion=1.0-SNAPSHOT
extensionClasses=com.baeldung.metaprogramming.extension.BasicExtensions
staticExtensionClasses=com.baeldung.metaprogramming.extension.StaticEmployeeExtension
Loading