diff --git a/.travis.yml b/.travis.yml
index 683422dc97..5e86714a89 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,7 +4,7 @@ before_install:
- echo "MAVEN_OPTS='-Xmx2048M -Xss128M -XX:+CMSClassUnloadingEnabled -XX:+UseG1GC -XX:-UseGCOverheadLimit'" > ~/.mavenrc
install: skip
-script: travis_wait 60 mvn -q install -Pdefault-first,default-second
+script: travis_wait 60 mvn -q install -Pdefault-first,default-second -Dgib.enabled=true
sudo: required
diff --git a/algorithms-miscellaneous-2/README.md b/algorithms-miscellaneous-2/README.md
index 6772a94a8d..d693a44f66 100644
--- a/algorithms-miscellaneous-2/README.md
+++ b/algorithms-miscellaneous-2/README.md
@@ -17,3 +17,4 @@
- [Round Up to the Nearest Hundred](https://www.baeldung.com/java-round-up-nearest-hundred)
- [Calculate Percentage in Java](https://www.baeldung.com/java-calculate-percentage)
- [Converting Between Byte Arrays and Hexadecimal Strings in Java](https://www.baeldung.com/java-byte-arrays-hex-strings)
+- [Convert Latitude and Longitude to a 2D Point in Java](https://www.baeldung.com/java-convert-latitude-longitude)
diff --git a/cdi/pom.xml b/cdi/pom.xml
index 2c719c1d7f..0b735e0ca5 100644
--- a/cdi/pom.xml
+++ b/cdi/pom.xml
@@ -5,7 +5,7 @@
com.baeldung
cdi
1.0-SNAPSHOT
-
+
com.baeldung
parent-spring-4
@@ -14,6 +14,16 @@
+
+ javax.enterprise
+ cdi-api
+ ${cdi-api.version}
+
+
+ org.jboss.weld.se
+ weld-se-core
+ ${weld-se-core.version}
+
org.hamcrest
hamcrest-core
@@ -42,11 +52,6 @@
aspectjweaver
${aspectjweaver.version}
-
- org.jboss.weld.se
- weld-se-core
- ${weld-se-core.version}
-
org.springframework
spring-test
@@ -54,13 +59,13 @@
test
-
- 1.8.9
- 2.4.1.Final
+ 2.0.SP1
+ 3.0.5.Final
+ 1.9.2
1.3
3.10.0
4.12
+ 5.1.2.RELEASE
-
diff --git a/cdi/src/main/java/com/baeldung/cdi2observers/application/BootstrappingApplication.java b/cdi/src/main/java/com/baeldung/cdi2observers/application/BootstrappingApplication.java
new file mode 100644
index 0000000000..4896408502
--- /dev/null
+++ b/cdi/src/main/java/com/baeldung/cdi2observers/application/BootstrappingApplication.java
@@ -0,0 +1,15 @@
+package com.baeldung.cdi.cdi2observers.application;
+
+import com.baeldung.cdi.cdi2observers.events.ExampleEvent;
+import javax.enterprise.inject.se.SeContainer;
+import javax.enterprise.inject.se.SeContainerInitializer;
+
+public class BootstrappingApplication {
+
+ public static void main(String... args) {
+ SeContainerInitializer containerInitializer = SeContainerInitializer.newInstance();
+ try (SeContainer container = containerInitializer.initialize()) {
+ container.getBeanManager().fireEvent(new ExampleEvent("Welcome to Baeldung!"));
+ }
+ }
+}
diff --git a/cdi/src/main/java/com/baeldung/cdi2observers/events/ExampleEvent.java b/cdi/src/main/java/com/baeldung/cdi2observers/events/ExampleEvent.java
new file mode 100644
index 0000000000..a2329d2ef1
--- /dev/null
+++ b/cdi/src/main/java/com/baeldung/cdi2observers/events/ExampleEvent.java
@@ -0,0 +1,14 @@
+package com.baeldung.cdi.cdi2observers.events;
+
+public class ExampleEvent {
+
+ private final String eventMessage;
+
+ public ExampleEvent(String eventMessage) {
+ this.eventMessage = eventMessage;
+ }
+
+ public String getEventMessage() {
+ return eventMessage;
+ }
+}
diff --git a/cdi/src/main/java/com/baeldung/cdi2observers/events/ExampleEventSource.java b/cdi/src/main/java/com/baeldung/cdi2observers/events/ExampleEventSource.java
new file mode 100644
index 0000000000..f37030778a
--- /dev/null
+++ b/cdi/src/main/java/com/baeldung/cdi2observers/events/ExampleEventSource.java
@@ -0,0 +1,14 @@
+package com.baeldung.cdi.cdi2observers.events;
+
+import javax.enterprise.event.Event;
+import javax.inject.Inject;
+
+public class ExampleEventSource {
+
+ @Inject
+ Event exampleEvent;
+
+ public void fireEvent() {
+ exampleEvent.fireAsync(new ExampleEvent("Welcome to Baeldung!"));
+ }
+}
diff --git a/cdi/src/main/java/com/baeldung/cdi2observers/observers/AnotherExampleEventObserver.java b/cdi/src/main/java/com/baeldung/cdi2observers/observers/AnotherExampleEventObserver.java
new file mode 100644
index 0000000000..34520c2b3d
--- /dev/null
+++ b/cdi/src/main/java/com/baeldung/cdi2observers/observers/AnotherExampleEventObserver.java
@@ -0,0 +1,12 @@
+package com.baeldung.cdi.cdi2observers.observers;
+
+import com.baeldung.cdi.cdi2observers.events.ExampleEvent;
+import javax.annotation.Priority;
+import javax.enterprise.event.Observes;
+
+public class AnotherExampleEventObserver {
+
+ public String onEvent(@Observes @Priority(2) ExampleEvent event) {
+ return event.getEventMessage();
+ }
+}
diff --git a/cdi/src/main/java/com/baeldung/cdi2observers/observers/ExampleEventObserver.java b/cdi/src/main/java/com/baeldung/cdi2observers/observers/ExampleEventObserver.java
new file mode 100644
index 0000000000..b3522b2ad0
--- /dev/null
+++ b/cdi/src/main/java/com/baeldung/cdi2observers/observers/ExampleEventObserver.java
@@ -0,0 +1,13 @@
+package com.baeldung.cdi.cdi2observers.observers;
+
+import com.baeldung.cdi.cdi2observers.events.ExampleEvent;
+import com.baeldung.cdi.cdi2observers.services.TextService;
+import javax.annotation.Priority;
+import javax.enterprise.event.Observes;
+
+public class ExampleEventObserver {
+
+ public String onEvent(@Observes @Priority(1) ExampleEvent event, TextService textService) {
+ return textService.parseText(event.getEventMessage());
+ }
+}
diff --git a/cdi/src/main/java/com/baeldung/cdi2observers/services/TextService.java b/cdi/src/main/java/com/baeldung/cdi2observers/services/TextService.java
new file mode 100644
index 0000000000..47788a0657
--- /dev/null
+++ b/cdi/src/main/java/com/baeldung/cdi2observers/services/TextService.java
@@ -0,0 +1,8 @@
+package com.baeldung.cdi.cdi2observers.services;
+
+public class TextService {
+
+ public String parseText(String text) {
+ return text.toUpperCase();
+ }
+}
diff --git a/cdi/src/test/java/com/baeldung/test/cdi2observers/tests/TextServiceUnitTest.java b/cdi/src/test/java/com/baeldung/test/cdi2observers/tests/TextServiceUnitTest.java
new file mode 100644
index 0000000000..deecf13f9a
--- /dev/null
+++ b/cdi/src/test/java/com/baeldung/test/cdi2observers/tests/TextServiceUnitTest.java
@@ -0,0 +1,14 @@
+package com.baeldung.cdi.cdi2observers.tests;
+
+import com.baeldung.cdi.cdi2observers.services.TextService;
+import static org.assertj.core.api.Assertions.assertThat;
+import org.junit.Test;
+
+public class TextServiceUnitTest {
+
+ @Test
+ public void givenTextServiceInstance_whenCalledparseText_thenCorrect() {
+ TextService textService = new TextService();
+ assertThat(textService.parseText("Baeldung")).isEqualTo("BAELDUNG");
+ }
+}
diff --git a/core-java-10/README.md b/core-java-10/README.md
index 84fa381a26..f0a25712a7 100644
--- a/core-java-10/README.md
+++ b/core-java-10/README.md
@@ -4,3 +4,4 @@
- [Java 10 LocalVariable Type-Inference](http://www.baeldung.com/java-10-local-variable-type-inference)
- [Guide to Java 10](http://www.baeldung.com/java-10-overview)
- [Copy a List to Another List in Java](http://www.baeldung.com/java-copy-list-to-another)
+- [Deep Dive Into the New Java JIT Compiler – Graal](https://www.baeldung.com/graal-java-jit-compiler)
diff --git a/core-java-8/README.md b/core-java-8/README.md
index ffd629a170..6786b29120 100644
--- a/core-java-8/README.md
+++ b/core-java-8/README.md
@@ -33,3 +33,4 @@
- [An Overview of Regular Expressions Performance in Java](https://www.baeldung.com/java-regex-performance)
- [Java Primitives versus Objects](https://www.baeldung.com/java-primitives-vs-objects)
- [How to Use if/else Logic in Java 8 Streams](https://www.baeldung.com/java-8-streams-if-else-logic)
+- [How to Replace Many if Statements in Java](https://www.baeldung.com/java-replace-if-statements)
diff --git a/core-java-arrays/src/main/java/com/baeldung/array/operations/ArrayOperations.java b/core-java-arrays/src/main/java/com/baeldung/array/operations/ArrayOperations.java
index 98155ed952..d8cc0afd61 100644
--- a/core-java-arrays/src/main/java/com/baeldung/array/operations/ArrayOperations.java
+++ b/core-java-arrays/src/main/java/com/baeldung/array/operations/ArrayOperations.java
@@ -4,11 +4,13 @@ import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedHashSet;
+import java.util.LinkedList;
import java.util.Random;
import java.util.Set;
import java.util.function.Function;
import java.util.function.IntPredicate;
import java.util.function.Predicate;
+import java.util.stream.Stream;
import org.apache.commons.lang3.ArrayUtils;
@@ -194,4 +196,16 @@ public class ArrayOperations {
public static T getRandomFromObjectArray(T[] array) {
return array[new Random().nextInt(array.length)];
}
+
+ public static Integer[] intersectionSimple(final Integer[] a, final Integer[] b){
+ return Stream.of(a).filter(Arrays.asList(b)::contains).toArray(Integer[]::new);
+ }
+
+ public static Integer[] intersectionSet(final Integer[] a, final Integer[] b){
+ return Stream.of(a).filter(Arrays.asList(b)::contains).distinct().toArray(Integer[]::new);
+ }
+
+ public static Integer[] intersectionMultiSet(final Integer[] a, final Integer[] b){
+ return Stream.of(a).filter(new LinkedList<>(Arrays.asList(b))::remove).toArray(Integer[]::new);
+ }
}
diff --git a/core-java-arrays/src/test/java/com/baeldung/array/operations/IntersectionUnitTest.java b/core-java-arrays/src/test/java/com/baeldung/array/operations/IntersectionUnitTest.java
new file mode 100644
index 0000000000..3c61060ea8
--- /dev/null
+++ b/core-java-arrays/src/test/java/com/baeldung/array/operations/IntersectionUnitTest.java
@@ -0,0 +1,66 @@
+package com.baeldung.array.operations;
+
+import org.junit.jupiter.api.Test;
+
+import static com.baeldung.array.operations.ArrayOperations.intersectionMultiSet;
+import static com.baeldung.array.operations.ArrayOperations.intersectionSet;
+import static com.baeldung.array.operations.ArrayOperations.intersectionSimple;
+import static org.assertj.core.api.Assertions.assertThat;
+
+class IntersectionUnitTest {
+ private static final Integer[] a = { 1, 3, 2 };
+ private static final Integer[] b = { 4, 3, 2, 4, 2, 3, 4, 4, 3 };
+ private static final Integer[] c = { 1, 3, 2, 3, 3, 2 };
+
+ @Test
+ void whenIntersectionSimpleIsUsed_thenCommonEntriesAreInTheResult() {
+ assertThat(intersectionSimple(a, b)).isEqualTo(new Integer[] { 3, 2 });
+ assertThat(intersectionSimple(b, a)).isEqualTo(new Integer[] { 3, 2, 2, 3, 3 });
+ }
+
+ @Test
+ void whenIntersectionSimpleIsUsedWithAnArrayAndItself_thenTheResultIsTheIdentity() {
+ assertThat(intersectionSimple(b, b)).isEqualTo(b);
+ assertThat(intersectionSimple(a, a)).isEqualTo(a);
+ }
+
+ @Test
+ void whenIntersectionSetIsUsed_thenCommonEntriesAreInTheResult() {
+ assertThat(intersectionSet(b, a)).isEqualTo(new Integer[] { 3, 2 });
+ }
+
+ @Test
+ void whenIntersectionSetIsUsed_thenTheNumberOfEntriesDoesNotChangeWithTheParameterOrder() {
+ assertThat(intersectionSet(a, b)).isEqualTo(new Integer[] { 3, 2 });
+ assertThat(intersectionSet(b, a)).isEqualTo(new Integer[] { 3, 2 });
+ }
+
+ @Test
+ void whenIntersectionSetIsUsedWithAnArrayAndWithItself_andTheInputHasNoDuplicateEntries_ThenTheResultIsTheIdentity() {
+ assertThat(intersectionSet(a, a)).isEqualTo(a);
+ }
+
+ @Test
+ void whenIntersectionSetIsUsedWithAnArrayAndWithItself_andTheInputHasDuplicateEntries_ThenTheResultIsNotTheIdentity() {
+ assertThat(intersectionSet(b, b)).isNotEqualTo(b);
+ }
+
+ @Test
+ void whenMultiSetIsUsed_thenCommonEntriesAreInTheResult() {
+ assertThat(intersectionMultiSet(b, a)).isEqualTo(new Integer[] { 3, 2 });
+ }
+
+ @Test
+ void whenIntersectionMultiSetIsUsed_thenTheNumberOfEntriesDoesNotChangeWithTheParameterOrder() {
+ assertThat(intersectionMultiSet(a, b)).isEqualTo(new Integer[] { 3, 2 });
+ assertThat(intersectionMultiSet(b, a)).isEqualTo(new Integer[] { 3, 2 });
+ assertThat(intersectionMultiSet(b, c)).isEqualTo(new Integer[] { 3, 2, 2, 3, 3 });
+ assertThat(intersectionMultiSet(c, b)).isEqualTo(new Integer[] { 3, 2, 3, 3, 2 });
+ }
+
+ @Test
+ void whenIntersectionMultiSetIsUsedWithAnArrayAndWithItself_ThenTheResultIsTheIdentity() {
+ assertThat(intersectionMultiSet(b, b)).isEqualTo(b);
+ assertThat(intersectionMultiSet(a, a)).isEqualTo(a);
+ }
+}
\ No newline at end of file
diff --git a/core-java-collections/README.md b/core-java-collections/README.md
index 0fcf7367c7..858dbef0b3 100644
--- a/core-java-collections/README.md
+++ b/core-java-collections/README.md
@@ -50,3 +50,4 @@
- [Check If Two Lists are Equal in Java](http://www.baeldung.com/java-test-a-list-for-ordinality-and-equality)
- [Java List Initialization in One Line](https://www.baeldung.com/java-init-list-one-line)
- [ClassCastException: Arrays$ArrayList cannot be cast to ArrayList](https://www.baeldung.com/java-classcastexception-arrays-arraylist)
+- [A Guide to EnumMap](https://www.baeldung.com/java-enum-map)
diff --git a/core-java-io/README.md b/core-java-io/README.md
index c81e466b57..3d028783ed 100644
--- a/core-java-io/README.md
+++ b/core-java-io/README.md
@@ -34,3 +34,4 @@
- [Read a File into an ArrayList](https://www.baeldung.com/java-file-to-arraylist)
- [Guide to Java OutputStream](https://www.baeldung.com/java-outputstream)
- [Reading a CSV File into an Array](https://www.baeldung.com/java-csv-file-array)
+- [Guide to BufferedReader](https://www.baeldung.com/java-buffered-reader)
diff --git a/core-java-lang/README.md b/core-java-lang/README.md
index 85312cba68..62af72818f 100644
--- a/core-java-lang/README.md
+++ b/core-java-lang/README.md
@@ -56,4 +56,5 @@
- [How to Separate Double into Integer and Decimal Parts](https://www.baeldung.com/java-separate-double-into-integer-decimal-parts)
- [“Sneaky Throws” in Java](http://www.baeldung.com/java-sneaky-throws)
- [Inheritance and Composition (Is-a vs Has-a relationship) in Java](http://www.baeldung.com/java-inheritance-composition)
+- [A Guide to Constructors in Java](https://www.baeldung.com/java-constructors)
diff --git a/core-java/src/main/java/com/baeldung/constructors/BankAccount.java b/core-java-lang/src/main/java/com/baeldung/constructors/BankAccount.java
similarity index 100%
rename from core-java/src/main/java/com/baeldung/constructors/BankAccount.java
rename to core-java-lang/src/main/java/com/baeldung/constructors/BankAccount.java
diff --git a/core-java/src/main/java/com/baeldung/constructors/Transaction.java b/core-java-lang/src/main/java/com/baeldung/constructors/Transaction.java
similarity index 100%
rename from core-java/src/main/java/com/baeldung/constructors/Transaction.java
rename to core-java-lang/src/main/java/com/baeldung/constructors/Transaction.java
diff --git a/core-java/src/test/java/com/baeldung/constructors/ConstructorUnitTest.java b/core-java-lang/src/test/java/com/baeldung/constructors/ConstructorUnitTest.java
similarity index 100%
rename from core-java/src/test/java/com/baeldung/constructors/ConstructorUnitTest.java
rename to core-java-lang/src/test/java/com/baeldung/constructors/ConstructorUnitTest.java
diff --git a/core-java/README.md b/core-java/README.md
index 11d9fd2ee0..e8923e9a2f 100644
--- a/core-java/README.md
+++ b/core-java/README.md
@@ -85,3 +85,6 @@
- [A Guide to SimpleDateFormat](https://www.baeldung.com/java-simple-date-format)
- [SSL Handshake Failures](https://www.baeldung.com/java-ssl-handshake-failures)
- [Implementing a Binary Tree in Java](https://www.baeldung.com/java-binary-tree)
+- [Changing the Order in a Sum Operation Can Produce Different Results?](https://www.baeldung.com/java-floating-point-sum-order)
+- [Java – Try with Resources](https://www.baeldung.com/java-try-with-resources)
+- [Abstract Classes in Java](https://www.baeldung.com/java-abstract-class)
diff --git a/core-java/src/main/java/com/baeldung/className/RetrievingClassName.java b/core-java/src/main/java/com/baeldung/className/RetrievingClassName.java
new file mode 100644
index 0000000000..ab6c8a51ff
--- /dev/null
+++ b/core-java/src/main/java/com/baeldung/className/RetrievingClassName.java
@@ -0,0 +1,9 @@
+package com.baeldung.className;
+
+public class RetrievingClassName {
+
+ public class InnerClass {
+
+ }
+
+}
diff --git a/core-java/src/test/java/com/baeldung/className/RetrievingClassNameUnitTest.java b/core-java/src/test/java/com/baeldung/className/RetrievingClassNameUnitTest.java
new file mode 100644
index 0000000000..f9dbf91d2c
--- /dev/null
+++ b/core-java/src/test/java/com/baeldung/className/RetrievingClassNameUnitTest.java
@@ -0,0 +1,156 @@
+package com.baeldung.className;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+public class RetrievingClassNameUnitTest {
+
+ // Retrieving Simple Name
+ @Test
+ public void givenRetrievingClassName_whenGetSimpleName_thenRetrievingClassName() {
+ assertEquals("RetrievingClassName", RetrievingClassName.class.getSimpleName());
+ }
+
+ @Test
+ public void givenPrimitiveInt_whenGetSimpleName_thenInt() {
+ assertEquals("int", int.class.getSimpleName());
+ }
+
+ @Test
+ public void givenRetrievingClassNameArray_whenGetSimpleName_thenRetrievingClassNameWithBrackets() {
+ assertEquals("RetrievingClassName[]", RetrievingClassName[].class.getSimpleName());
+ assertEquals("RetrievingClassName[][]", RetrievingClassName[][].class.getSimpleName());
+ }
+
+ @Test
+ public void givenAnonymousClass_whenGetSimpleName_thenEmptyString() {
+ assertEquals("", new RetrievingClassName() {}.getClass().getSimpleName());
+ }
+
+ // Retrieving Other Names
+ // - Primitive Types
+ @Test
+ public void givenPrimitiveInt_whenGetName_thenInt() {
+ assertEquals("int", int.class.getName());
+ }
+
+ @Test
+ public void givenPrimitiveInt_whenGetTypeName_thenInt() {
+ assertEquals("int", int.class.getTypeName());
+ }
+
+ @Test
+ public void givenPrimitiveInt_whenGetCanonicalName_thenInt() {
+ assertEquals("int", int.class.getCanonicalName());
+ }
+
+ // - Object Types
+ @Test
+ public void givenRetrievingClassName_whenGetName_thenCanonicalName() {
+ assertEquals("com.baeldung.className.RetrievingClassName", RetrievingClassName.class.getName());
+ }
+
+ @Test
+ public void givenRetrievingClassName_whenGetTypeName_thenCanonicalName() {
+ assertEquals("com.baeldung.className.RetrievingClassName", RetrievingClassName.class.getTypeName());
+ }
+
+ @Test
+ public void givenRetrievingClassName_whenGetCanonicalName_thenCanonicalName() {
+ assertEquals("com.baeldung.className.RetrievingClassName", RetrievingClassName.class.getCanonicalName());
+ }
+
+ // - Inner Classes
+ @Test
+ public void givenRetrievingClassNameInnerClass_whenGetName_thenCanonicalNameWithDollarSeparator() {
+ assertEquals("com.baeldung.className.RetrievingClassName$InnerClass", RetrievingClassName.InnerClass.class.getName());
+ }
+
+ @Test
+ public void givenRetrievingClassNameInnerClass_whenGetTypeName_thenCanonicalNameWithDollarSeparator() {
+ assertEquals("com.baeldung.className.RetrievingClassName$InnerClass", RetrievingClassName.InnerClass.class.getTypeName());
+ }
+
+ @Test
+ public void givenRetrievingClassNameInnerClass_whenGetCanonicalName_thenCanonicalName() {
+ assertEquals("com.baeldung.className.RetrievingClassName.InnerClass", RetrievingClassName.InnerClass.class.getCanonicalName());
+ }
+
+ // - Anonymous Classes
+ @Test
+ public void givenAnonymousClass_whenGetName_thenCallingClassCanonicalNameWithDollarSeparatorAndCountNumber() {
+ // These are the second and third appearences of an anonymous class in RetrievingClassNameUnitTest, hence $2 and $3 expectations
+ assertEquals("com.baeldung.className.RetrievingClassNameUnitTest$2", new RetrievingClassName() {}.getClass().getName());
+ assertEquals("com.baeldung.className.RetrievingClassNameUnitTest$3", new RetrievingClassName() {}.getClass().getName());
+ }
+
+ @Test
+ public void givenAnonymousClass_whenGetTypeName_thenCallingClassCanonicalNameWithDollarSeparatorAndCountNumber() {
+ // These are the fourth and fifth appearences of an anonymous class in RetrievingClassNameUnitTest, hence $4 and $5 expectations
+ assertEquals("com.baeldung.className.RetrievingClassNameUnitTest$4", new RetrievingClassName() {}.getClass().getTypeName());
+ assertEquals("com.baeldung.className.RetrievingClassNameUnitTest$5", new RetrievingClassName() {}.getClass().getTypeName());
+ }
+
+ @Test
+ public void givenAnonymousClass_whenGetCanonicalName_thenNull() {
+ assertNull(new RetrievingClassName() {}.getClass().getCanonicalName());
+ }
+
+ // - Arrays
+ @Test
+ public void givenPrimitiveIntArray_whenGetName_thenOpeningBracketsAndPrimitiveIntLetter() {
+ assertEquals("[I", int[].class.getName());
+ assertEquals("[[I", int[][].class.getName());
+ }
+
+ @Test
+ public void givenRetrievingClassNameArray_whenGetName_thenOpeningBracketsLetterLAndRetrievingClassNameGetName() {
+ assertEquals("[Lcom.baeldung.className.RetrievingClassName;", RetrievingClassName[].class.getName());
+ assertEquals("[[Lcom.baeldung.className.RetrievingClassName;", RetrievingClassName[][].class.getName());
+ }
+
+ @Test
+ public void givenRetrievingClassNameInnerClassArray_whenGetName_thenOpeningBracketsLetterLAndRetrievingClassNameInnerClassGetName() {
+ assertEquals("[Lcom.baeldung.className.RetrievingClassName$InnerClass;", RetrievingClassName.InnerClass[].class.getName());
+ assertEquals("[[Lcom.baeldung.className.RetrievingClassName$InnerClass;", RetrievingClassName.InnerClass[][].class.getName());
+ }
+
+ @Test
+ public void givenPrimitiveIntArray_whenGetTypeName_thenPrimitiveIntGetTypeNameWithBrackets() {
+ assertEquals("int[]", int[].class.getTypeName());
+ assertEquals("int[][]", int[][].class.getTypeName());
+ }
+
+ @Test
+ public void givenRetrievingClassNameArray_whenGetTypeName_thenRetrievingClassNameGetTypeNameWithBrackets() {
+ assertEquals("com.baeldung.className.RetrievingClassName[]", RetrievingClassName[].class.getTypeName());
+ assertEquals("com.baeldung.className.RetrievingClassName[][]", RetrievingClassName[][].class.getTypeName());
+ }
+
+ @Test
+ public void givenRetrievingClassNameInnerClassArray_whenGetTypeName_thenRetrievingClassNameInnerClassGetTypeNameWithBrackets() {
+ assertEquals("com.baeldung.className.RetrievingClassName$InnerClass[]", RetrievingClassName.InnerClass[].class.getTypeName());
+ assertEquals("com.baeldung.className.RetrievingClassName$InnerClass[][]", RetrievingClassName.InnerClass[][].class.getTypeName());
+ }
+
+ @Test
+ public void givenPrimitiveIntArray_whenGetCanonicalName_thenPrimitiveIntGetCanonicalNameWithBrackets() {
+ assertEquals("int[]", int[].class.getCanonicalName());
+ assertEquals("int[][]", int[][].class.getCanonicalName());
+ }
+
+ @Test
+ public void givenRetrievingClassNameArray_whenGetCanonicalName_thenRetrievingClassNameGetCanonicalNameWithBrackets() {
+ assertEquals("com.baeldung.className.RetrievingClassName[]", RetrievingClassName[].class.getCanonicalName());
+ assertEquals("com.baeldung.className.RetrievingClassName[][]", RetrievingClassName[][].class.getCanonicalName());
+ }
+
+ @Test
+ public void givenRetrievingClassNameInnerClassArray_whenGetCanonicalName_thenRetrievingClassNameInnerClassGetCanonicalNameWithBrackets() {
+ assertEquals("com.baeldung.className.RetrievingClassName.InnerClass[]", RetrievingClassName.InnerClass[].class.getCanonicalName());
+ assertEquals("com.baeldung.className.RetrievingClassName.InnerClass[][]", RetrievingClassName.InnerClass[][].class.getCanonicalName());
+ }
+
+}
\ No newline at end of file
diff --git a/java-dates/README.md b/java-dates/README.md
index 66046b16a6..3f6d7998b8 100644
--- a/java-dates/README.md
+++ b/java-dates/README.md
@@ -24,3 +24,4 @@
- [Add Hours To a Date In Java](http://www.baeldung.com/java-add-hours-date)
- [Guide to DateTimeFormatter](https://www.baeldung.com/java-datetimeformatter)
- [Format ZonedDateTime to String](https://www.baeldung.com/java-format-zoned-datetime-string)
+- [Convert Between java.time.Instant and java.sql.Timestamp](Convert Between java.time.Instant and java.sql.Timestamp)
diff --git a/java-strings/src/main/java/com/baeldung/string/checkinputs/CheckIntegerInput.java b/java-strings/src/main/java/com/baeldung/string/checkinputs/CheckIntegerInput.java
new file mode 100644
index 0000000000..9462244bbb
--- /dev/null
+++ b/java-strings/src/main/java/com/baeldung/string/checkinputs/CheckIntegerInput.java
@@ -0,0 +1,19 @@
+package com.baeldung.string.checkinputs;
+
+import java.util.Scanner;
+
+public class CheckIntegerInput {
+
+ public static void main(String[] args) {
+
+ try (Scanner scanner = new Scanner(System.in)) {
+ System.out.println("Enter an integer : ");
+
+ if (scanner.hasNextInt()) {
+ System.out.println("You entered : " + scanner.nextInt());
+ } else {
+ System.out.println("The input is not an integer");
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/java-strings/src/main/java/com/baeldung/stringduplicates/RemoveDuplicateFromString.java b/java-strings/src/main/java/com/baeldung/stringduplicates/RemoveDuplicateFromString.java
index eeba81f334..d8fd9c4b14 100644
--- a/java-strings/src/main/java/com/baeldung/stringduplicates/RemoveDuplicateFromString.java
+++ b/java-strings/src/main/java/com/baeldung/stringduplicates/RemoveDuplicateFromString.java
@@ -44,16 +44,16 @@ public class RemoveDuplicateFromString {
}
String removeDuplicatesUsingSorting(String str) {
-
- char[] chars = str.toCharArray();
-
- Arrays.sort(chars);
-
StringBuilder sb = new StringBuilder();
- sb.append(chars[0]);
- for (int i = 1; i < chars.length; i++) {
- if (chars[i] != chars[i - 1]) {
- sb.append(chars[i]);
+ if(!str.isEmpty()) {
+ char[] chars = str.toCharArray();
+ Arrays.sort(chars);
+
+ sb.append(chars[0]);
+ for (int i = 1; i < chars.length; i++) {
+ if (chars[i] != chars[i - 1]) {
+ sb.append(chars[i]);
+ }
}
}
@@ -90,6 +90,13 @@ public class RemoveDuplicateFromString {
return sb.toString();
}
+
+ String removeDuplicatesUsingDistinct(String str) {
+ StringBuilder sb = new StringBuilder();
+ str.chars().distinct().forEach(c -> sb.append((char) c));
+ return sb.toString();
+ }
+
}
diff --git a/java-strings/src/test/java/com/baeldung/string/StringReplaceAndRemoveUnitTest.java b/java-strings/src/test/java/com/baeldung/string/StringReplaceAndRemoveUnitTest.java
new file mode 100644
index 0000000000..d952d2383b
--- /dev/null
+++ b/java-strings/src/test/java/com/baeldung/string/StringReplaceAndRemoveUnitTest.java
@@ -0,0 +1,83 @@
+package com.baeldung.string;
+
+
+import org.apache.commons.lang3.StringUtils;
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+public class StringReplaceAndRemoveUnitTest {
+
+
+ @Test
+ public void givenTestStrings_whenReplace_thenProcessedString() {
+
+ String master = "Hello World Baeldung!";
+ String target = "Baeldung";
+ String replacement = "Java";
+ String processed = master.replace(target, replacement);
+ assertTrue(processed.contains(replacement));
+ assertFalse(processed.contains(target));
+
+ }
+
+ @Test
+ public void givenTestStrings_whenReplaceAll_thenProcessedString() {
+
+ String master2 = "Welcome to Baeldung, Hello World Baeldung";
+ String regexTarget= "(Baeldung)$";
+ String replacement = "Java";
+ String processed2 = master2.replaceAll(regexTarget, replacement);
+ assertTrue(processed2.endsWith("Java"));
+
+ }
+
+ @Test
+ public void givenTestStrings_whenStringBuilderMethods_thenProcessedString() {
+
+ String master = "Hello World Baeldung!";
+ String target = "Baeldung";
+ String replacement = "Java";
+
+ int startIndex = master.indexOf(target);
+ int stopIndex = startIndex + target.length();
+
+ StringBuilder builder = new StringBuilder(master);
+
+
+ builder.delete(startIndex, stopIndex);
+ assertFalse(builder.toString().contains(target));
+
+
+ builder.replace(startIndex, stopIndex, replacement);
+ assertTrue(builder.toString().contains(replacement));
+
+
+ }
+
+
+ @Test
+ public void givenTestStrings_whenStringUtilsMethods_thenProcessedStrings() {
+
+ String master = "Hello World Baeldung!";
+ String target = "Baeldung";
+ String replacement = "Java";
+
+ String processed = StringUtils.replace(master, target, replacement);
+ assertTrue(processed.contains(replacement));
+
+ String master2 = "Hello World Baeldung!";
+ String target2 = "baeldung";
+ String processed2 = StringUtils.replaceIgnoreCase(master2, target2, replacement);
+ assertFalse(processed2.contains(target));
+
+ }
+
+
+
+
+
+
+
+}
diff --git a/java-strings/src/test/java/com/baeldung/stringduplicates/RemoveDuplicateFromStringUnitTest.java b/java-strings/src/test/java/com/baeldung/stringduplicates/RemoveDuplicateFromStringUnitTest.java
index cf7819ced3..895ecc4a3b 100644
--- a/java-strings/src/test/java/com/baeldung/stringduplicates/RemoveDuplicateFromStringUnitTest.java
+++ b/java-strings/src/test/java/com/baeldung/stringduplicates/RemoveDuplicateFromStringUnitTest.java
@@ -8,6 +8,8 @@ public class RemoveDuplicateFromStringUnitTest {
private final static String STR1 = "racecar";
private final static String STR2 = "J2ee programming";
+ private final static String STR_EMPTY = "";
+
private RemoveDuplicateFromString removeDuplicateFromString;
@Before
@@ -20,6 +22,8 @@ public class RemoveDuplicateFromStringUnitTest {
public void whenUsingCharArray_DuplicatesShouldBeRemovedWithoutKeepingStringOrder() {
String str1 = removeDuplicateFromString.removeDuplicatesUsingCharArray(STR1);
String str2 = removeDuplicateFromString.removeDuplicatesUsingCharArray(STR2);
+ String strEmpty = removeDuplicateFromString.removeDuplicatesUsingCharArray(STR_EMPTY);
+ Assert.assertEquals("", strEmpty);
Assert.assertEquals("ecar", str1);
Assert.assertEquals("J2e poraming", str2);
}
@@ -28,6 +32,9 @@ public class RemoveDuplicateFromStringUnitTest {
public void whenUsingLinkedHashSet_DuplicatesShouldBeRemovedAndItKeepStringOrder() {
String str1 = removeDuplicateFromString.removeDuplicatesUsinglinkedHashSet(STR1);
String str2 = removeDuplicateFromString.removeDuplicatesUsinglinkedHashSet(STR2);
+
+ String strEmpty = removeDuplicateFromString.removeDuplicatesUsinglinkedHashSet(STR_EMPTY);
+ Assert.assertEquals("", strEmpty);
Assert.assertEquals("race", str1);
Assert.assertEquals("J2e progamin", str2);
}
@@ -36,6 +43,9 @@ public class RemoveDuplicateFromStringUnitTest {
public void whenUsingSorting_DuplicatesShouldBeRemovedWithoutKeepingStringOrder() {
String str1 = removeDuplicateFromString.removeDuplicatesUsingSorting(STR1);
String str2 = removeDuplicateFromString.removeDuplicatesUsingSorting(STR2);
+
+ String strEmpty = removeDuplicateFromString.removeDuplicatesUsingSorting(STR_EMPTY);
+ Assert.assertEquals("", strEmpty);
Assert.assertEquals("acer", str1);
Assert.assertEquals(" 2Jaegimnopr", str2);
}
@@ -44,6 +54,8 @@ public class RemoveDuplicateFromStringUnitTest {
public void whenUsingHashSet_DuplicatesShouldBeRemovedWithoutKeepingStringOrder() {
String str1 = removeDuplicateFromString.removeDuplicatesUsingHashSet(STR1);
String str2 = removeDuplicateFromString.removeDuplicatesUsingHashSet(STR2);
+ String strEmpty = removeDuplicateFromString.removeDuplicatesUsingHashSet(STR_EMPTY);
+ Assert.assertEquals("", strEmpty);
Assert.assertEquals("arce", str1);
Assert.assertEquals(" pa2regiJmno", str2);
}
@@ -52,7 +64,19 @@ public class RemoveDuplicateFromStringUnitTest {
public void whenUsingIndexOf_DuplicatesShouldBeRemovedWithoutKeepingStringOrder() {
String str1 = removeDuplicateFromString.removeDuplicatesUsingIndexOf(STR1);
String str2 = removeDuplicateFromString.removeDuplicatesUsingIndexOf(STR2);
+ String strEmpty = removeDuplicateFromString.removeDuplicatesUsingIndexOf(STR_EMPTY);
+ Assert.assertEquals("", strEmpty);
Assert.assertEquals("ecar", str1);
Assert.assertEquals("J2e poraming", str2);
}
+
+ @Test
+ public void whenUsingJava8_DuplicatesShouldBeRemovedAndItKeepStringOrder() {
+ String str1 = removeDuplicateFromString.removeDuplicatesUsingDistinct(STR1);
+ String str2 = removeDuplicateFromString.removeDuplicatesUsingDistinct(STR2);
+ String strEmpty = removeDuplicateFromString.removeDuplicatesUsingDistinct(STR_EMPTY);
+ Assert.assertEquals("", strEmpty);
+ Assert.assertEquals("race", str1);
+ Assert.assertEquals("J2e progamin", str2);
+ }
}
diff --git a/jee-7/pom.xml b/jee-7/pom.xml
index 4f6e6a20fb..9011648d17 100644
--- a/jee-7/pom.xml
+++ b/jee-7/pom.xml
@@ -1,430 +1,537 @@
-
- 4.0.0
- jee-7
- 1.0-SNAPSHOT
- war
- JavaEE 7 Arquillian Archetype Sample
+
+ 4.0.0
+ jee-7
+ 1.0-SNAPSHOT
+ war
+ JavaEE 7 Arquillian Archetype Sample
-
- com.baeldung
- parent-modules
- 1.0.0-SNAPSHOT
-
+
+ com.baeldung
+ parent-modules
+ 1.0.0-SNAPSHOT
+
-
-
- javax
- javaee-api
- ${javaee_api.version}
- provided
-
+
+
+ javax
+ javaee-api
+ ${javaee_api.version}
+ provided
+
-
- org.jboss.arquillian.junit
- arquillian-junit-container
- test
-
-
- org.jboss.arquillian.graphene
- graphene-webdriver
- ${graphene-webdriver.version}
- pom
- test
-
-
- com.jayway.awaitility
- awaitility
- ${awaitility.version}
- test
-
+
+ org.jboss.arquillian.junit
+ arquillian-junit-container
+ test
+
+
+ org.jboss.arquillian.graphene
+ graphene-webdriver
+ ${graphene-webdriver.version}
+ pom
+ test
+
+
+ com.jayway.awaitility
+ awaitility
+ ${awaitility.version}
+ test
+
-
- org.jboss.shrinkwrap.resolver
- shrinkwrap-resolver-impl-maven
- test
- jar
-
+
+ org.jboss.shrinkwrap.resolver
+ shrinkwrap-resolver-impl-maven
+ test
+ jar
+
-
- org.jboss.shrinkwrap.resolver
- shrinkwrap-resolver-impl-maven-archive
- test
-
-
- org.apache.httpcomponents
- httpclient
- ${httpclient.version}
-
-
- commons-io
- commons-io
- ${commons-io.version}
-
-
- com.sun.faces
- jsf-api
- ${com.sun.faces.jsf.version}
-
-
- com.sun.faces
- jsf-impl
- ${com.sun.faces.jsf.version}
-
-
- javax.servlet
- jstl
- ${jstl.version}
-
-
- javax.servlet
- javax.servlet-api
- ${javax.servlet-api.version}
-
-
- javax.servlet.jsp
- jsp-api
- ${jsp-api.version}
- provided
-
-
- taglibs
- standard
- ${taglibs.standard.version}
-
+
+ org.jboss.shrinkwrap.resolver
+ shrinkwrap-resolver-impl-maven-archive
+ test
+
+
+ org.apache.httpcomponents
+ httpclient
+ ${httpclient.version}
+
+
+ commons-io
+ commons-io
+ ${commons-io.version}
+
+
+ com.sun.faces
+ jsf-api
+ ${com.sun.faces.jsf.version}
+
+
+ com.sun.faces
+ jsf-impl
+ ${com.sun.faces.jsf.version}
+
+
+ javax.servlet
+ jstl
+ ${jstl.version}
+
+
+ javax.servlet
+ javax.servlet-api
+ ${javax.servlet-api.version}
+
+
+ javax.servlet.jsp
+ jsp-api
+ ${jsp-api.version}
+ provided
+
+
+ taglibs
+ standard
+ ${taglibs.standard.version}
+
-
- javax.mvc
- javax.mvc-api
- 20160715
-
-
- org.glassfish.ozark
- ozark
- ${ozark.version}
-
+
+ javax.mvc
+ javax.mvc-api
+ 20160715
+
+
+ org.glassfish.ozark
+ ozark
+ ${ozark.version}
+
-
- org.springframework.security
- spring-security-web
- ${org.springframework.security.version}
-
+
+ org.springframework.security
+ spring-security-web
+ ${org.springframework.security.version}
+
-
- org.springframework.security
- spring-security-config
- ${org.springframework.security.version}
-
-
- org.springframework.security
- spring-security-taglibs
- ${org.springframework.security.version}
-
-
+
+ org.springframework.security
+ spring-security-config
+ ${org.springframework.security.version}
+
+
+ org.springframework.security
+ spring-security-taglibs
+ ${org.springframework.security.version}
+
+
-
-
-
- org.apache.maven.plugins
- maven-war-plugin
- ${maven-war-plugin.version}
-
- src/main/webapp
- false
-
-
-
-
+
+ org.jboss.spec.javax.batch
+ jboss-batch-api_1.0_spec
+ 1.0.0.Final
+
+
+ org.jberet
+ jberet-core
+ 1.0.2.Final
+
+
+ org.jberet
+ jberet-support
+ 1.0.2.Final
+
+
+ org.jboss.spec.javax.transaction
+ jboss-transaction-api_1.2_spec
+ 1.0.0.Final
+
+
+ org.jboss.marshalling
+ jboss-marshalling
+ 1.4.2.Final
+
+
+ org.jboss.weld
+ weld-core
+ 2.1.1.Final
+
+
+ org.jboss.weld.se
+ weld-se
+ 2.1.1.Final
+
+
+ org.jberet
+ jberet-se
+ 1.0.2.Final
+
+
+ com.h2database
+ h2
+ 1.4.178
+
+
+ org.glassfish.jersey.containers
+ jersey-container-jetty-servlet
+ 2.22.1
+
+
-
-
-
- org.jboss.arquillian
- arquillian-bom
- ${arquillian_core.version}
- import
- pom
-
-
- org.jboss.arquillian.extension
- arquillian-drone-bom
- ${arquillian-drone-bom.version}
- pom
- import
-
-
-
+
+
+
+ org.apache.maven.plugins
+ maven-war-plugin
+ ${maven-war-plugin.version}
+
+ src/main/webapp
+ false
+
+
+
+
+
+
+
+ org.eclipse.m2e
+ lifecycle-mapping
+ 1.0.0
+
+
+
+
+
+
+ org.apache.maven.plugins
+
+
+ maven-pmd-plugin
+
+
+ [3.8,)
+
+
+ check
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
- wildfly-managed-arquillian
-
- true
-
-
- standalone-full.xml
- ${project.build.directory}/wildfly-${version.wildfly}
-
-
-
- io.undertow
- undertow-websockets-jsr
- ${undertow-websockets-jsr.version}
- test
-
-
- org.jboss.resteasy
- resteasy-client
- ${resteasy.version}
- test
-
-
- org.jboss.resteasy
- resteasy-jaxb-provider
- ${resteasy.version}
- test
-
-
- org.jboss.resteasy
- resteasy-json-p-provider
- ${resteasy.version}
- test
-
-
- org.wildfly
- wildfly-arquillian-container-managed
- ${wildfly.version}
- test
-
-
+
+
+
+ org.jboss.arquillian
+ arquillian-bom
+ ${arquillian_core.version}
+ import
+ pom
+
+
+ org.jboss.arquillian.extension
+ arquillian-drone-bom
+ ${arquillian-drone-bom.version}
+ pom
+ import
+
+
+
-
-
-
-
- maven-dependency-plugin
- ${maven-dependency-plugin.version}
-
- ${maven.test.skip}
-
-
-
- unpack
- process-test-classes
-
- unpack
-
-
-
-
- org.wildfly
- wildfly-dist
- ${wildfly.version}
- zip
- false
- ${project.build.directory}
-
-
-
-
-
-
-
- maven-surefire-plugin
- ${maven-surefire-plugin.version}
-
-
- ${project.build.directory}/wildfly-${wildfly.version}
-
-
-
-
-
-
-
-
- wildfly-remote-arquillian
-
-
- io.undertow
- undertow-websockets-jsr
- ${undertow-websockets-jsr.version}
- test
-
-
- org.jboss.resteasy
- resteasy-client
- ${resteasy.version}
- test
-
-
- org.jboss.resteasy
- resteasy-jaxb-provider
- ${resteasy.version}
- test
-
-
- org.jboss.resteasy
- resteasy-json-p-provider
- ${resteasy.version}
- test
-
-
- org.wildfly
- wildfly-arquillian-container-remote
- ${wildfly.version}
- test
-
-
-
-
- glassfish-embedded-arquillian
-
-
- org.glassfish.main.extras
- glassfish-embedded-all
- ${glassfish-embedded-all.version}
- test
-
-
- org.glassfish
- javax.json
- ${javax.json.version}
- test
-
-
- org.glassfish.tyrus
- tyrus-client
- ${tyrus.version}
- test
-
-
- org.glassfish.tyrus
- tyrus-container-grizzly-client
- ${tyrus.version}
- test
-
-
- org.glassfish.jersey.core
- jersey-client
- ${jersey.version}
- test
-
-
- org.jboss.arquillian.container
- arquillian-glassfish-embedded-3.1
- ${arquillian-glassfish.version}
- test
-
-
-
-
- glassfish-remote-arquillian
-
-
- org.glassfish
- javax.json
- ${javax.json.version}
- test
-
-
- org.glassfish.tyrus
- tyrus-client
- ${tyrus.version}
- test
-
-
- org.glassfish.tyrus
- tyrus-container-grizzly-client
- ${tyrus.version}
- test
-
-
- org.glassfish.jersey.core
- jersey-client
- ${jersey.version}
- test
-
-
- org.glassfish.jersey.media
- jersey-media-json-jackson
- ${jersey.version}
- test
-
-
- org.glassfish.jersey.media
- jersey-media-json-processing
- ${jersey.version}
- test
-
-
- org.jboss.arquillian.container
- arquillian-glassfish-remote-3.1
- ${arquillian-glassfish.version}
- test
-
-
-
-
- webdriver-chrome
-
- true
-
-
- chrome
-
-
-
- webdriver-firefox
-
- firefox
-
-
-
+
+
+ wildfly-managed-arquillian
+
+ true
+
+
+ standalone-full.xml
+ ${project.build.directory}/wildfly-${version.wildfly}
+
+
+
+ io.undertow
+ undertow-websockets-jsr
+ ${undertow-websockets-jsr.version}
+ test
+
+
+ org.jboss.resteasy
+ resteasy-client
+ ${resteasy.version}
+ test
+
+
+ org.jboss.resteasy
+ resteasy-jaxb-provider
+ ${resteasy.version}
+ test
+
+
+ org.jboss.resteasy
+ resteasy-json-p-provider
+ ${resteasy.version}
+ test
+
+
+ org.wildfly
+ wildfly-arquillian-container-managed
+ ${wildfly.version}
+ test
+
+
+ sun.jdk
+ jconsole
+
+
+
+
-
-
- bintray-mvc-spec-maven
- bintray
- http://dl.bintray.com/mvc-spec/maven
-
- true
-
-
- false
-
-
-
+
+
+
+
+ maven-dependency-plugin
+ ${maven-dependency-plugin.version}
+
+ ${maven.test.skip}
+
+
+
+ unpack
+ process-test-classes
+
+ unpack
+
+
+
+
+ org.wildfly
+ wildfly-dist
+ ${wildfly.version}
+ zip
+ false
+ ${project.build.directory}
+
+
+ sun.jdk
+ jconsole
+
+
+
+
+
+
+
+
+
+ maven-surefire-plugin
+ ${maven-surefire-plugin.version}
+
+
+ ${project.build.directory}/wildfly-${wildfly.version}
+
+
+
+
+
+
+
+
+ wildfly-remote-arquillian
+
+
+ io.undertow
+ undertow-websockets-jsr
+ ${undertow-websockets-jsr.version}
+ test
+
+
+ org.jboss.resteasy
+ resteasy-client
+ ${resteasy.version}
+ test
+
+
+ org.jboss.resteasy
+ resteasy-jaxb-provider
+ ${resteasy.version}
+ test
+
+
+ org.jboss.resteasy
+ resteasy-json-p-provider
+ ${resteasy.version}
+ test
+
+
+ org.wildfly
+ wildfly-arquillian-container-remote
+ ${wildfly.version}
+ test
+
+
+ sun.jdk
+ jconsole
+
+
+
+
+
+
+ glassfish-embedded-arquillian
+
+
+ org.glassfish.main.extras
+ glassfish-embedded-all
+ ${glassfish-embedded-all.version}
+ test
+
+
+ org.glassfish
+ javax.json
+ ${javax.json.version}
+ test
+
+
+ org.glassfish.tyrus
+ tyrus-client
+ ${tyrus.version}
+ test
+
+
+ org.glassfish.tyrus
+ tyrus-container-grizzly-client
+ ${tyrus.version}
+ test
+
+
+ org.glassfish.jersey.core
+ jersey-client
+ ${jersey.version}
+ test
+
+
+ org.jboss.arquillian.container
+ arquillian-glassfish-embedded-3.1
+ ${arquillian-glassfish.version}
+ test
+
+
+
+
+ glassfish-remote-arquillian
+
+
+ org.glassfish
+ javax.json
+ ${javax.json.version}
+ test
+
+
+ org.glassfish.tyrus
+ tyrus-client
+ ${tyrus.version}
+ test
+
+
+ org.glassfish.tyrus
+ tyrus-container-grizzly-client
+ ${tyrus.version}
+ test
+
+
+ org.glassfish.jersey.core
+ jersey-client
+ ${jersey.version}
+ test
+
+
+ org.glassfish.jersey.media
+ jersey-media-json-jackson
+ ${jersey.version}
+ test
+
+
+ org.glassfish.jersey.media
+ jersey-media-json-processing
+ ${jersey.version}
+ test
+
+
+ org.jboss.arquillian.container
+ arquillian-glassfish-remote-3.1
+ ${arquillian-glassfish.version}
+ test
+
+
+
+
+ webdriver-chrome
+
+ true
+
+
+ chrome
+
+
+
+ webdriver-firefox
+
+ firefox
+
+
+
-
- 1.8
- 3.0.0
- 7.0
- 1.1.11.Final
- 8.2.1.Final
- 1.7.0
- 1.4.6.Final
- 3.0.19.Final
- 4.1.1
- 1.0.4
- 1.13
- 2.25
- 1.0.0.Final
- 2.6
- 4.2.3.RELEASE
- 2.21.0
- 1.1.2
- 2.4
- 2.2.14
- 4.5
- 2.0.1.Final
- 3.1.0
- 2.1.0.Final
- 2.8
- 1.2
- 2.2
- 20160715
-
+
+
+ bintray-mvc-spec-maven
+ bintray
+ http://dl.bintray.com/mvc-spec/maven
+
+ true
+
+
+ false
+
+
+
-
+
+ 1.8
+ 3.0.0
+ 7.0
+ 1.1.11.Final
+ 8.2.1.Final
+ 1.7.0
+ 1.4.6.Final
+ 3.0.19.Final
+ 4.1.1
+ 1.0.4
+ 1.13
+ 2.25
+ 1.0.0.Final
+ 2.6
+ 4.2.3.RELEASE
+ 2.21.0
+ 1.1.2
+ 2.4
+ 2.2.14
+ 4.5
+ 2.0.1.Final
+ 3.1.0
+ 2.1.0.Final
+ 2.8
+ 1.2
+ 2.2
+ 20160715
+
+
+
\ No newline at end of file
diff --git a/jee-7/src/main/java/com/baeldung/batch/understanding/ChunkExceptionSkipReadListener.java b/jee-7/src/main/java/com/baeldung/batch/understanding/ChunkExceptionSkipReadListener.java
new file mode 100644
index 0000000000..ce47de66af
--- /dev/null
+++ b/jee-7/src/main/java/com/baeldung/batch/understanding/ChunkExceptionSkipReadListener.java
@@ -0,0 +1,11 @@
+package com.baeldung.batch.understanding;
+
+import javax.batch.api.chunk.listener.SkipReadListener;
+import javax.inject.Named;
+
+@Named
+public class ChunkExceptionSkipReadListener implements SkipReadListener {
+ @Override
+ public void onSkipReadItem(Exception e) throws Exception {
+ }
+}
\ No newline at end of file
diff --git a/jee-7/src/main/java/com/baeldung/batch/understanding/CustomCheckPoint.java b/jee-7/src/main/java/com/baeldung/batch/understanding/CustomCheckPoint.java
new file mode 100644
index 0000000000..fe6759b365
--- /dev/null
+++ b/jee-7/src/main/java/com/baeldung/batch/understanding/CustomCheckPoint.java
@@ -0,0 +1,12 @@
+package com.baeldung.batch.understanding;
+
+import javax.batch.api.chunk.AbstractCheckpointAlgorithm;
+import javax.inject.Named;
+
+@Named
+public class CustomCheckPoint extends AbstractCheckpointAlgorithm {
+ @Override
+ public boolean isReadyToCheckpoint() throws Exception {
+ return SimpleChunkItemReader.COUNT % 5 == 0;
+ }
+}
diff --git a/jee-7/src/main/java/com/baeldung/batch/understanding/DeciderJobSequence.java b/jee-7/src/main/java/com/baeldung/batch/understanding/DeciderJobSequence.java
new file mode 100644
index 0000000000..6cc2012f23
--- /dev/null
+++ b/jee-7/src/main/java/com/baeldung/batch/understanding/DeciderJobSequence.java
@@ -0,0 +1,14 @@
+package com.baeldung.batch.understanding;
+
+import javax.batch.api.Decider;
+import javax.batch.runtime.StepExecution;
+import javax.inject.Named;
+
+@Named
+public class DeciderJobSequence implements Decider {
+ @Override
+ public String decide(StepExecution[] ses) throws Exception {
+ return "nothing";
+ }
+
+}
\ No newline at end of file
diff --git a/jee-7/src/main/java/com/baeldung/batch/understanding/InjectSimpleBatchLet.java b/jee-7/src/main/java/com/baeldung/batch/understanding/InjectSimpleBatchLet.java
new file mode 100644
index 0000000000..93eb20708d
--- /dev/null
+++ b/jee-7/src/main/java/com/baeldung/batch/understanding/InjectSimpleBatchLet.java
@@ -0,0 +1,20 @@
+package com.baeldung.batch.understanding;
+
+import javax.batch.api.AbstractBatchlet;
+import javax.batch.api.BatchProperty;
+import javax.batch.runtime.BatchStatus;
+import javax.inject.Inject;
+import javax.inject.Named;
+
+@Named
+public class InjectSimpleBatchLet extends AbstractBatchlet {
+ @Inject
+ @BatchProperty(name = "name")
+ private String nameString;
+
+ @Override
+ public String process() throws Exception {
+ System.out.println("Value passed in = " + nameString);
+ return BatchStatus.COMPLETED.toString();
+ }
+}
diff --git a/jee-7/src/main/java/com/baeldung/batch/understanding/SimpleBatchLet.java b/jee-7/src/main/java/com/baeldung/batch/understanding/SimpleBatchLet.java
new file mode 100644
index 0000000000..6a367b064b
--- /dev/null
+++ b/jee-7/src/main/java/com/baeldung/batch/understanding/SimpleBatchLet.java
@@ -0,0 +1,13 @@
+package com.baeldung.batch.understanding;
+
+import javax.batch.api.AbstractBatchlet;
+import javax.batch.runtime.BatchStatus;
+import javax.inject.Named;
+
+@Named
+public class SimpleBatchLet extends AbstractBatchlet {
+ @Override
+ public String process() throws Exception {
+ return BatchStatus.FAILED.toString();
+ }
+}
diff --git a/jee-7/src/main/java/com/baeldung/batch/understanding/SimpleChunkItemProcessor.java b/jee-7/src/main/java/com/baeldung/batch/understanding/SimpleChunkItemProcessor.java
new file mode 100644
index 0000000000..3f8166b6d8
--- /dev/null
+++ b/jee-7/src/main/java/com/baeldung/batch/understanding/SimpleChunkItemProcessor.java
@@ -0,0 +1,12 @@
+package com.baeldung.batch.understanding;
+
+import javax.batch.api.chunk.ItemProcessor;
+import javax.inject.Named;
+
+@Named
+public class SimpleChunkItemProcessor implements ItemProcessor {
+ @Override
+ public Integer processItem(Object t) {
+ return ((Integer) t).intValue() % 2 == 0 ? null : ((Integer) t).intValue();
+ }
+}
diff --git a/jee-7/src/main/java/com/baeldung/batch/understanding/SimpleChunkItemReader.java b/jee-7/src/main/java/com/baeldung/batch/understanding/SimpleChunkItemReader.java
new file mode 100644
index 0000000000..10f81d95d0
--- /dev/null
+++ b/jee-7/src/main/java/com/baeldung/batch/understanding/SimpleChunkItemReader.java
@@ -0,0 +1,27 @@
+package com.baeldung.batch.understanding;
+
+import java.io.Serializable;
+import java.util.StringTokenizer;
+import javax.batch.api.chunk.AbstractItemReader;
+import javax.inject.Named;
+
+@Named
+public class SimpleChunkItemReader extends AbstractItemReader {
+ private StringTokenizer tokens;
+ public static int COUNT = 0;
+
+ @Override
+ public Integer readItem() throws Exception {
+ if (tokens.hasMoreTokens()) {
+ COUNT++;
+ String tempTokenize = tokens.nextToken();
+ return Integer.valueOf(tempTokenize);
+ }
+ return null;
+ }
+
+ @Override
+ public void open(Serializable checkpoint) throws Exception {
+ tokens = new StringTokenizer("1,2,3,4,5,6,7,8,9,10", ",");
+ }
+}
diff --git a/jee-7/src/main/java/com/baeldung/batch/understanding/SimpleChunkItemReaderError.java b/jee-7/src/main/java/com/baeldung/batch/understanding/SimpleChunkItemReaderError.java
new file mode 100644
index 0000000000..92096d0571
--- /dev/null
+++ b/jee-7/src/main/java/com/baeldung/batch/understanding/SimpleChunkItemReaderError.java
@@ -0,0 +1,31 @@
+package com.baeldung.batch.understanding;
+
+import java.io.Serializable;
+import java.util.StringTokenizer;
+
+import javax.batch.api.chunk.AbstractItemReader;
+import javax.inject.Named;
+
+@Named
+public class SimpleChunkItemReaderError extends AbstractItemReader {
+ private StringTokenizer tokens;
+ public static int COUNT = 0;
+
+ @Override
+ public Integer readItem() throws Exception {
+ if (tokens.hasMoreTokens()) {
+ COUNT++;
+ int token = Integer.valueOf(tokens.nextToken());
+ if (token == 3) {
+ throw new RuntimeException("Something happened");
+ }
+ return Integer.valueOf(token);
+ }
+ return null;
+ }
+
+ @Override
+ public void open(Serializable checkpoint) throws Exception {
+ tokens = new StringTokenizer("1,2,3,4,5,6,7,8,9,10", ",");
+ }
+}
\ No newline at end of file
diff --git a/jee-7/src/main/java/com/baeldung/batch/understanding/SimpleChunkWriter.java b/jee-7/src/main/java/com/baeldung/batch/understanding/SimpleChunkWriter.java
new file mode 100644
index 0000000000..909596766d
--- /dev/null
+++ b/jee-7/src/main/java/com/baeldung/batch/understanding/SimpleChunkWriter.java
@@ -0,0 +1,13 @@
+package com.baeldung.batch.understanding;
+
+import java.util.List;
+
+import javax.batch.api.chunk.AbstractItemWriter;
+import javax.inject.Named;
+
+@Named
+public class SimpleChunkWriter extends AbstractItemWriter {
+ @Override
+ public void writeItems(List