commit
91633ff4cf
|
@ -1,3 +1,4 @@
|
|||
**UPDATE**: The price of "Learn Spring Security OAuth" will permanently change on the 11th of December, along with the upcoming OAuth2 material: http://bit.ly/github-lss
|
||||
|
||||
The Courses
|
||||
==============================
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
package com.baeldung.algorithms.mergesortedarrays;
|
||||
|
||||
public class SortedArrays {
|
||||
|
||||
public static int[] merge(int[] foo, int[] bar) {
|
||||
|
||||
int fooLength = foo.length;
|
||||
int barLength = bar.length;
|
||||
|
||||
int[] merged = new int[fooLength + barLength];
|
||||
|
||||
int fooPosition, barPosition, mergedPosition;
|
||||
fooPosition = barPosition = mergedPosition = 0;
|
||||
|
||||
while (fooPosition < fooLength && barPosition < barLength) {
|
||||
if (foo[fooPosition] < bar[barPosition]) {
|
||||
merged[mergedPosition++] = foo[fooPosition++];
|
||||
} else {
|
||||
merged[mergedPosition++] = bar[barPosition++];
|
||||
}
|
||||
}
|
||||
|
||||
while (fooPosition < fooLength) {
|
||||
merged[mergedPosition++] = foo[fooPosition++];
|
||||
}
|
||||
|
||||
while (barPosition < barLength) {
|
||||
merged[mergedPosition++] = bar[barPosition++];
|
||||
}
|
||||
|
||||
return merged;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.baeldung.algorithms.mergesortedarrays;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import com.baeldung.algorithms.mergesortedarrays.SortedArrays;
|
||||
|
||||
public class SortedArraysUnitTest {
|
||||
|
||||
@Test
|
||||
public void givenTwoSortedArrays_whenMerged_thenReturnMergedSortedArray() {
|
||||
|
||||
int[] foo = { 3, 7 };
|
||||
int[] bar = { 4, 8, 11 };
|
||||
int[] merged = { 3, 4, 7, 8, 11 };
|
||||
|
||||
assertArrayEquals(merged, SortedArrays.merge(foo, bar));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenTwoSortedArraysWithDuplicates_whenMerged_thenReturnMergedSortedArray() {
|
||||
|
||||
int[] foo = { 3, 3, 7 };
|
||||
int[] bar = { 4, 8, 8, 11 };
|
||||
int[] merged = { 3, 3, 4, 7, 8, 8, 11 };
|
||||
|
||||
assertArrayEquals(merged, SortedArrays.merge(foo, bar));
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
## AWS
|
||||
|
||||
This module contains articles about AWS
|
||||
This module contains articles about Amazon Web Services (AWS)
|
||||
|
||||
### Relevant articles
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
=========
|
||||
|
||||
## Core Java Concurrency Advanced Examples
|
||||
|
||||
This module contains articles about advanced topics about multithreading with core Java.
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
=========
|
||||
## Core Java Concurrency Basic
|
||||
|
||||
## Core Java Concurrency Basic 2 Examples
|
||||
This module contains articles about basic Java concurrency
|
||||
|
||||
### Relevant Articles:
|
||||
- [How to Delay Code Execution in Java](https://www.baeldung.com/java-delay-code-execution)
|
||||
|
@ -8,3 +8,4 @@
|
|||
- [Difference Between Wait and Sleep in Java](https://www.baeldung.com/java-wait-and-sleep)
|
||||
- [Guide to the Synchronized Keyword in Java](https://www.baeldung.com/java-synchronized)
|
||||
- [Life Cycle of a Thread in Java](https://www.baeldung.com/java-thread-lifecycle)
|
||||
- [[<-- Prev]](/core-java-modules/core-java-concurrency-basic)
|
|
@ -17,3 +17,4 @@ This module contains articles about core java exceptions
|
|||
- [Common Java Exceptions](https://www.baeldung.com/java-common-exceptions)
|
||||
- [How to Find an Exception’s Root Cause in Java](https://www.baeldung.com/java-exception-root-cause)
|
||||
- [Is It a Bad Practice to Catch Throwable?](https://www.baeldung.com/java-catch-throwable-bad-practice)
|
||||
- [[Next -->]](/core-java-modules/core-java-exceptions-2)
|
|
@ -156,10 +156,16 @@ public class FileClassUnitTest {
|
|||
|
||||
private static File makeDir(String name) {
|
||||
File directory = new File(name);
|
||||
directory.mkdir();
|
||||
if (directory.isDirectory()) {
|
||||
|
||||
// If the directory already exists, make sure we create it 'from scratch', i.e. all the files inside are deleted first
|
||||
if (directory.exists()) {
|
||||
removeDir(directory);
|
||||
}
|
||||
|
||||
if (directory.mkdir()) {
|
||||
return directory;
|
||||
}
|
||||
|
||||
throw new RuntimeException("'" + name + "' not made!");
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package com.baeldung.overflow;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class OverflowUnitTest {
|
||||
|
||||
@Test
|
||||
public void positive_and_negative_zero_are_not_always_equal() {
|
||||
|
||||
double a = +0f;
|
||||
double b = -0f;
|
||||
|
||||
assertTrue(a == b);
|
||||
|
||||
assertTrue(1/a == Double.POSITIVE_INFINITY);
|
||||
assertTrue(1/b == Double.NEGATIVE_INFINITY);
|
||||
|
||||
assertTrue(1/a != 1/b);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package com.baeldung.printbinarytree;
|
||||
|
||||
public class BinaryTreeModel {
|
||||
|
||||
private Object value;
|
||||
private BinaryTreeModel left;
|
||||
private BinaryTreeModel right;
|
||||
|
||||
public BinaryTreeModel(Object value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public Object getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(Object value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public BinaryTreeModel getLeft() {
|
||||
return left;
|
||||
}
|
||||
|
||||
public void setLeft(BinaryTreeModel left) {
|
||||
this.left = left;
|
||||
}
|
||||
|
||||
public BinaryTreeModel getRight() {
|
||||
return right;
|
||||
}
|
||||
|
||||
public void setRight(BinaryTreeModel right) {
|
||||
this.right = right;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package com.baeldung.printbinarytree;
|
||||
|
||||
import java.io.PrintStream;
|
||||
|
||||
public class BinaryTreePrinter {
|
||||
|
||||
private BinaryTreeModel tree;
|
||||
|
||||
public BinaryTreePrinter(BinaryTreeModel tree) {
|
||||
this.tree = tree;
|
||||
}
|
||||
|
||||
private String traversePreOrder(BinaryTreeModel root) {
|
||||
|
||||
if (root == null) {
|
||||
return "";
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(root.getValue());
|
||||
|
||||
String pointerRight = "└──";
|
||||
String pointerLeft = (root.getRight() != null) ? "├──" : "└──";
|
||||
|
||||
traverseNodes(sb, "", pointerLeft, root.getLeft(), root.getRight() != null);
|
||||
traverseNodes(sb, "", pointerRight, root.getRight(), false);
|
||||
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private void traverseNodes(StringBuilder sb, String padding, String pointer, BinaryTreeModel node,
|
||||
boolean hasRightSibling) {
|
||||
|
||||
if (node != null) {
|
||||
|
||||
sb.append("\n");
|
||||
sb.append(padding);
|
||||
sb.append(pointer);
|
||||
sb.append(node.getValue());
|
||||
|
||||
StringBuilder paddingBuilder = new StringBuilder(padding);
|
||||
if (hasRightSibling) {
|
||||
paddingBuilder.append("│ ");
|
||||
} else {
|
||||
paddingBuilder.append(" ");
|
||||
}
|
||||
|
||||
String paddingForBoth = paddingBuilder.toString();
|
||||
String pointerRight = "└──";
|
||||
String pointerLeft = (node.getRight() != null) ? "├──" : "└──";
|
||||
|
||||
traverseNodes(sb, paddingForBoth, pointerLeft, node.getLeft(), node.getRight() != null);
|
||||
traverseNodes(sb, paddingForBoth, pointerRight, node.getRight(), false);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void print(PrintStream os) {
|
||||
os.print(traversePreOrder(tree));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,178 @@
|
|||
package com.baeldung.printbinarytree;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.baeldung.printbinarytree.BinaryTreeModel;
|
||||
import com.baeldung.printbinarytree.BinaryTreePrinter;
|
||||
|
||||
public class PrintingBinaryTreeModelUnitTest {
|
||||
|
||||
private BinaryTreeModel balanced;
|
||||
private BinaryTreeModel leftSkewed;
|
||||
private BinaryTreeModel rightSkewed;
|
||||
|
||||
private OutputStream output;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
balanced = createBalancedTree();
|
||||
leftSkewed = createLeftUnbalancedTree();
|
||||
rightSkewed = createRightUnbalancedTree();
|
||||
|
||||
output = new ByteArrayOutputStream();
|
||||
System.setOut(new PrintStream(output));
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
System.setOut(System.out);
|
||||
}
|
||||
|
||||
private BinaryTreeModel createBalancedTree() {
|
||||
|
||||
BinaryTreeModel root = new BinaryTreeModel("root");
|
||||
|
||||
BinaryTreeModel node1 = new BinaryTreeModel("node1");
|
||||
BinaryTreeModel node2 = new BinaryTreeModel("node2");
|
||||
root.setLeft(node1);
|
||||
root.setRight(node2);
|
||||
|
||||
BinaryTreeModel node3 = new BinaryTreeModel("node3");
|
||||
BinaryTreeModel node4 = new BinaryTreeModel("node4");
|
||||
node1.setLeft(node3);
|
||||
node1.setRight(node4);
|
||||
|
||||
node2.setLeft(new BinaryTreeModel("node5"));
|
||||
node2.setRight(new BinaryTreeModel("node6"));
|
||||
|
||||
BinaryTreeModel node7 = new BinaryTreeModel("node7");
|
||||
node3.setLeft(node7);
|
||||
node7.setLeft(new BinaryTreeModel("node8"));
|
||||
node7.setRight(new BinaryTreeModel("node9"));
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
private BinaryTreeModel createLeftUnbalancedTree() {
|
||||
|
||||
BinaryTreeModel root = new BinaryTreeModel("root");
|
||||
|
||||
BinaryTreeModel node1 = new BinaryTreeModel("node1");
|
||||
root.setLeft(node1);
|
||||
root.setRight(new BinaryTreeModel("node2"));
|
||||
|
||||
BinaryTreeModel node3 = new BinaryTreeModel("node3");
|
||||
node1.setLeft(node3);
|
||||
|
||||
BinaryTreeModel node4 = new BinaryTreeModel("node4");
|
||||
node3.setLeft(node4);
|
||||
|
||||
BinaryTreeModel node5 = new BinaryTreeModel("node5");
|
||||
node4.setLeft(node5);
|
||||
|
||||
BinaryTreeModel node6 = new BinaryTreeModel("node6");
|
||||
node5.setLeft(node6);
|
||||
|
||||
BinaryTreeModel node7 = new BinaryTreeModel("node7");
|
||||
node6.setLeft(node7);
|
||||
|
||||
node7.setLeft(new BinaryTreeModel("node8"));
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
private BinaryTreeModel createRightUnbalancedTree() {
|
||||
|
||||
BinaryTreeModel root = new BinaryTreeModel("root");
|
||||
|
||||
BinaryTreeModel node2 = new BinaryTreeModel("node2");
|
||||
root.setLeft(new BinaryTreeModel("node1"));
|
||||
root.setRight(node2);
|
||||
|
||||
BinaryTreeModel node3 = new BinaryTreeModel("node3");
|
||||
node2.setRight(node3);
|
||||
|
||||
BinaryTreeModel node4 = new BinaryTreeModel("node4");
|
||||
node3.setRight(node4);
|
||||
|
||||
BinaryTreeModel node5 = new BinaryTreeModel("node5");
|
||||
node4.setRight(node5);
|
||||
|
||||
BinaryTreeModel node6 = new BinaryTreeModel("node6");
|
||||
node5.setRight(node6);
|
||||
|
||||
BinaryTreeModel node7 = new BinaryTreeModel("node7");
|
||||
node6.setRight(node7);
|
||||
|
||||
node7.setRight(new BinaryTreeModel("node8"));
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenBinaryTreeModelBalanced_whenPrintWithBinaryTreePrinter_thenProduceCorrectOutput() {
|
||||
|
||||
StringBuilder expected = new StringBuilder();
|
||||
expected.append("root").append("\n");
|
||||
expected.append("├──node1").append("\n");
|
||||
expected.append("│ ├──node3").append("\n");
|
||||
expected.append("│ │ └──node7").append("\n");
|
||||
expected.append("│ │ ├──node8").append("\n");
|
||||
expected.append("│ │ └──node9").append("\n");
|
||||
expected.append("│ └──node4").append("\n");
|
||||
expected.append("└──node2").append("\n");
|
||||
expected.append(" ├──node5").append("\n");
|
||||
expected.append(" └──node6");
|
||||
|
||||
new BinaryTreePrinter(balanced).print(System.out);
|
||||
|
||||
assertEquals(expected.toString(), output.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenBinaryTreeModelLeftUnbalanced_whenPrintWithBinaryTreePrinter_thenProduceCorrectOutput() {
|
||||
|
||||
StringBuilder expected = new StringBuilder();
|
||||
expected.append("root").append("\n");
|
||||
expected.append("├──node1").append("\n");
|
||||
expected.append("│ └──node3").append("\n");
|
||||
expected.append("│ └──node4").append("\n");
|
||||
expected.append("│ └──node5").append("\n");
|
||||
expected.append("│ └──node6").append("\n");
|
||||
expected.append("│ └──node7").append("\n");
|
||||
expected.append("│ └──node8").append("\n");
|
||||
expected.append("└──node2");
|
||||
|
||||
new BinaryTreePrinter(leftSkewed).print(System.out);
|
||||
|
||||
assertEquals(expected.toString(), output.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void givenBinaryTreeModelRightUnbalanced_whenPrintWithBinaryTreePrinter_thenProduceCorrectOutput() {
|
||||
|
||||
StringBuilder expected = new StringBuilder();
|
||||
expected.append("root").append("\n");
|
||||
expected.append("├──node1").append("\n");
|
||||
expected.append("└──node2").append("\n");
|
||||
expected.append(" └──node3").append("\n");
|
||||
expected.append(" └──node4").append("\n");
|
||||
expected.append(" └──node5").append("\n");
|
||||
expected.append(" └──node6").append("\n");
|
||||
expected.append(" └──node7").append("\n");
|
||||
expected.append(" └──node8");
|
||||
|
||||
new BinaryTreePrinter(rightSkewed).print(System.out);
|
||||
|
||||
assertEquals(expected.toString(), output.toString());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.entities;
|
||||
package com.baeldung.gson.entities;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.entities;
|
||||
package com.baeldung.gson.entities;
|
||||
|
||||
public abstract class Animal {
|
||||
public String type = "Animal";
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.entities;
|
||||
package com.baeldung.gson.entities;
|
||||
|
||||
public class Cow extends Animal {
|
||||
private String breed;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.entities;
|
||||
package com.baeldung.gson.entities;
|
||||
|
||||
public class Dog extends Animal {
|
||||
private String petName;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.entities;
|
||||
package com.baeldung.gson.entities;
|
||||
|
||||
public class Employee {
|
||||
private int id;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.entities;
|
||||
package com.baeldung.gson.entities;
|
||||
|
||||
import java.util.List;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.entities;
|
||||
package com.baeldung.gson.entities;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.entities;
|
||||
package com.baeldung.gson.entities;
|
||||
|
||||
import java.util.Objects;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.entities;
|
||||
package com.baeldung.gson.entities;
|
||||
|
||||
public class User {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.entities;
|
||||
package com.baeldung.gson.entities;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.primitives.models;
|
||||
package com.baeldung.gson.primitives.models;
|
||||
|
||||
public class BooleanExample {
|
||||
public boolean value;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.primitives.models;
|
||||
package com.baeldung.gson.primitives.models;
|
||||
|
||||
public class ByteExample {
|
||||
public byte value = (byte) 1;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.primitives.models;
|
||||
package com.baeldung.gson.primitives.models;
|
||||
|
||||
public class CharExample {
|
||||
public char value;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.primitives.models;
|
||||
package com.baeldung.gson.primitives.models;
|
||||
|
||||
public class DoubleExample {
|
||||
public double value;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.primitives.models;
|
||||
package com.baeldung.gson.primitives.models;
|
||||
|
||||
public class FloatExample {
|
||||
public float value;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.primitives.models;
|
||||
package com.baeldung.gson.primitives.models;
|
||||
|
||||
public class InfinityValuesExample {
|
||||
public float negativeInfinity;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.primitives.models;
|
||||
package com.baeldung.gson.primitives.models;
|
||||
|
||||
public class LongExample {
|
||||
public long value = 1;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.primitives.models;
|
||||
package com.baeldung.gson.primitives.models;
|
||||
|
||||
public class PrimitiveBundle {
|
||||
public byte byteValue;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.primitives.models;
|
||||
package com.baeldung.gson.primitives.models;
|
||||
|
||||
public class PrimitiveBundleInitialized {
|
||||
// @formatter:off
|
|
@ -1,11 +1,11 @@
|
|||
package org.baeldung.gson.serialization;
|
||||
package com.baeldung.gson.serialization;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.baeldung.gson.entities.ActorGson;
|
||||
import com.baeldung.gson.entities.ActorGson;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonDeserializationContext;
|
|
@ -1,10 +1,10 @@
|
|||
package org.baeldung.gson.serialization;
|
||||
package com.baeldung.gson.serialization;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
import org.baeldung.gson.entities.ActorGson;
|
||||
import com.baeldung.gson.entities.ActorGson;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.text.SimpleDateFormat;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.serialization;
|
||||
package com.baeldung.gson.serialization;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
|
@ -8,7 +8,7 @@ import com.google.gson.JsonObject;
|
|||
import java.lang.reflect.Type;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.baeldung.gson.entities.Animal;
|
||||
import com.baeldung.gson.entities.Animal;
|
||||
|
||||
public class AnimalDeserializer implements JsonDeserializer<Animal> {
|
||||
private String animalTypeElementName;
|
|
@ -1,12 +1,11 @@
|
|||
package org.baeldung.gson.serialization;
|
||||
package com.baeldung.gson.serialization;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.baeldung.gson.entities.Employee;
|
||||
import com.baeldung.gson.entities.Employee;
|
||||
|
||||
import com.google.gson.*;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.serialization;
|
||||
package com.baeldung.gson.serialization;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.text.ParseException;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.serializationwithexclusions;
|
||||
package com.baeldung.gson.serializationwithexclusions;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.serializationwithexclusions;
|
||||
package com.baeldung.gson.serializationwithexclusions;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.serializationwithexclusions;
|
||||
package com.baeldung.gson.serializationwithexclusions;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.serializationwithexclusions;
|
||||
package com.baeldung.gson.serializationwithexclusions;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.serializationwithexclusions;
|
||||
package com.baeldung.gson.serializationwithexclusions;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.serializationwithexclusions;
|
||||
package com.baeldung.gson.serializationwithexclusions;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.serializationwithexclusions;
|
||||
package com.baeldung.gson.serializationwithexclusions;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.serializationwithexclusions;
|
||||
package com.baeldung.gson.serializationwithexclusions;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.serializationwithexclusions;
|
||||
package com.baeldung.gson.serializationwithexclusions;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
|
@ -1,8 +1,9 @@
|
|||
package org.baeldung.gson.advance;
|
||||
package com.baeldung.gson.advance;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import com.baeldung.gson.entities.Dog;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
@ -10,11 +11,10 @@ import java.lang.reflect.Type;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.baeldung.gson.entities.Animal;
|
||||
import org.baeldung.gson.entities.Cow;
|
||||
import org.baeldung.gson.entities.Dog;
|
||||
import org.baeldung.gson.entities.MyClass;
|
||||
import org.baeldung.gson.serialization.AnimalDeserializer;
|
||||
import com.baeldung.gson.entities.Animal;
|
||||
import com.baeldung.gson.entities.Cow;
|
||||
import com.baeldung.gson.entities.MyClass;
|
||||
import com.baeldung.gson.serialization.AnimalDeserializer;
|
||||
import org.junit.Test;
|
||||
|
||||
public class GsonAdvanceUnitTest {
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.advance;
|
||||
package com.baeldung.gson.advance;
|
||||
|
||||
/*
|
||||
* Copyright (C) 2011 Google Inc.
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.conversion;
|
||||
package com.baeldung.gson.conversion;
|
||||
|
||||
import com.google.gson.*;
|
||||
import org.junit.Assert;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.deserialization;
|
||||
package com.baeldung.gson.deserialization;
|
||||
|
||||
public class Foo {
|
||||
public int intValue;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.deserialization;
|
||||
package com.baeldung.gson.deserialization;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.deserialization;
|
||||
package com.baeldung.gson.deserialization;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.deserialization;
|
||||
package com.baeldung.gson.deserialization;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.deserialization;
|
||||
package com.baeldung.gson.deserialization;
|
||||
|
||||
public class FooWithInner {
|
||||
public int intValue;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.deserialization;
|
||||
package com.baeldung.gson.deserialization;
|
||||
|
||||
public class GenericFoo<T> {
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
package org.baeldung.gson.deserialization;
|
||||
package com.baeldung.gson.deserialization;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import org.baeldung.gson.entities.Weather;
|
||||
import com.baeldung.gson.entities.Weather;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.google.gson.Gson;
|
|
@ -1,10 +1,10 @@
|
|||
package org.baeldung.gson.deserialization;
|
||||
package com.baeldung.gson.deserialization;
|
||||
|
||||
import java.text.ParseException;
|
||||
|
||||
import org.baeldung.gson.entities.ActorGson;
|
||||
import org.baeldung.gson.entities.Movie;
|
||||
import org.baeldung.gson.serialization.ActorGsonDeserializer;
|
||||
import com.baeldung.gson.entities.Movie;
|
||||
import com.baeldung.gson.serialization.ActorGsonDeserializer;
|
||||
import com.baeldung.gson.entities.ActorGson;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.deserialization;
|
||||
package com.baeldung.gson.deserialization;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.text.ParseException;
|
||||
|
@ -6,9 +6,9 @@ import java.util.Date;
|
|||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.baeldung.gson.entities.Employee;
|
||||
import org.baeldung.gson.serialization.MapDeserializer;
|
||||
import org.baeldung.gson.serialization.StringDateMapDeserializer;
|
||||
import com.baeldung.gson.entities.Employee;
|
||||
import com.baeldung.gson.serialization.MapDeserializer;
|
||||
import com.baeldung.gson.serialization.StringDateMapDeserializer;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.slf4j.Logger;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.deserialization.test;
|
||||
package com.baeldung.gson.deserialization.test;
|
||||
|
||||
import static org.hamcrest.Matchers.hasItem;
|
||||
import static org.hamcrest.Matchers.instanceOf;
|
||||
|
@ -10,11 +10,11 @@ import java.lang.reflect.Type;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.baeldung.gson.deserialization.Foo;
|
||||
import org.baeldung.gson.deserialization.FooDeserializerFromJsonWithDifferentFields;
|
||||
import org.baeldung.gson.deserialization.FooInstanceCreator;
|
||||
import org.baeldung.gson.deserialization.FooWithInner;
|
||||
import org.baeldung.gson.deserialization.GenericFoo;
|
||||
import com.baeldung.gson.deserialization.Foo;
|
||||
import com.baeldung.gson.deserialization.FooDeserializerFromJsonWithDifferentFields;
|
||||
import com.baeldung.gson.deserialization.FooInstanceCreator;
|
||||
import com.baeldung.gson.deserialization.FooWithInner;
|
||||
import com.baeldung.gson.deserialization.GenericFoo;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.google.common.collect.Lists;
|
|
@ -1,7 +1,7 @@
|
|||
package org.baeldung.gson.primitives;
|
||||
package com.baeldung.gson.primitives;
|
||||
|
||||
import com.baeldung.gson.primitives.models.*;
|
||||
import com.google.gson.*;
|
||||
import org.baeldung.gson.primitives.models.*;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.lang.reflect.Type;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.serialization;
|
||||
package com.baeldung.gson.serialization;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
package org.baeldung.gson.serialization;
|
||||
package com.baeldung.gson.serialization;
|
||||
|
||||
import com.baeldung.gson.entities.Movie;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonParser;
|
||||
import org.baeldung.gson.entities.ActorGson;
|
||||
import org.baeldung.gson.entities.Movie;
|
||||
import org.baeldung.gson.entities.MovieWithNullValue;
|
||||
import com.baeldung.gson.entities.ActorGson;
|
||||
import com.baeldung.gson.entities.MovieWithNullValue;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.serialization;
|
||||
package com.baeldung.gson.serialization;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.serialization;
|
||||
package com.baeldung.gson.serialization;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.serialization;
|
||||
package com.baeldung.gson.serialization;
|
||||
|
||||
public class SourceClass {
|
||||
private int intValue;
|
|
@ -1,18 +1,16 @@
|
|||
package org.baeldung.gson.serialization.test;
|
||||
package com.baeldung.gson.serialization.test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
|
||||
import org.baeldung.gson.serialization.DifferentNameSerializer;
|
||||
import org.baeldung.gson.serialization.IgnoringFieldsNotMatchingCriteriaSerializer;
|
||||
import org.baeldung.gson.serialization.IgnoringFieldsSerializer;
|
||||
import org.baeldung.gson.serialization.SourceClass;
|
||||
import com.baeldung.gson.serialization.DifferentNameSerializer;
|
||||
import com.baeldung.gson.serialization.IgnoringFieldsNotMatchingCriteriaSerializer;
|
||||
import com.baeldung.gson.serialization.IgnoringFieldsSerializer;
|
||||
import com.baeldung.gson.serialization.SourceClass;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Test;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.serialization.test;
|
||||
package com.baeldung.gson.serialization.test;
|
||||
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
@ -6,7 +6,7 @@ import java.io.Writer;
|
|||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import org.baeldung.gson.entities.User;
|
||||
import com.baeldung.gson.entities.User;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.gson.serializationwithexclusions;
|
||||
package com.baeldung.gson.serializationwithexclusions;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.guava;
|
||||
package com.baeldung.guava;
|
||||
|
||||
public class CustomEvent {
|
||||
private String action;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.guava;
|
||||
package com.baeldung.guava;
|
||||
|
||||
import com.google.common.eventbus.DeadEvent;
|
||||
import com.google.common.eventbus.Subscribe;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.guava.memoizer;
|
||||
package com.baeldung.guava.memoizer;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.Random;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.guava.memoizer;
|
||||
package com.baeldung.guava.memoizer;
|
||||
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
|
@ -1,11 +1,10 @@
|
|||
package org.baeldung.guava.memoizer;
|
||||
package com.baeldung.guava.memoizer;
|
||||
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class FibonacciSequence {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.guava;
|
||||
package com.baeldung.guava;
|
||||
|
||||
|
||||
import com.google.common.hash.BloomFilter;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.guava;
|
||||
package com.baeldung.guava;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.guava;
|
||||
package com.baeldung.guava;
|
||||
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.guava;
|
||||
package com.baeldung.guava;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.guava;
|
||||
package com.baeldung.guava;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.guava;
|
||||
package com.baeldung.guava;
|
||||
|
||||
import com.google.common.eventbus.EventBus;
|
||||
import org.junit.After;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.guava;
|
||||
package com.baeldung.guava;
|
||||
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.guava;
|
||||
package com.baeldung.guava;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.guava;
|
||||
package com.baeldung.guava;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.guava;
|
||||
package com.baeldung.guava;
|
||||
|
||||
import static org.hamcrest.core.IsEqual.equalTo;
|
||||
import static org.junit.Assert.*;
|
|
@ -1,9 +1,9 @@
|
|||
package org.baeldung.guava;
|
||||
package com.baeldung.guava;
|
||||
|
||||
import com.google.common.base.Suppliers;
|
||||
import org.baeldung.guava.memoizer.CostlySupplier;
|
||||
import org.baeldung.guava.memoizer.Factorial;
|
||||
import org.baeldung.guava.memoizer.FibonacciSequence;
|
||||
import com.baeldung.guava.memoizer.CostlySupplier;
|
||||
import com.baeldung.guava.memoizer.Factorial;
|
||||
import com.baeldung.guava.memoizer.FibonacciSequence;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.math.BigInteger;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.guava;
|
||||
package com.baeldung.guava;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
import java.util.Arrays;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.guava;
|
||||
package com.baeldung.guava;
|
||||
|
||||
|
||||
import com.google.common.collect.Lists;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.guava;
|
||||
package com.baeldung.guava;
|
||||
|
||||
|
||||
import com.google.common.util.concurrent.RateLimiter;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.httpclient;
|
||||
package com.baeldung.httpclient;
|
||||
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.Assert.assertThat;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.httpclient;
|
||||
package com.baeldung.httpclient;
|
||||
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpStatus;
|
||||
|
@ -38,7 +38,7 @@ public class HttpClientMultipartLiveTest {
|
|||
private static final String TEXTFILENAME = "temp.txt";
|
||||
private static final String IMAGEFILENAME = "image.jpg";
|
||||
private static final String ZIPFILENAME = "zipFile.zip";
|
||||
private static final Logger LOGGER = Logger.getLogger("org.baeldung.httpclient.HttpClientMultipartLiveTest");
|
||||
private static final Logger LOGGER = Logger.getLogger("com.baeldung.httpclient.HttpClientMultipartLiveTest");
|
||||
private CloseableHttpClient client;
|
||||
private HttpPost post;
|
||||
private BufferedReader rd;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.httpclient;
|
||||
package com.baeldung.httpclient;
|
||||
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.httpclient;
|
||||
package com.baeldung.httpclient;
|
||||
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.httpclient.advancedconfig;
|
||||
package com.baeldung.httpclient.advancedconfig;
|
||||
|
||||
|
||||
import com.github.tomakehurst.wiremock.junit.WireMockRule;
|
|
@ -1,5 +1,6 @@
|
|||
package org.baeldung.httpclient.base;
|
||||
package com.baeldung.httpclient.base;
|
||||
|
||||
import com.baeldung.httpclient.ResponseUtil;
|
||||
import org.apache.http.auth.AuthenticationException;
|
||||
import org.apache.http.auth.UsernamePasswordCredentials;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
|
@ -8,7 +9,6 @@ import org.apache.http.entity.StringEntity;
|
|||
import org.apache.http.impl.auth.BasicScheme;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.baeldung.httpclient.ResponseUtil;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
|
@ -1,5 +1,6 @@
|
|||
package org.baeldung.httpclient.base;
|
||||
package com.baeldung.httpclient.base;
|
||||
|
||||
import com.baeldung.httpclient.ResponseUtil;
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.HttpHeaders;
|
||||
|
@ -11,7 +12,6 @@ import org.apache.http.impl.client.CloseableHttpClient;
|
|||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.impl.conn.BasicHttpClientConnectionManager;
|
||||
import org.baeldung.httpclient.ResponseUtil;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
|
@ -1,5 +1,6 @@
|
|||
package org.baeldung.httpclient.base;
|
||||
package com.baeldung.httpclient.base;
|
||||
|
||||
import com.baeldung.httpclient.ResponseUtil;
|
||||
import org.apache.http.auth.AuthScope;
|
||||
import org.apache.http.auth.UsernamePasswordCredentials;
|
||||
import org.apache.http.client.CredentialsProvider;
|
||||
|
@ -8,7 +9,6 @@ import org.apache.http.client.methods.HttpGet;
|
|||
import org.apache.http.impl.client.BasicCredentialsProvider;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.baeldung.httpclient.ResponseUtil;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.IOException;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.httpclient.conn;
|
||||
package com.baeldung.httpclient.conn;
|
||||
|
||||
import org.apache.http.HeaderElement;
|
||||
import org.apache.http.HeaderElementIterator;
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue