Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
9ed06aae0e
|
@ -21,3 +21,5 @@
|
|||
# Maven
|
||||
log/
|
||||
target/
|
||||
|
||||
spring-openid/src/main/resources/application.properties
|
||||
|
|
22
.project
22
.project
|
@ -1,11 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>parent</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
</natures>
|
||||
<name>parent-modules</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.baeldung</groupId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>apache-fop</artifactId>
|
||||
<version>0.1-SNAPSHOT</version>
|
||||
|
||||
|
@ -142,16 +142,12 @@
|
|||
</build>
|
||||
|
||||
<properties>
|
||||
<!-- Spring -->
|
||||
<org.springframework.version>4.1.5.RELEASE</org.springframework.version>
|
||||
<org.springframework.security.version>3.2.5.RELEASE</org.springframework.security.version>
|
||||
|
||||
<!-- persistence -->
|
||||
<hibernate.version>4.3.8.Final</hibernate.version>
|
||||
<mysql-connector-java.version>5.1.34</mysql-connector-java.version>
|
||||
<hibernate.version>4.3.11.Final</hibernate.version>
|
||||
<mysql-connector-java.version>5.1.38</mysql-connector-java.version>
|
||||
|
||||
<!-- marshalling -->
|
||||
<jackson.version>2.5.5</jackson.version>
|
||||
<jackson.version>2.7.2</jackson.version>
|
||||
|
||||
<!-- logging -->
|
||||
<org.slf4j.version>1.7.9</org.slf4j.version>
|
||||
|
@ -161,7 +157,7 @@
|
|||
<hibernate-validator.version>5.1.3.Final</hibernate-validator.version>
|
||||
|
||||
<!-- util -->
|
||||
<guava.version>17.0</guava.version> <!-- upgrade to 18.0 -->
|
||||
<guava.version>19.0</guava.version>
|
||||
<commons-lang3.version>3.3.2</commons-lang3.version>
|
||||
|
||||
<!-- testing -->
|
||||
|
@ -172,14 +168,14 @@
|
|||
<httpcore.version>4.4</httpcore.version>
|
||||
<httpclient.version>4.4</httpclient.version>
|
||||
|
||||
<rest-assured.version>2.4.0</rest-assured.version>
|
||||
<rest-assured.version>2.9.0</rest-assured.version>
|
||||
|
||||
<!-- maven plugins -->
|
||||
<maven-compiler-plugin.version>3.2</maven-compiler-plugin.version>
|
||||
<maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version>
|
||||
<maven-war-plugin.version>2.6</maven-war-plugin.version>
|
||||
<maven-surefire-plugin.version>2.18.1</maven-surefire-plugin.version>
|
||||
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
|
||||
<maven-resources-plugin.version>2.7</maven-resources-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.12</cargo-maven2-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.18</cargo-maven2-plugin.version>
|
||||
|
||||
</properties>
|
||||
|
||||
|
|
|
@ -8,3 +8,4 @@
|
|||
- [Java – Try with Resources](http://www.baeldung.com/java-try-with-resources)
|
||||
- [Lambda Expressions and Functional Interfaces: Tips and Best Practices](http://www.baeldung.com/java-8-lambda-expressions-tips)
|
||||
- [The Double Colon Operator in Java 8](http://www.baeldung.com/java-8-double-colon-operator)
|
||||
- [A Guide to the Java ExecutorService](http://www.baeldung.com/java-executor-service-tutorial)
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.baeldung</groupId>
|
||||
<artifactId>spring-rest</artifactId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>core-java8</artifactId>
|
||||
<version>0.1-SNAPSHOT</version>
|
||||
|
||||
<name>spring-rest</name>
|
||||
<name>core-java8</name>
|
||||
|
||||
<dependencies>
|
||||
|
||||
|
@ -114,9 +114,9 @@
|
|||
<mockito.version>1.10.19</mockito.version>
|
||||
|
||||
<!-- maven plugins -->
|
||||
<maven-compiler-plugin.version>3.3</maven-compiler-plugin.version>
|
||||
<maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version>
|
||||
<maven-war-plugin.version>2.6</maven-war-plugin.version>
|
||||
<maven-surefire-plugin.version>2.18.1</maven-surefire-plugin.version>
|
||||
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
|
||||
<maven-resources-plugin.version>2.7</maven-resources-plugin.version>
|
||||
|
||||
</properties>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.baeldung</groupId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>core-java</artifactId>
|
||||
<version>0.1-SNAPSHOT</version>
|
||||
<version>0.1.0-SNAPSHOT</version>
|
||||
|
||||
<name>core-java</name>
|
||||
|
||||
|
@ -143,16 +143,12 @@
|
|||
</build>
|
||||
|
||||
<properties>
|
||||
<!-- Spring -->
|
||||
<org.springframework.version>4.1.5.RELEASE</org.springframework.version>
|
||||
<org.springframework.security.version>3.2.5.RELEASE</org.springframework.security.version>
|
||||
|
||||
<!-- persistence -->
|
||||
<hibernate.version>4.3.10.Final</hibernate.version>
|
||||
<mysql-connector-java.version>5.1.35</mysql-connector-java.version>
|
||||
<hibernate.version>4.3.11.Final</hibernate.version>
|
||||
<mysql-connector-java.version>5.1.38</mysql-connector-java.version>
|
||||
|
||||
<!-- marshalling -->
|
||||
<jackson.version>2.5.5</jackson.version>
|
||||
<jackson.version>2.7.2</jackson.version>
|
||||
|
||||
<!-- logging -->
|
||||
<org.slf4j.version>1.7.13</org.slf4j.version>
|
||||
|
@ -173,14 +169,14 @@
|
|||
<httpcore.version>4.4.1</httpcore.version>
|
||||
<httpclient.version>4.5</httpclient.version>
|
||||
|
||||
<rest-assured.version>2.4.1</rest-assured.version>
|
||||
<rest-assured.version>2.9.0</rest-assured.version>
|
||||
|
||||
<!-- maven plugins -->
|
||||
<maven-compiler-plugin.version>3.3</maven-compiler-plugin.version>
|
||||
<maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version>
|
||||
<maven-war-plugin.version>2.6</maven-war-plugin.version>
|
||||
<maven-surefire-plugin.version>2.18.1</maven-surefire-plugin.version>
|
||||
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
|
||||
<maven-resources-plugin.version>2.7</maven-resources-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.14</cargo-maven2-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.18</cargo-maven2-plugin.version>
|
||||
|
||||
</properties>
|
||||
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd" >
|
||||
|
||||
</beans>
|
|
@ -1,41 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
|
||||
xsi:schemaLocation="
|
||||
http://java.sun.com/xml/ns/javaee
|
||||
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"
|
||||
>
|
||||
|
||||
<display-name>Spring MVC Application</display-name>
|
||||
|
||||
<!-- Spring root -->
|
||||
<context-param>
|
||||
<param-name>contextClass</param-name>
|
||||
<param-value>
|
||||
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
|
||||
</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>contextConfigLocation</param-name>
|
||||
<param-value>org.baeldung.config</param-value>
|
||||
</context-param>
|
||||
|
||||
<listener>
|
||||
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
|
||||
</listener>
|
||||
|
||||
<!-- Spring child -->
|
||||
<servlet>
|
||||
<servlet-name>api</servlet-name>
|
||||
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>api</servlet-name>
|
||||
<url-pattern>/</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<welcome-file-list>
|
||||
<welcome-file/>
|
||||
</welcome-file-list>
|
||||
|
||||
</web-app>
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry including="**/*.java" kind="src" path="src/main/java"/>
|
||||
<classpathentry excluding="**/*.java" kind="src" path="src/main/resources"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
|
||||
<classpathentry kind="var" path="M2_REPO/com/google/code/gson/gson/2.5/gson-2.5.jar"/>
|
||||
<classpathentry kind="var" path="M2_REPO/com/fasterxml/jackson/core/jackson-databind/2.7.1-1/jackson-databind-2.7.1-1.jar"/>
|
||||
<classpathentry kind="var" path="M2_REPO/com/fasterxml/jackson/core/jackson-annotations/2.7.0/jackson-annotations-2.7.0.jar"/>
|
||||
<classpathentry kind="var" path="M2_REPO/com/fasterxml/jackson/core/jackson-core/2.7.1/jackson-core-2.7.1.jar"/>
|
||||
<classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
|
||||
<classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.17/log4j-1.2.17.jar"/>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>gson-jackson-performance</name>
|
||||
<comment>NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse.</comment>
|
||||
<projects/>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,3 @@
|
|||
## Performance of Gson and Jackson
|
||||
|
||||
Standalone java programs to measure the performance of both JSON APIs based on file size and object graph complexity.
|
|
@ -0,0 +1,72 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>gson-jackson-performance</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>gson-jackson-performance</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<finalName>gson-jackson-performance</finalName>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
<plugins>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.5</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
<version>2.7.1-1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
<version>1.2.17</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,63 @@
|
|||
package com.baeldung.data.complex;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.baeldung.data.utility.Utility;
|
||||
import com.baeldung.pojo.complex.AddressDetails;
|
||||
import com.baeldung.pojo.complex.ContactDetails;
|
||||
import com.baeldung.pojo.complex.CustomerAddressDetails;
|
||||
import com.baeldung.pojo.complex.CustomerPortfolioComplex;
|
||||
|
||||
/**
|
||||
*
|
||||
* This class is responsible for generating data for complex type object
|
||||
*/
|
||||
|
||||
public class ComplexDataGeneration {
|
||||
|
||||
public static CustomerPortfolioComplex generateData() {
|
||||
List<CustomerAddressDetails> customerAddressDetailsList = new ArrayList<CustomerAddressDetails>();
|
||||
for (int i = 0; i < 600000; i++) {
|
||||
CustomerAddressDetails customerAddressDetails = new CustomerAddressDetails();
|
||||
customerAddressDetails.setAge(20);
|
||||
customerAddressDetails.setFirstName(Utility.generateRandomName());
|
||||
customerAddressDetails.setLastName(Utility.generateRandomName());
|
||||
|
||||
List<AddressDetails> addressDetailsList = new ArrayList<AddressDetails>();
|
||||
customerAddressDetails.setAddressDetails(addressDetailsList);
|
||||
|
||||
for (int j = 0; j < 2; j++) {
|
||||
AddressDetails addressDetails = new AddressDetails();
|
||||
addressDetails.setZipcode(Utility.generateRandomZip());
|
||||
addressDetails.setAddress(Utility.generateRandomAddress());
|
||||
|
||||
List<ContactDetails> contactDetailsList = new ArrayList<ContactDetails>();
|
||||
addressDetails.setContactDetails(contactDetailsList);
|
||||
|
||||
for (int k = 0; k < 2; k++) {
|
||||
ContactDetails contactDetails = new ContactDetails();
|
||||
contactDetails.setLandline(Utility.generateRandomPhone());
|
||||
contactDetails.setMobile(Utility.generateRandomPhone());
|
||||
contactDetailsList.add(contactDetails);
|
||||
contactDetails = null;
|
||||
}
|
||||
|
||||
addressDetailsList.add(addressDetails);
|
||||
addressDetails = null;
|
||||
contactDetailsList = null;
|
||||
}
|
||||
customerAddressDetailsList.add(customerAddressDetails);
|
||||
customerAddressDetails = null;
|
||||
|
||||
if (i % 6000 == 0) {
|
||||
Runtime.getRuntime().gc();
|
||||
}
|
||||
}
|
||||
|
||||
CustomerPortfolioComplex customerPortfolioComplex = new CustomerPortfolioComplex();
|
||||
customerPortfolioComplex.setCustomerAddressDetailsList(customerAddressDetailsList);
|
||||
customerAddressDetailsList = null;
|
||||
return customerPortfolioComplex;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
package com.baeldung.data.complex;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import com.baeldung.data.utility.Utility;
|
||||
import com.baeldung.pojo.complex.CustomerPortfolioComplex;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
/**
|
||||
*
|
||||
* This class is responsible for performing functions for Complex type
|
||||
* GSON like
|
||||
* Java to Json
|
||||
* Json to Map
|
||||
* Json to Java Object
|
||||
*/
|
||||
|
||||
public class ComplexDataGson {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(ComplexDataGson.class);
|
||||
|
||||
static Gson gson = new Gson();
|
||||
|
||||
static long generateJsonAvgTime = 0L;
|
||||
|
||||
static long parseJsonToMapAvgTime = 0L;
|
||||
|
||||
static long parseJsonToActualObjectAvgTime = 0L;
|
||||
|
||||
public static void main(String[] args) {
|
||||
CustomerPortfolioComplex customerPortfolioComplex = ComplexDataGeneration.generateData();
|
||||
int j = 50;
|
||||
for (int i = 0; i < j; i++) {
|
||||
logger.info("-------Round " + (i + 1));
|
||||
String jsonStr = generateJson(customerPortfolioComplex);
|
||||
logger.info("Size of Complex content Jackson :: " + Utility.bytesIntoMB(jsonStr.getBytes().length));
|
||||
logger.info("--------------------------------------------------------------------------");
|
||||
parseJsonToMap(jsonStr);
|
||||
parseJsonToActualObject(jsonStr);
|
||||
jsonStr = null;
|
||||
}
|
||||
|
||||
generateJsonAvgTime = generateJsonAvgTime / j;
|
||||
parseJsonToMapAvgTime = parseJsonToMapAvgTime / j;
|
||||
parseJsonToActualObjectAvgTime = parseJsonToActualObjectAvgTime / j;
|
||||
|
||||
logger.info("--------------------------------------------------------------------------");
|
||||
logger.info("Average Time to Generate JSON : " + generateJsonAvgTime);
|
||||
logger.info("Average Time to Parse JSON To Map : " + parseJsonToMapAvgTime);
|
||||
logger.info("Average Time to Parse JSON To Actual Object : " + parseJsonToActualObjectAvgTime);
|
||||
logger.info("--------------------------------------------------------------------------");
|
||||
}
|
||||
|
||||
private static String generateJson(CustomerPortfolioComplex customerPortfolioComplex) {
|
||||
Runtime.getRuntime().gc();
|
||||
long startParsTime = System.nanoTime();
|
||||
String json = gson.toJson(customerPortfolioComplex);
|
||||
long endParsTime = System.nanoTime();
|
||||
long elapsedTime = endParsTime - startParsTime;
|
||||
generateJsonAvgTime = generateJsonAvgTime + elapsedTime;
|
||||
logger.info("Json Generation Time(ms):: " + elapsedTime);
|
||||
return json;
|
||||
}
|
||||
|
||||
private static void parseJsonToMap(String jsonStr) {
|
||||
long startParsTime = System.nanoTime();
|
||||
Map parsedMap = gson.fromJson(jsonStr , Map.class);
|
||||
long endParsTime = System.nanoTime();
|
||||
long elapsedTime = endParsTime - startParsTime;
|
||||
parseJsonToMapAvgTime = parseJsonToMapAvgTime + elapsedTime;
|
||||
logger.info("Generating Map from json Time(ms):: " + elapsedTime);
|
||||
logger.info("--------------------------------------------------------------------------");
|
||||
parsedMap = null;
|
||||
Runtime.getRuntime().gc();
|
||||
}
|
||||
|
||||
private static void parseJsonToActualObject(String jsonStr) {
|
||||
long startParsTime = System.nanoTime();
|
||||
CustomerPortfolioComplex customerPortfolioComplex = gson.fromJson(jsonStr , CustomerPortfolioComplex.class);
|
||||
long endParsTime = System.nanoTime();
|
||||
long elapsedTime = endParsTime - startParsTime;
|
||||
parseJsonToActualObjectAvgTime = parseJsonToActualObjectAvgTime + elapsedTime;
|
||||
logger.info("Generating Actual Object from json Time(ms):: " + elapsedTime);
|
||||
logger.info("--------------------------------------------------------------------------");
|
||||
customerPortfolioComplex = null;
|
||||
Runtime.getRuntime().gc();
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
package com.baeldung.data.complex;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import com.baeldung.data.utility.Utility;
|
||||
import org.apache.log4j.Logger;
|
||||
import com.baeldung.pojo.complex.CustomerPortfolioComplex;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParseException;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
/**
|
||||
*
|
||||
* This class is responsible for performing functions for Complex type
|
||||
* Jackson like
|
||||
* Java to Json
|
||||
* Json to Map
|
||||
* Json to Java Object
|
||||
*/
|
||||
|
||||
public class ComplexDataJackson {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(ComplexDataJackson.class);
|
||||
|
||||
static ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
static long generateJsonAvgTime = 0L;
|
||||
|
||||
static long parseJsonToMapAvgTime = 0L;
|
||||
|
||||
static long parseJsonToActualObjectAvgTime = 0L;
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
CustomerPortfolioComplex customerPortfolioComplex = ComplexDataGeneration.generateData();
|
||||
int j = 50;
|
||||
for (int i = 0; i < j; i++) {
|
||||
logger.info("-------Round " + (i + 1));
|
||||
String jsonStr = generateJson(customerPortfolioComplex);
|
||||
logger.info("Size of Complex content Jackson :: " + Utility.bytesIntoMB(jsonStr.getBytes().length));
|
||||
logger.info("--------------------------------------------------------------------------");
|
||||
parseJsonToMap(jsonStr);
|
||||
parseJsonToActualObject(jsonStr);
|
||||
jsonStr = null;
|
||||
}
|
||||
|
||||
generateJsonAvgTime = generateJsonAvgTime / j;
|
||||
parseJsonToMapAvgTime = parseJsonToMapAvgTime / j;
|
||||
parseJsonToActualObjectAvgTime = parseJsonToActualObjectAvgTime / j;
|
||||
|
||||
logger.info("--------------------------------------------------------------------------");
|
||||
logger.info("Average Time to Generate JSON : " + generateJsonAvgTime);
|
||||
logger.info("Average Time to Parse JSON To Map : " + parseJsonToMapAvgTime);
|
||||
logger.info("Average Time to Parse JSON To Actual Object : " + parseJsonToActualObjectAvgTime);
|
||||
logger.info("--------------------------------------------------------------------------");
|
||||
}
|
||||
|
||||
private static String generateJson(CustomerPortfolioComplex customerPortfolioComplex)
|
||||
throws JsonProcessingException {
|
||||
Runtime.getRuntime().gc();
|
||||
long startParsTime = System.nanoTime();
|
||||
String json = mapper.writeValueAsString(customerPortfolioComplex);
|
||||
long endParsTime = System.nanoTime();
|
||||
long elapsedTime = endParsTime - startParsTime;
|
||||
generateJsonAvgTime = generateJsonAvgTime + elapsedTime;
|
||||
logger.info("Json Generation Time(ms):: " + elapsedTime);
|
||||
return json;
|
||||
}
|
||||
|
||||
private static void parseJsonToMap(String jsonStr) throws JsonParseException , JsonMappingException , IOException {
|
||||
long startParsTime = System.nanoTime();
|
||||
Map parsedMap = mapper.readValue(jsonStr , Map.class);
|
||||
long endParsTime = System.nanoTime();
|
||||
long elapsedTime = endParsTime - startParsTime;
|
||||
parseJsonToMapAvgTime = parseJsonToMapAvgTime + elapsedTime;
|
||||
logger.info("Generating Map from json Time(ms):: " + elapsedTime);
|
||||
parsedMap = null;
|
||||
Runtime.getRuntime().gc();
|
||||
|
||||
}
|
||||
|
||||
private static void parseJsonToActualObject(String jsonStr) throws JsonParseException , JsonMappingException ,
|
||||
IOException {
|
||||
long startParsTime = System.nanoTime();
|
||||
CustomerPortfolioComplex customerPortfolioComplex = mapper.readValue(jsonStr , CustomerPortfolioComplex.class);
|
||||
long endParsTime = System.nanoTime();
|
||||
long elapsedTime = endParsTime - startParsTime;
|
||||
parseJsonToActualObjectAvgTime = parseJsonToActualObjectAvgTime + elapsedTime;
|
||||
logger.info("Generating Actual Object from json Time(ms):: " + elapsedTime);
|
||||
customerPortfolioComplex = null;
|
||||
Runtime.getRuntime().gc();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package com.baeldung.data.simple;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.baeldung.data.utility.Utility;
|
||||
import com.baeldung.pojo.simple.Customer;
|
||||
import com.baeldung.pojo.simple.CustomerPortfolioSimple;
|
||||
|
||||
/**
|
||||
*
|
||||
* This class is responsible for generating data for simple type object
|
||||
*/
|
||||
|
||||
public class SimpleDataGeneration {
|
||||
|
||||
public static CustomerPortfolioSimple generateData() {
|
||||
List<Customer> customerList = new ArrayList<Customer>();
|
||||
for (int i = 0; i < 1; i++) {
|
||||
Customer customer = new Customer();
|
||||
customer.setAge(20);
|
||||
customer.setFirstName(Utility.generateRandomName());
|
||||
customer.setLastName(Utility.generateRandomName());
|
||||
|
||||
customerList.add(customer);
|
||||
customer = null;
|
||||
|
||||
}
|
||||
|
||||
CustomerPortfolioSimple customerPortfolioSimple = new CustomerPortfolioSimple();
|
||||
customerPortfolioSimple.setCustomerLists(customerList);
|
||||
customerList = null;
|
||||
return customerPortfolioSimple;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
package com.baeldung.data.simple;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import com.baeldung.data.utility.Utility;
|
||||
import com.baeldung.pojo.simple.CustomerPortfolioSimple;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
/**
|
||||
*
|
||||
* This class is responsible for performing functions for Simple type
|
||||
* GSON like
|
||||
* Java to Json
|
||||
* Json to Map
|
||||
* Json to Java Object
|
||||
*/
|
||||
|
||||
public class SimpleDataGson {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(SimpleDataGson.class);
|
||||
|
||||
static Gson gson = new Gson();
|
||||
|
||||
static long generateJsonAvgTime = 0L;
|
||||
|
||||
static long parseJsonToMapAvgTime = 0L;
|
||||
|
||||
static long parseJsonToActualObjectAvgTime = 0L;
|
||||
|
||||
public static void main(String[] args) {
|
||||
CustomerPortfolioSimple customerPortfolioSimple = SimpleDataGeneration.generateData();
|
||||
String jsonStr = null;
|
||||
int j = 5;
|
||||
for (int i = 0; i < j; i++) {
|
||||
logger.info("-------Round " + (i + 1));
|
||||
jsonStr = generateJson(customerPortfolioSimple);
|
||||
logger.info("Size of Simple content Gson :: " + Utility.bytesIntoMB(jsonStr.getBytes().length));
|
||||
logger.info("--------------------------------------------------------------------------");
|
||||
parseJsonToMap(jsonStr);
|
||||
parseJsonToActualObject(jsonStr);
|
||||
jsonStr = null;
|
||||
}
|
||||
generateJsonAvgTime = generateJsonAvgTime / j;
|
||||
parseJsonToMapAvgTime = parseJsonToMapAvgTime / j;
|
||||
parseJsonToActualObjectAvgTime = parseJsonToActualObjectAvgTime / j;
|
||||
|
||||
logger.info("--------------------------------------------------------------------------");
|
||||
logger.info("Average Time to Generate JSON : " + generateJsonAvgTime);
|
||||
logger.info("Average Time to Parse JSON To Map : " + parseJsonToMapAvgTime);
|
||||
logger.info("Average Time to Parse JSON To Actual Object : " + parseJsonToActualObjectAvgTime);
|
||||
logger.info("--------------------------------------------------------------------------");
|
||||
}
|
||||
|
||||
private static String generateJson(CustomerPortfolioSimple customerPortfolioSimple) {
|
||||
Runtime.getRuntime().gc();
|
||||
long startParsTime = System.nanoTime();
|
||||
String json = gson.toJson(customerPortfolioSimple);
|
||||
long endParsTime = System.nanoTime();
|
||||
long elapsedTime = endParsTime - startParsTime;
|
||||
generateJsonAvgTime = generateJsonAvgTime + elapsedTime;
|
||||
logger.info("Json Generation Time(ms):: " + elapsedTime);
|
||||
return json;
|
||||
}
|
||||
|
||||
private static void parseJsonToMap(String jsonStr) {
|
||||
long startParsTime = System.nanoTime();
|
||||
Map parsedMap = gson.fromJson(jsonStr , Map.class);
|
||||
long endParsTime = System.nanoTime();
|
||||
long elapsedTime = endParsTime - startParsTime;
|
||||
parseJsonToMapAvgTime = parseJsonToMapAvgTime + elapsedTime;
|
||||
logger.info("Generating Map from json Time(ms):: " + elapsedTime);
|
||||
logger.info("--------------------------------------------------------------------------");
|
||||
parsedMap = null;
|
||||
Runtime.getRuntime().gc();
|
||||
|
||||
}
|
||||
|
||||
private static void parseJsonToActualObject(String jsonStr) {
|
||||
long startParsTime = System.nanoTime();
|
||||
CustomerPortfolioSimple customerPortfolioSimple = gson.fromJson(jsonStr , CustomerPortfolioSimple.class);
|
||||
long endParsTime = System.nanoTime();
|
||||
long elapsedTime = endParsTime - startParsTime;
|
||||
parseJsonToActualObjectAvgTime = parseJsonToActualObjectAvgTime + elapsedTime;
|
||||
logger.info("Generating Actual Object from json Time(ms):: " + elapsedTime);
|
||||
logger.info("--------------------------------------------------------------------------");
|
||||
customerPortfolioSimple = null;
|
||||
Runtime.getRuntime().gc();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
package com.baeldung.data.simple;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import com.baeldung.data.utility.Utility;
|
||||
import org.apache.log4j.Logger;
|
||||
import com.baeldung.pojo.simple.CustomerPortfolioSimple;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParseException;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
/**
|
||||
*
|
||||
* This class is responsible for performing functions for Simple type
|
||||
* Jackson like
|
||||
* Java to Json
|
||||
* Json to Map
|
||||
* Json to Java Object
|
||||
*/
|
||||
|
||||
public class SimpleDataJackson {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(SimpleDataJackson.class);
|
||||
|
||||
static ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
static long generateJsonAvgTime = 0L;
|
||||
|
||||
static long parseJsonToMapAvgTime = 0L;
|
||||
|
||||
static long parseJsonToActualObjectAvgTime = 0L;
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
CustomerPortfolioSimple customerPortfolioSimple = SimpleDataGeneration.generateData();
|
||||
int j = 50;
|
||||
for (int i = 0; i < j; i++) {
|
||||
logger.info("-------Round " + (i + 1));
|
||||
String jsonStr = generateJson(customerPortfolioSimple);
|
||||
logger.info("Size of Simple content Jackson :: " + Utility.bytesIntoMB(jsonStr.getBytes().length));
|
||||
logger.info("--------------------------------------------------------------------------");
|
||||
|
||||
parseJsonToMap(jsonStr);
|
||||
parseJsonToActualObject(jsonStr);
|
||||
jsonStr = null;
|
||||
}
|
||||
|
||||
generateJsonAvgTime = generateJsonAvgTime / j;
|
||||
parseJsonToMapAvgTime = parseJsonToMapAvgTime / j;
|
||||
parseJsonToActualObjectAvgTime = parseJsonToActualObjectAvgTime / j;
|
||||
|
||||
logger.info("--------------------------------------------------------------------------");
|
||||
logger.info("Average Time to Generate JSON : " + generateJsonAvgTime);
|
||||
logger.info("Average Time to Parse JSON To Map : " + parseJsonToMapAvgTime);
|
||||
logger.info("Average Time to Parse JSON To Actual Object : " + parseJsonToActualObjectAvgTime);
|
||||
logger.info("--------------------------------------------------------------------------");
|
||||
}
|
||||
|
||||
private static String generateJson(CustomerPortfolioSimple customerPortfolioSimple) throws JsonProcessingException {
|
||||
Runtime.getRuntime().gc();
|
||||
long startParsTime = System.nanoTime();
|
||||
String json = mapper.writeValueAsString(customerPortfolioSimple);
|
||||
long endParsTime = System.nanoTime();
|
||||
long elapsedTime = endParsTime - startParsTime;
|
||||
generateJsonAvgTime = generateJsonAvgTime + elapsedTime;
|
||||
logger.info("Json Generation Time(ms):: " + elapsedTime);
|
||||
return json;
|
||||
}
|
||||
|
||||
private static void parseJsonToMap(String jsonStr) throws JsonParseException , JsonMappingException , IOException {
|
||||
long startParsTime = System.nanoTime();
|
||||
Map parsedMap = mapper.readValue(jsonStr , Map.class);
|
||||
long endParsTime = System.nanoTime();
|
||||
long elapsedTime = endParsTime - startParsTime;
|
||||
parseJsonToMapAvgTime = parseJsonToMapAvgTime + elapsedTime;
|
||||
logger.info("Generating Map from json Time(ms):: " + elapsedTime);
|
||||
logger.info("--------------------------------------------------------------------------");
|
||||
parsedMap = null;
|
||||
Runtime.getRuntime().gc();
|
||||
}
|
||||
|
||||
private static void parseJsonToActualObject(String jsonStr) throws JsonParseException , JsonMappingException ,
|
||||
IOException {
|
||||
long startParsTime = System.nanoTime();
|
||||
CustomerPortfolioSimple customerPortfolioSimple = mapper.readValue(jsonStr , CustomerPortfolioSimple.class);
|
||||
long endParsTime = System.nanoTime();
|
||||
long elapsedTime = endParsTime - startParsTime;
|
||||
parseJsonToActualObjectAvgTime = parseJsonToActualObjectAvgTime + elapsedTime;
|
||||
logger.info("Generating Actual Object from json Time(ms):: " + elapsedTime);
|
||||
customerPortfolioSimple = null;
|
||||
Runtime.getRuntime().gc();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
package com.baeldung.data.utility;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.Random;
|
||||
|
||||
public class Utility {
|
||||
|
||||
public static String generateRandomName() {
|
||||
char[] chars = "abcdefghijklmnopqrstuvwxyz ".toCharArray();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Random random = new Random();
|
||||
for (int i = 0; i < 8; i++) {
|
||||
char c = chars[random.nextInt(chars.length)];
|
||||
sb.append(c);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static String generateRandomAddress() {
|
||||
char[] chars = "abcdefghijklmnopqrstuvwxyz ".toCharArray();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Random random = new Random();
|
||||
for (int i = 0; i < 30; i++) {
|
||||
char c = chars[random.nextInt(chars.length)];
|
||||
sb.append(c);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static String generateRandomZip() {
|
||||
char[] chars = "1234567890".toCharArray();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Random random = new Random();
|
||||
for (int i = 0; i < 8; i++) {
|
||||
char c = chars[random.nextInt(chars.length)];
|
||||
sb.append(c);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static String generateRandomPhone() {
|
||||
char[] chars = "1234567890".toCharArray();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Random random = new Random();
|
||||
for (int i = 0; i < 10; i++) {
|
||||
char c = chars[random.nextInt(chars.length)];
|
||||
sb.append(c);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static String readFile(String fileName , Class clazz) throws IOException {
|
||||
String dir = clazz.getResource("/").getFile();
|
||||
dir = dir + "/" + fileName;
|
||||
|
||||
BufferedReader br = new BufferedReader(new FileReader(dir));
|
||||
try {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String line = br.readLine();
|
||||
|
||||
while (line != null) {
|
||||
sb.append(line);
|
||||
sb.append(System.lineSeparator());
|
||||
line = br.readLine();
|
||||
}
|
||||
return sb.toString();
|
||||
} finally {
|
||||
br.close();
|
||||
}
|
||||
}
|
||||
|
||||
public static String bytesIntoMB(long bytes) {
|
||||
long kilobyte = 1024;
|
||||
long megabyte = kilobyte * 1024;
|
||||
|
||||
if ((bytes >= 0) && (bytes < kilobyte)) {
|
||||
return bytes + " B";
|
||||
|
||||
} else if ((bytes >= kilobyte) && (bytes < megabyte)) {
|
||||
return (bytes / kilobyte) + " KB";
|
||||
|
||||
} else if ((bytes >= megabyte)) {
|
||||
return (bytes / megabyte) + " MB";
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package com.baeldung.pojo.complex;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class AddressDetails {
|
||||
|
||||
private String address;
|
||||
|
||||
private String zipcode;
|
||||
|
||||
private List<ContactDetails> contactDetails;
|
||||
|
||||
public String getZipcode() {
|
||||
return zipcode;
|
||||
}
|
||||
|
||||
public void setZipcode(String zipcode) {
|
||||
this.zipcode = zipcode;
|
||||
}
|
||||
|
||||
public List<ContactDetails> getContactDetails() {
|
||||
return contactDetails;
|
||||
}
|
||||
|
||||
public void setContactDetails(List<ContactDetails> contactDetails) {
|
||||
this.contactDetails = contactDetails;
|
||||
}
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.baeldung.pojo.complex;
|
||||
|
||||
public class ContactDetails {
|
||||
|
||||
private String mobile;
|
||||
|
||||
private String landline;
|
||||
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
|
||||
public void setMobile(String mobile) {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
|
||||
public String getLandline() {
|
||||
return landline;
|
||||
}
|
||||
|
||||
public void setLandline(String landline) {
|
||||
this.landline = landline;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.baeldung.pojo.complex;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baeldung.pojo.simple.Customer;
|
||||
|
||||
public class CustomerAddressDetails extends Customer {
|
||||
|
||||
private List<AddressDetails> addressDetails;
|
||||
|
||||
public List<AddressDetails> getAddressDetails() {
|
||||
return addressDetails;
|
||||
}
|
||||
|
||||
public void setAddressDetails(List<AddressDetails> addressDetails) {
|
||||
this.addressDetails = addressDetails;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.baeldung.pojo.complex;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CustomerPortfolioComplex {
|
||||
|
||||
private List<CustomerAddressDetails> customerAddressDetailsList;
|
||||
|
||||
public List<CustomerAddressDetails> getCustomerAddressDetailsList() {
|
||||
return customerAddressDetailsList;
|
||||
}
|
||||
|
||||
public void setCustomerAddressDetailsList(List<CustomerAddressDetails> customerAddressDetailsList) {
|
||||
this.customerAddressDetailsList = customerAddressDetailsList;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
package com.baeldung.pojo.simple;
|
||||
|
||||
|
||||
public class Customer {
|
||||
|
||||
private String firstName;
|
||||
|
||||
private String lastName;
|
||||
|
||||
private int age;
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
public int getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
public void setAge(int age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.baeldung.pojo.simple;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CustomerPortfolioSimple {
|
||||
|
||||
private List<Customer> customerLists;
|
||||
|
||||
public List<Customer> getCustomerLists() {
|
||||
return customerLists;
|
||||
}
|
||||
|
||||
public void setCustomerLists(List<Customer> customerLists) {
|
||||
this.customerLists = customerLists;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
# Root logger option
|
||||
log4j.rootLogger=DEBUG, file
|
||||
|
||||
# Redirect log messages to console
|
||||
# log4j.appender.stdout=org.apache.log4j.ConsoleAppender
|
||||
# log4j.appender.stdout.Target=System.out
|
||||
# log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
|
||||
# log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
|
||||
|
||||
# Redirect log messages to a log file, support file rolling.
|
||||
log4j.appender.file=org.apache.log4j.RollingFileAppender
|
||||
log4j.appender.file.File=log4j-application.log
|
||||
log4j.appender.file.MaxFileSize=5MB
|
||||
log4j.appender.file.MaxBackupIndex=10
|
||||
log4j.appender.file.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.file.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n
|
18
gson/pom.xml
18
gson/pom.xml
|
@ -1,6 +1,6 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.baeldung</groupId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>0.1-SNAPSHOT</version>
|
||||
|
||||
|
@ -112,13 +112,9 @@
|
|||
</build>
|
||||
|
||||
<properties>
|
||||
<!-- Spring -->
|
||||
<org.springframework.version>4.1.5.RELEASE</org.springframework.version>
|
||||
<org.springframework.security.version>3.2.5.RELEASE</org.springframework.security.version>
|
||||
|
||||
<!-- persistence -->
|
||||
<hibernate.version>4.3.10.Final</hibernate.version>
|
||||
<mysql-connector-java.version>5.1.35</mysql-connector-java.version>
|
||||
<hibernate.version>4.3.11.Final</hibernate.version>
|
||||
<mysql-connector-java.version>5.1.38</mysql-connector-java.version>
|
||||
|
||||
<!-- marshalling -->
|
||||
<gson.version>2.3</gson.version>
|
||||
|
@ -142,14 +138,14 @@
|
|||
<httpcore.version>4.4.1</httpcore.version>
|
||||
<httpclient.version>4.5</httpclient.version>
|
||||
|
||||
<rest-assured.version>2.4.1</rest-assured.version>
|
||||
<rest-assured.version>2.9.0</rest-assured.version>
|
||||
|
||||
<!-- maven plugins -->
|
||||
<maven-compiler-plugin.version>3.3</maven-compiler-plugin.version>
|
||||
<maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version>
|
||||
<maven-war-plugin.version>2.6</maven-war-plugin.version>
|
||||
<maven-surefire-plugin.version>2.18.1</maven-surefire-plugin.version>
|
||||
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
|
||||
<maven-resources-plugin.version>2.7</maven-resources-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.14</cargo-maven2-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.18</cargo-maven2-plugin.version>
|
||||
|
||||
</properties>
|
||||
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd" >
|
||||
|
||||
</beans>
|
|
@ -1,41 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
|
||||
xsi:schemaLocation="
|
||||
http://java.sun.com/xml/ns/javaee
|
||||
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"
|
||||
>
|
||||
|
||||
<display-name>Spring MVC Application</display-name>
|
||||
|
||||
<!-- Spring root -->
|
||||
<context-param>
|
||||
<param-name>contextClass</param-name>
|
||||
<param-value>
|
||||
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
|
||||
</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>contextConfigLocation</param-name>
|
||||
<param-value>org.baeldung.config</param-value>
|
||||
</context-param>
|
||||
|
||||
<listener>
|
||||
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
|
||||
</listener>
|
||||
|
||||
<!-- Spring child -->
|
||||
<servlet>
|
||||
<servlet-name>api</servlet-name>
|
||||
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>api</servlet-name>
|
||||
<url-pattern>/</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<welcome-file-list>
|
||||
<welcome-file/>
|
||||
</welcome-file-list>
|
||||
|
||||
</web-app>
|
|
@ -1,8 +1,8 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.baeldung</groupId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>0.1-SNAPSHOT</version>
|
||||
<version>0.1.0-SNAPSHOT</version>
|
||||
|
||||
<name>guava</name>
|
||||
|
||||
|
@ -93,13 +93,9 @@
|
|||
</build>
|
||||
|
||||
<properties>
|
||||
<!-- Spring -->
|
||||
<org.springframework.version>4.1.5.RELEASE</org.springframework.version>
|
||||
<org.springframework.security.version>3.2.5.RELEASE</org.springframework.security.version>
|
||||
|
||||
<!-- persistence -->
|
||||
<hibernate.version>4.3.10.Final</hibernate.version>
|
||||
<mysql-connector-java.version>5.1.35</mysql-connector-java.version>
|
||||
<hibernate.version>4.3.11.Final</hibernate.version>
|
||||
<mysql-connector-java.version>5.1.38</mysql-connector-java.version>
|
||||
|
||||
<!-- logging -->
|
||||
<org.slf4j.version>1.7.13</org.slf4j.version>
|
||||
|
@ -120,14 +116,14 @@
|
|||
<httpcore.version>4.4.1</httpcore.version>
|
||||
<httpclient.version>4.5</httpclient.version>
|
||||
|
||||
<rest-assured.version>2.4.1</rest-assured.version>
|
||||
<rest-assured.version>2.9.0</rest-assured.version>
|
||||
|
||||
<!-- maven plugins -->
|
||||
<maven-compiler-plugin.version>3.3</maven-compiler-plugin.version>
|
||||
<maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version>
|
||||
<maven-war-plugin.version>2.6</maven-war-plugin.version>
|
||||
<maven-surefire-plugin.version>2.18.1</maven-surefire-plugin.version>
|
||||
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
|
||||
<maven-resources-plugin.version>2.7</maven-resources-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.14</cargo-maven2-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.18</cargo-maven2-plugin.version>
|
||||
|
||||
</properties>
|
||||
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd" >
|
||||
|
||||
</beans>
|
|
@ -1,41 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
|
||||
xsi:schemaLocation="
|
||||
http://java.sun.com/xml/ns/javaee
|
||||
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"
|
||||
>
|
||||
|
||||
<display-name>Spring MVC Application</display-name>
|
||||
|
||||
<!-- Spring root -->
|
||||
<context-param>
|
||||
<param-name>contextClass</param-name>
|
||||
<param-value>
|
||||
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
|
||||
</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>contextConfigLocation</param-name>
|
||||
<param-value>org.baeldung.config</param-value>
|
||||
</context-param>
|
||||
|
||||
<listener>
|
||||
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
|
||||
</listener>
|
||||
|
||||
<!-- Spring child -->
|
||||
<servlet>
|
||||
<servlet-name>api</servlet-name>
|
||||
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>api</servlet-name>
|
||||
<url-pattern>/</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<welcome-file-list>
|
||||
<welcome-file/>
|
||||
</welcome-file-list>
|
||||
|
||||
</web-app>
|
|
@ -5,8 +5,8 @@
|
|||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<artifactId>guava18</artifactId>
|
||||
<version>0.1.0-SNAPSHOT</version>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
=========
|
||||
|
||||
## Guava 19
|
||||
|
||||
|
||||
### Relevant Articles:
|
||||
- [Guava 19: What’s New?](http://www.baeldung.com/whats-new-in-guava-19)
|
|
@ -1,12 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<artifactId>guava19</artifactId>
|
||||
<version>0.1.0-SNAPSHOT</version>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
@ -25,6 +23,7 @@
|
|||
<version>1.3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
|
|
|
@ -6,7 +6,11 @@
|
|||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry including="**/*.java" kind="src" path="src/main/resources"/>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>handling-spring-static-resources</name>
|
||||
<name>spring-static-resources</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.baeldung</groupId>
|
||||
<artifactId>handling-spring-static-resources</artifactId>
|
||||
<name>handling-spring-static-resources</name>
|
||||
<version>0.1-SNAPSHOT</version>
|
||||
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>spring-static-resources</artifactId>
|
||||
<version>0.1.0-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
|
||||
<name>spring-static-resources</name>
|
||||
|
||||
<dependencies>
|
||||
<!-- Spring Security -->
|
||||
|
||||
|
@ -161,7 +163,7 @@
|
|||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>handling-spring-static-resources</finalName>
|
||||
<finalName>spring-static-resources</finalName>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
|
@ -172,21 +174,22 @@
|
|||
|
||||
<properties>
|
||||
<java-version>1.8</java-version>
|
||||
|
||||
<!-- Spring -->
|
||||
<org.springframework.version>4.2.4.RELEASE</org.springframework.version>
|
||||
<org.springframework.security.version>4.0.3.RELEASE</org.springframework.security.version>
|
||||
<org.springframework.version>4.2.5.RELEASE</org.springframework.version>
|
||||
<org.springframework.security.version>4.0.4.RELEASE</org.springframework.security.version>
|
||||
|
||||
<org.aspectj-version>1.8.1</org.aspectj-version>
|
||||
<javax.servlet.jsp-api.version>2.3.2-b01</javax.servlet.jsp-api.version>
|
||||
|
||||
<!-- persistence -->
|
||||
<hibernate.version>4.3.11.Final</hibernate.version>
|
||||
<mysql-connector-java.version>5.1.37</mysql-connector-java.version>
|
||||
<mysql-connector-java.version>5.1.38</mysql-connector-java.version>
|
||||
<spring-data-jpa.version>1.9.2.RELEASE</spring-data-jpa.version>
|
||||
|
||||
<!-- marshalling -->
|
||||
|
||||
<jackson.version>2.6.4</jackson.version>
|
||||
<jackson.version>2.7.2</jackson.version>
|
||||
|
||||
<!-- logging -->
|
||||
<org.slf4j.version>1.7.13</org.slf4j.version>
|
||||
|
@ -207,13 +210,13 @@
|
|||
<httpcore.version>4.4.1</httpcore.version>
|
||||
<httpclient.version>4.5</httpclient.version>
|
||||
|
||||
<rest-assured.version>2.4.1</rest-assured.version>
|
||||
<rest-assured.version>2.9.0</rest-assured.version>
|
||||
|
||||
<!-- Maven plugins -->
|
||||
<maven-compiler-plugin.version>3.3</maven-compiler-plugin.version>
|
||||
<maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version>
|
||||
<maven-war-plugin.version>2.6</maven-war-plugin.version>
|
||||
<maven-surefire-plugin.version>2.18.1</maven-surefire-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.14</cargo-maven2-plugin.version>
|
||||
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.18</cargo-maven2-plugin.version>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -1,6 +1,6 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.baeldung</groupId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>0.1-SNAPSHOT</version>
|
||||
|
||||
|
@ -148,13 +148,9 @@
|
|||
</build>
|
||||
|
||||
<properties>
|
||||
<!-- Spring -->
|
||||
<org.springframework.version>4.1.5.RELEASE</org.springframework.version>
|
||||
<org.springframework.security.version>3.2.5.RELEASE</org.springframework.security.version>
|
||||
|
||||
<!-- persistence -->
|
||||
<hibernate.version>4.3.10.Final</hibernate.version>
|
||||
<mysql-connector-java.version>5.1.35</mysql-connector-java.version>
|
||||
<hibernate.version>4.3.11.Final</hibernate.version>
|
||||
<mysql-connector-java.version>5.1.38</mysql-connector-java.version>
|
||||
|
||||
<!-- logging -->
|
||||
<org.slf4j.version>1.7.13</org.slf4j.version>
|
||||
|
@ -175,14 +171,14 @@
|
|||
<httpcore.version>4.4.1</httpcore.version>
|
||||
<httpclient.version>4.5</httpclient.version> <!-- 4.3.6 --> <!-- 4.4-beta1 -->
|
||||
|
||||
<rest-assured.version>2.4.1</rest-assured.version>
|
||||
<rest-assured.version>2.9.0</rest-assured.version>
|
||||
|
||||
<!-- maven plugins -->
|
||||
<maven-compiler-plugin.version>3.3</maven-compiler-plugin.version>
|
||||
<maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version>
|
||||
<maven-war-plugin.version>2.6</maven-war-plugin.version>
|
||||
<maven-surefire-plugin.version>2.18.1</maven-surefire-plugin.version>
|
||||
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
|
||||
<maven-resources-plugin.version>2.7</maven-resources-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.14</cargo-maven2-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.18</cargo-maven2-plugin.version>
|
||||
|
||||
</properties>
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.baeldung</groupId>
|
||||
<groupId>com.baeldung</groupId>
|
||||
<artifactId>jackson</artifactId>
|
||||
<version>0.1-SNAPSHOT</version>
|
||||
|
||||
|
@ -47,25 +48,31 @@
|
|||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-jsr310</artifactId>
|
||||
<version>2.4.0</version>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.datatype</groupId>
|
||||
<artifactId>jackson-datatype-joda</artifactId>
|
||||
<version>2.4.0</version>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.module</groupId>
|
||||
<artifactId>jackson-module-jsonSchema</artifactId>
|
||||
<version>2.6.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>joda-time</groupId>
|
||||
<artifactId>joda-time</artifactId>
|
||||
<version>2.6</version>
|
||||
<version>2.9.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.3.1</version>
|
||||
<version>2.6.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- test scoped -->
|
||||
|
@ -131,16 +138,12 @@
|
|||
</build>
|
||||
|
||||
<properties>
|
||||
<!-- Spring -->
|
||||
<org.springframework.version>4.1.5.RELEASE</org.springframework.version>
|
||||
<org.springframework.security.version>3.2.5.RELEASE</org.springframework.security.version>
|
||||
|
||||
<!-- persistence -->
|
||||
<hibernate.version>4.3.10.Final</hibernate.version>
|
||||
<mysql-connector-java.version>5.1.35</mysql-connector-java.version>
|
||||
<hibernate.version>4.3.11.Final</hibernate.version>
|
||||
<mysql-connector-java.version>5.1.38</mysql-connector-java.version>
|
||||
|
||||
<!-- marshalling -->
|
||||
<jackson.version>2.7.1-1</jackson.version>
|
||||
<jackson.version>2.7.2</jackson.version>
|
||||
|
||||
<!-- logging -->
|
||||
<org.slf4j.version>1.7.13</org.slf4j.version>
|
||||
|
@ -161,15 +164,15 @@
|
|||
<httpcore.version>4.4.1</httpcore.version>
|
||||
<httpclient.version>4.5</httpclient.version>
|
||||
|
||||
<rest-assured.version>2.4.1</rest-assured.version>
|
||||
<rest-assured.version>2.9.0</rest-assured.version>
|
||||
|
||||
<!-- maven plugins -->
|
||||
<maven-compiler-plugin.version>3.3</maven-compiler-plugin.version>
|
||||
<maven-compiler-plugin.version>3.5.1</maven-compiler-plugin.version>
|
||||
<maven-war-plugin.version>2.6</maven-war-plugin.version>
|
||||
<maven-surefire-plugin.version>2.18.1</maven-surefire-plugin.version>
|
||||
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
|
||||
<maven-resources-plugin.version>2.7</maven-resources-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.14</cargo-maven2-plugin.version>
|
||||
<cargo-maven2-plugin.version>1.4.18</cargo-maven2-plugin.version>
|
||||
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
</project>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.annotation;
|
||||
package com.baeldung.jackson.annotation;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
@ -1,10 +1,10 @@
|
|||
package org.baeldung.jackson.annotation;
|
||||
package com.baeldung.jackson.annotation;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.Date;
|
||||
|
||||
import org.baeldung.jackson.annotation.BeanWithCustomAnnotation.CustomAnnotation;
|
||||
import com.baeldung.jackson.annotation.BeanWithCustomAnnotation.CustomAnnotation;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.annotation;
|
||||
package com.baeldung.jackson.annotation;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFilter;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.annotation;
|
||||
package com.baeldung.jackson.annotation;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonGetter;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.annotation;
|
||||
package com.baeldung.jackson.annotation;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.annotation;
|
||||
package com.baeldung.jackson.annotation;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JacksonInject;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.annotation;
|
||||
package com.baeldung.jackson.annotation;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.annotation;
|
||||
package com.baeldung.jackson.annotation;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.annotation;
|
||||
package com.baeldung.jackson.annotation;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.annotation;
|
||||
package com.baeldung.jackson.annotation;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonRawValue;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.annotation;
|
||||
package com.baeldung.jackson.annotation;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonUnwrapped;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.annotation;
|
||||
package com.baeldung.jackson.annotation;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreType;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.annotation;
|
||||
package com.baeldung.jackson.annotation;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonSubTypes;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
|
@ -0,0 +1,31 @@
|
|||
package com.baeldung.jackson.annotation.extra;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonAppend;
|
||||
|
||||
@JsonAppend(attrs = {@JsonAppend.Attr(value = "appendedProperty", include = JsonInclude.Include.ALWAYS)})
|
||||
public class AppendBean {
|
||||
private int id;
|
||||
private String name;
|
||||
|
||||
public AppendBean(int id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
package com.baeldung.jackson.annotation.extra;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.hamcrest.CoreMatchers.instanceOf;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping;
|
||||
import com.fasterxml.jackson.module.jsonSchema.JsonSchema;
|
||||
import com.fasterxml.jackson.module.jsonSchema.factories.SchemaFactoryWrapper;
|
||||
|
||||
public class ExtraAnnotationTest {
|
||||
@Test
|
||||
public void whenUsingJsonIdentityReferenceAnnotation_thenCorrect() throws JsonProcessingException {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
IdentityReferenceBean bean = new IdentityReferenceBean(1, "Identity Reference Bean");
|
||||
String jsonString = mapper.writeValueAsString(bean);
|
||||
|
||||
assertEquals("1", jsonString);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenUsingJsonAppendAnnotation_thenCorrect() throws JsonProcessingException {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
AppendBean bean = new AppendBean(2, "Append Bean");
|
||||
String jsonString = mapper.writeValueAsString(bean);
|
||||
|
||||
assertThat(jsonString, containsString("appendedProperty"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenUsingJsonNamingAnnotation_thenCorrect() throws JsonProcessingException {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
NamingBean bean = new NamingBean(3, "Naming Bean");
|
||||
String jsonString = mapper.writeValueAsString(bean);
|
||||
|
||||
assertThat(jsonString, containsString("bean_name"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenUsingJsonPropertyDescriptionAnnotation_thenCorrect() throws JsonProcessingException {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
SchemaFactoryWrapper wrapper = new SchemaFactoryWrapper();
|
||||
mapper.acceptJsonFormatVisitor(PropertyDescriptionBean.class, wrapper);
|
||||
JsonSchema jsonSchema = wrapper.finalSchema();
|
||||
String jsonString = mapper.writeValueAsString(jsonSchema);
|
||||
|
||||
assertThat(jsonString, containsString("This is a description of the name property"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenUsingJsonPOJOBuilderAnnotation_thenCorrect() throws IOException {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
String jsonString = "{\"id\":5,\"name\":\"POJO Builder Bean\"}";
|
||||
POJOBuilderBean bean = mapper.readValue(jsonString, POJOBuilderBean.class);
|
||||
|
||||
assertEquals(5, bean.getIdentity());
|
||||
assertEquals("POJO Builder Bean", bean.getBeanName());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenUsingJsonTypeIdAnnotation_thenCorrect() throws JsonProcessingException {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
mapper.enableDefaultTyping(DefaultTyping.NON_FINAL);
|
||||
TypeIdBean bean = new TypeIdBean(6, "Type Id Bean");
|
||||
String jsonString = mapper.writeValueAsString(bean);
|
||||
|
||||
assertThat(jsonString, containsString("Type Id Bean"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void whenUsingJsonTypeIdResolverAnnotation_thenCorrect() throws IOException {
|
||||
TypeIdResolverStructure.FirstBean bean1 = new TypeIdResolverStructure.FirstBean(1, "Bean 1");
|
||||
TypeIdResolverStructure.LastBean bean2 = new TypeIdResolverStructure.LastBean(2, "Bean 2");
|
||||
|
||||
List<TypeIdResolverStructure.AbstractBean> beans = new ArrayList<>();
|
||||
beans.add(bean1);
|
||||
beans.add(bean2);
|
||||
|
||||
TypeIdResolverStructure.BeanContainer serializedContainer = new TypeIdResolverStructure.BeanContainer();
|
||||
serializedContainer.setBeans(beans);
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
String jsonString = mapper.writeValueAsString(serializedContainer);
|
||||
assertThat(jsonString, containsString("bean1"));
|
||||
assertThat(jsonString, containsString("bean2"));
|
||||
|
||||
TypeIdResolverStructure.BeanContainer deserializedContainer = mapper.readValue(jsonString, TypeIdResolverStructure.BeanContainer.class);
|
||||
List<TypeIdResolverStructure.AbstractBean> beanList = deserializedContainer.getBeans();
|
||||
assertThat(beanList.get(0), instanceOf(TypeIdResolverStructure.FirstBean.class));
|
||||
assertThat(beanList.get(1), instanceOf(TypeIdResolverStructure.LastBean.class));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package com.baeldung.jackson.annotation.extra;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityReference;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
||||
|
||||
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
|
||||
@JsonIdentityReference(alwaysAsId = true)
|
||||
public class IdentityReferenceBean {
|
||||
private int id;
|
||||
private String name;
|
||||
|
||||
public IdentityReferenceBean(int id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
package com.baeldung.jackson.annotation.extra;
|
||||
|
||||
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonNaming;
|
||||
|
||||
@JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class)
|
||||
public class NamingBean {
|
||||
private int id;
|
||||
private String beanName;
|
||||
|
||||
public NamingBean(int id, String beanName) {
|
||||
this.id = id;
|
||||
this.beanName = beanName;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getBeanName() {
|
||||
return beanName;
|
||||
}
|
||||
|
||||
public void setBeanName(String beanName) {
|
||||
this.beanName = beanName;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
package com.baeldung.jackson.annotation.extra;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder;
|
||||
|
||||
@JsonDeserialize(builder = POJOBuilderBean.BeanBuilder.class)
|
||||
public class POJOBuilderBean {
|
||||
private int identity;
|
||||
private String beanName;
|
||||
|
||||
@JsonPOJOBuilder(buildMethodName = "createBean", withPrefix = "construct")
|
||||
public static class BeanBuilder {
|
||||
private int idValue;
|
||||
private String nameValue;
|
||||
|
||||
public BeanBuilder constructId(int id) {
|
||||
idValue = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public BeanBuilder constructName(String name) {
|
||||
nameValue = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public POJOBuilderBean createBean() {
|
||||
return new POJOBuilderBean(idValue, nameValue);
|
||||
}
|
||||
}
|
||||
|
||||
public POJOBuilderBean(int identity, String beanName) {
|
||||
this.identity = identity;
|
||||
this.beanName = beanName;
|
||||
}
|
||||
|
||||
public int getIdentity() {
|
||||
return identity;
|
||||
}
|
||||
|
||||
public void setIdentity(int identity) {
|
||||
this.identity = identity;
|
||||
}
|
||||
|
||||
public String getBeanName() {
|
||||
return beanName;
|
||||
}
|
||||
|
||||
public void setBeanName(String beanName) {
|
||||
this.beanName = beanName;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.baeldung.jackson.annotation.extra;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonPropertyDescription;
|
||||
|
||||
public class PropertyDescriptionBean {
|
||||
private int id;
|
||||
@JsonPropertyDescription("This is a description of the name property")
|
||||
private String name;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package com.baeldung.jackson.annotation.extra;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonTypeId;
|
||||
|
||||
public class TypeIdBean {
|
||||
private int id;
|
||||
@JsonTypeId
|
||||
private String name;
|
||||
|
||||
public TypeIdBean(int id, String name) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,130 @@
|
|||
package com.baeldung.jackson.annotation.extra;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
|
||||
import com.fasterxml.jackson.databind.DatabindContext;
|
||||
import com.fasterxml.jackson.databind.JavaType;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonTypeIdResolver;
|
||||
import com.fasterxml.jackson.databind.jsontype.impl.TypeIdResolverBase;
|
||||
|
||||
public class TypeIdResolverStructure {
|
||||
public static class BeanContainer {
|
||||
private List<AbstractBean> beans;
|
||||
|
||||
public List<AbstractBean> getBeans() {
|
||||
return beans;
|
||||
}
|
||||
|
||||
public void setBeans(List<AbstractBean> beans) {
|
||||
this.beans = beans;
|
||||
}
|
||||
}
|
||||
|
||||
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "@type")
|
||||
@JsonTypeIdResolver(BeanIdResolver.class)
|
||||
public static class AbstractBean {
|
||||
private int id;
|
||||
|
||||
protected AbstractBean() {
|
||||
}
|
||||
|
||||
protected AbstractBean(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
||||
public static class FirstBean extends AbstractBean {
|
||||
String firstName;
|
||||
|
||||
public FirstBean() {
|
||||
}
|
||||
|
||||
public FirstBean(int id, String name) {
|
||||
super(id);
|
||||
setFirstName(name);
|
||||
}
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(String name) {
|
||||
firstName = name;
|
||||
}
|
||||
}
|
||||
|
||||
public static class LastBean extends AbstractBean {
|
||||
String lastName;
|
||||
|
||||
public LastBean() {
|
||||
}
|
||||
|
||||
public LastBean(int id, String name) {
|
||||
super(id);
|
||||
setLastName(name);
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(String name) {
|
||||
lastName = name;
|
||||
}
|
||||
}
|
||||
|
||||
public static class BeanIdResolver extends TypeIdResolverBase {
|
||||
private JavaType superType;
|
||||
|
||||
@Override
|
||||
public void init(JavaType baseType) {
|
||||
superType = baseType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Id getMechanism() {
|
||||
return Id.NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String idFromValue(Object obj) {
|
||||
return idFromValueAndType(obj, obj.getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String idFromValueAndType(Object obj, Class<?> subType) {
|
||||
String typeId = null;
|
||||
switch (subType.getSimpleName()) {
|
||||
case "FirstBean":
|
||||
typeId = "bean1";
|
||||
break;
|
||||
case "LastBean":
|
||||
typeId = "bean2";
|
||||
}
|
||||
return typeId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaType typeFromId(DatabindContext context, String id) {
|
||||
Class<?> subType = null;
|
||||
switch (id) {
|
||||
case "bean1":
|
||||
subType = FirstBean.class;
|
||||
break;
|
||||
case "bean2":
|
||||
subType = LastBean.class;
|
||||
}
|
||||
return context.constructSpecializedType(superType, subType);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.bidirection;
|
||||
package com.baeldung.jackson.bidirection;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.bidirection;
|
||||
package com.baeldung.jackson.bidirection;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.bidirection;
|
||||
package com.baeldung.jackson.bidirection;
|
||||
|
||||
public class Item {
|
||||
public int id;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.bidirection;
|
||||
package com.baeldung.jackson.bidirection;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIdentityInfo;
|
||||
import com.fasterxml.jackson.annotation.ObjectIdGenerators;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.bidirection;
|
||||
package com.baeldung.jackson.bidirection;
|
||||
|
||||
public class ItemWithIgnore {
|
||||
public int id;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.bidirection;
|
||||
package com.baeldung.jackson.bidirection;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonManagedReference;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.bidirection;
|
||||
package com.baeldung.jackson.bidirection;
|
||||
|
||||
public class ItemWithSerializer {
|
||||
public int id;
|
|
@ -1,6 +1,6 @@
|
|||
package org.baeldung.jackson.bidirection;
|
||||
package com.baeldung.jackson.bidirection;
|
||||
|
||||
import org.baeldung.jackson.jsonview.Views;
|
||||
import com.baeldung.jackson.jsonview.Views;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.bidirection;
|
||||
package com.baeldung.jackson.bidirection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.bidirection;
|
||||
package com.baeldung.jackson.bidirection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.bidirection;
|
||||
package com.baeldung.jackson.bidirection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.bidirection;
|
||||
package com.baeldung.jackson.bidirection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.bidirection;
|
||||
package com.baeldung.jackson.bidirection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
|
@ -1,9 +1,9 @@
|
|||
package org.baeldung.jackson.bidirection;
|
||||
package com.baeldung.jackson.bidirection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.baeldung.jackson.jsonview.Views;
|
||||
import com.baeldung.jackson.jsonview.Views;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonView;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.date;
|
||||
package com.baeldung.jackson.date;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.date;
|
||||
package com.baeldung.jackson.date;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.SimpleDateFormat;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.date;
|
||||
package com.baeldung.jackson.date;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.date;
|
||||
package com.baeldung.jackson.date;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDateTime;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.date;
|
||||
package com.baeldung.jackson.date;
|
||||
|
||||
import java.util.Date;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.date;
|
||||
package com.baeldung.jackson.date;
|
||||
|
||||
import java.util.Date;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.date;
|
||||
package com.baeldung.jackson.date;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.date;
|
||||
package com.baeldung.jackson.date;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.date;
|
||||
package com.baeldung.jackson.date;
|
||||
|
||||
import java.util.Date;
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
package org.baeldung.jackson.deserialization;
|
||||
package com.baeldung.jackson.deserialization;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.baeldung.jackson.dtos.Item;
|
||||
import org.baeldung.jackson.dtos.User;
|
||||
import com.baeldung.jackson.dtos.User;
|
||||
import com.baeldung.jackson.dtos.Item;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
@ -1,9 +1,9 @@
|
|||
package org.baeldung.jackson.deserialization;
|
||||
package com.baeldung.jackson.deserialization;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.baeldung.jackson.dtos.ItemWithSerializer;
|
||||
import org.baeldung.jackson.dtos.User;
|
||||
import com.baeldung.jackson.dtos.ItemWithSerializer;
|
||||
import com.baeldung.jackson.dtos.User;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonParser;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.dtos;
|
||||
package com.baeldung.jackson.dtos;
|
||||
|
||||
public class Item {
|
||||
public int id;
|
|
@ -1,7 +1,7 @@
|
|||
package org.baeldung.jackson.dtos;
|
||||
package com.baeldung.jackson.dtos;
|
||||
|
||||
import org.baeldung.jackson.deserialization.ItemDeserializerOnClass;
|
||||
import org.baeldung.jackson.serialization.ItemSerializerOnClass;
|
||||
import com.baeldung.jackson.deserialization.ItemDeserializerOnClass;
|
||||
import com.baeldung.jackson.serialization.ItemSerializerOnClass;
|
||||
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.dtos;
|
||||
package com.baeldung.jackson.dtos;
|
||||
|
||||
public class MyDto {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.dtos;
|
||||
package com.baeldung.jackson.dtos;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.dtos;
|
||||
package com.baeldung.jackson.dtos;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.dtos;
|
||||
package com.baeldung.jackson.dtos;
|
||||
|
||||
public class MyDtoNoAccessors {
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.dtos;
|
||||
package com.baeldung.jackson.dtos;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.dtos;
|
||||
package com.baeldung.jackson.dtos;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFilter;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.dtos;
|
||||
package com.baeldung.jackson.dtos;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreType;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.dtos;
|
||||
package com.baeldung.jackson.dtos;
|
||||
|
||||
public class User {
|
||||
public int id;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.dtos.ignore;
|
||||
package com.baeldung.jackson.dtos.ignore;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.dtos.ignore;
|
||||
package com.baeldung.jackson.dtos.ignore;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.dtos.ignore;
|
||||
package com.baeldung.jackson.dtos.ignore;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude.Include;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.jackson.dtos.ignore;
|
||||
package com.baeldung.jackson.dtos.ignore;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue