Bug #508688 - Remove JSON-B. JSON-B is moved to Eclipse Yasson project.
Signed-off-by: Dmitry Kornilov <dmitry.kornilov@oracle.com>
diff --git a/jsonb/build.gradle b/jsonb/build.gradle
deleted file mode 100644
index e349e34..0000000
--- a/jsonb/build.gradle
+++ /dev/null
@@ -1,166 +0,0 @@
-apply plugin: 'java'
-apply plugin: "maven"
-apply plugin: 'signing'
-apply plugin: 'idea'
-apply plugin: 'findbugs'
-
-group = "org.eclipse.persistence"
-version = "1.0-SNAPSHOT"
-
-jar {
- name = "jsonb-ri"
- archivesBaseName = "jsonb-ri"
- version = '1.0-SNAPSHOT'
-}
-
-def defaultEncoding = 'UTF-8'
-compileJava {
- sourceCompatibility = 1.8
- targetCompatibility = 1.8
- options.encoding = defaultEncoding
- compileTestJava {
- options.encoding = defaultEncoding
- }
-
-}
-
-sourceSets {
- test {
- resources.srcDir 'src/main/resources'
- }
-}
-
-repositories {
- mavenLocal()
- mavenCentral()
- maven {
- url "https://maven.java.net/content/repositories/snapshots/"
- }
-}
-
-dependencies {
- compile 'javax.json.bind:javax.json.bind-api:1.0-SNAPSHOT'
- compile 'javax.json:javax.json-api:1.1.0-SNAPSHOT'
- compile 'javax.enterprise:cdi-api:1.2'
-
- if (project.hasProperty('1.1')) {
- println '1.1'
- testRuntime 'org.glassfish:javax.json:1.1.0'
- } else {
- println '1.0'
- testRuntime 'org.glassfish:javax.json:1.1.0-SNAPSHOT'
- }
-
- testCompile 'junit:junit:4.12'
- testCompile 'org.jboss.weld:weld-core:2.3.3.Final';
- testCompile 'org.jboss.weld.se:weld-se:2.3.3.Final';
-
-}
-
-test {
- if (!project.hasProperty('1.1')) {
- println 'Single value tests excluded'
- exclude 'org/eclipse/persistence/json/bind/defaultmapping/basic/SingleValueTest.class'
- }
-}
-
-task wrapper(type: Wrapper) {
- gradleVersion = '2.3'
-}
-
-idea {
- module {
- downloadJavadoc = true
- downloadSources = true
- }
-}
-
-/*task noErrorJavadoc(type: Javadoc) {
- failOnError = false
-}*/
-
-task javadocJar(type: Jar, dependsOn: javadoc) {
- classifier = 'javadoc'
- from javadoc
-}
-
-task sourcesJar(type: Jar, dependsOn: classes) {
- classifier = 'sources'
- from sourceSets.main.allSource
-}
-
-artifacts {
- archives javadocJar
- archives sourcesJar
-}
-
-/*signing {
- sign configurations.archives
-}*/
-
-// use ./gradlew upload -PdeployOSS
-if (project.hasProperty("deployOSS")) {
-
- println 'Deploying to OSS';
- uploadArchives {
- repositories {
- mavenDeployer {
-// beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
-
- repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
- authentication(userName: uName, password: uPwd)
- }
-
- snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
- authentication(userName: uName, password: uPwd)
- }
-
- pom.project {
- name 'jsonb-ri'
- packaging 'jar'
- // optionally artifactId can be defined here
- description 'Reference implementation of JSR-367'
-// url 'http://www.example.com/example-application'
-
- scm {
- connection 'scm:git://git.eclipse.org/gitroot/eclipselink/eclipselink.runtime.git'
- developerConnection 'scm:ssh://git.eclipse.org/gitroot/eclipselink/eclipselink.runtime.git'
- url 'http://git.eclipse.org/c/eclipselink/eclipselink.runtime.git'
- }
-
- licenses {
- license {
- name 'Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0'
- url 'http://www.eclipse.org/legal/epl-v10.html'
- }
- }
-
- developers {
- developer {
- id 'rgrigoriadi'
- name 'Roman Grigoriadi'
- email 'roman.grigoriadi@oracle.com'
- }
- }
- }
- }
- }
- }
-}
-
-/**
- * Configure Findbugs plugin and make it disable on normal build process. The Findbug plugin introduces two tasks to run
- * the inspections for the main sources or tests. To call them, we can just run following tasks directly:
- *
- * findbugsMain: runs the inspections for the main sources (e.g. ./gradlew findbugsMain)
- * findbugsTest: runs the inspections for the test sources (e.g. ./gradlew findbugsTest)
- */
-findbugs {
- ignoreFailures = true
- effort = "max"
- reportLevel = "low"
- toolVersion = "3.0.1"
- // Empty sourceSets prevents the findbugs to be run as part of default build life cycle, but it still works by
- // calling its corresponding tasks (findbugsMain and findbugsTest) directly
- sourceSets = []
-}
\ No newline at end of file
diff --git a/jsonb/gradle/wrapper/gradle-wrapper.jar b/jsonb/gradle/wrapper/gradle-wrapper.jar
deleted file mode 100644
index 085a1cd..0000000
--- a/jsonb/gradle/wrapper/gradle-wrapper.jar
+++ /dev/null
Binary files differ
diff --git a/jsonb/gradle/wrapper/gradle-wrapper.properties b/jsonb/gradle/wrapper/gradle-wrapper.properties
deleted file mode 100644
index c321290..0000000
--- a/jsonb/gradle/wrapper/gradle-wrapper.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-#Tue Jul 28 17:46:49 CEST 2015
-distributionBase=GRADLE_USER_HOME
-distributionPath=wrapper/dists
-zipStoreBase=GRADLE_USER_HOME
-zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.3-all.zip
diff --git a/jsonb/gradlew b/jsonb/gradlew
deleted file mode 100755
index 91a7e26..0000000
--- a/jsonb/gradlew
+++ /dev/null
@@ -1,164 +0,0 @@
-#!/usr/bin/env bash
-
-##############################################################################
-##
-## Gradle start up script for UN*X
-##
-##############################################################################
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
-
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
-
-warn ( ) {
- echo "$*"
-}
-
-die ( ) {
- echo
- echo "$*"
- echo
- exit 1
-}
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
-esac
-
-# For Cygwin, ensure paths are in UNIX format before anything is touched.
-if $cygwin ; then
- [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
-fi
-
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >&-
-APP_HOME="`pwd -P`"
-cd "$SAVED" >&-
-
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
-
-# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- if [ ! -x "$JAVACMD" ] ; then
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
- fi
-else
- JAVACMD="java"
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
-fi
-
-# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
- fi
-fi
-
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
-
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
- fi
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
- fi
- i=$((i+1))
- done
- case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
- esac
-fi
-
-# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
-function splitJvmOpts() {
- JVM_OPTS=("$@")
-}
-eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
-JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
-
-exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/jsonb/gradlew.bat b/jsonb/gradlew.bat
deleted file mode 100644
index 8a0b282..0000000
--- a/jsonb/gradlew.bat
+++ /dev/null
@@ -1,90 +0,0 @@
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto init
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:init
-@rem Get command-line arguments, handling Windowz variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-if "%@eval[2+2]" == "4" goto 4NT_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-goto execute
-
-:4NT_args
-@rem Get arguments from the 4NT Shell from JP Software
-set CMD_LINE_ARGS=%$
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/JsonBindingProvider.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/JsonBindingProvider.java
deleted file mode 100644
index 9ff3c67..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/JsonBindingProvider.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Dmitry Kornilov - initial implementation
- ******************************************************************************/
-package org.eclipse.persistence.json.bind;
-
-import org.eclipse.persistence.json.bind.internal.JsonBindingBuilder;
-
-import javax.json.bind.JsonbBuilder;
-import javax.json.bind.spi.JsonbProvider;
-
-/**
- * JsonbProvider implementation.
- *
- * @author Dmitry Kornilov
- */
-public class JsonBindingProvider extends JsonbProvider {
-
- @Override
- public JsonbBuilder create() {
- return new JsonBindingBuilder();
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/AbstractContainerSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/AbstractContainerSerializer.java
deleted file mode 100644
index e3919e0..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/AbstractContainerSerializer.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal;
-
-import org.eclipse.persistence.json.bind.internal.serializer.SerializerBuilder;
-import org.eclipse.persistence.json.bind.internal.unmarshaller.AbstractItem;
-import org.eclipse.persistence.json.bind.internal.unmarshaller.CurrentItem;
-import org.eclipse.persistence.json.bind.model.ClassModel;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-import org.eclipse.persistence.json.bind.model.JsonContext;
-
-import javax.json.bind.serializer.JsonbSerializer;
-import javax.json.bind.serializer.SerializationContext;
-import javax.json.stream.JsonGenerator;
-import java.lang.reflect.Type;
-
-/**
- * @author Roman Grigoriadi
- */
-public abstract class AbstractContainerSerializer<T> extends AbstractItem<T> implements JsonbSerializer<T> {
- /**
- * Create instance of current item with its builder.
- *
- * @param builder
- */
- protected AbstractContainerSerializer(SerializerBuilder builder) {
- super(builder);
- }
-
- public AbstractContainerSerializer(CurrentItem<?> wrapper, Type runtimeType, ClassModel classModel, JsonBindingModel wrapperModel) {
- super(wrapper, runtimeType, classModel, wrapperModel);
- }
-
- @Override
- public final void serialize(T obj, JsonGenerator generator, SerializationContext ctx) {
- if (getWrapperModel().getContext() == JsonContext.JSON_OBJECT) {
- writeStart(getWrapperModel().getWriteName(), generator);
- } else {
- writeStart(generator);
- }
- serializeInternal(obj, generator, ctx);
- writeEnd(generator);
- }
-
- protected abstract void serializeInternal(T obj, JsonGenerator generator, SerializationContext ctx);
-
- /**
- * Write start object or start array without a key.
- */
- protected abstract void writeStart(JsonGenerator generator);
-
- /**
- * Writes end for object or array.
- */
- protected void writeEnd(JsonGenerator generator) {
- generator.writeEnd();
- }
-
- /**
- * Write start object or start array with key.
- * @param key json key name
- */
- protected abstract void writeStart(String key, JsonGenerator generator);
-
- protected <X> void serializerCaptor(JsonbSerializer<?> serializer, X object, JsonGenerator generator, SerializationContext ctx) {
- ((JsonbSerializer<X>) serializer).serialize(object, generator, ctx);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/AbstractSerializerBuilder.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/AbstractSerializerBuilder.java
deleted file mode 100644
index 178979e..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/AbstractSerializerBuilder.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal;
-
-import org.eclipse.persistence.json.bind.internal.unmarshaller.CurrentItem;
-import org.eclipse.persistence.json.bind.model.ClassModel;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import java.lang.reflect.Type;
-import java.util.Objects;
-
-/**
- * @author Roman Grigoriadi
- */
-public class AbstractSerializerBuilder<T extends AbstractSerializerBuilder> {
- /**
- * Not null with an exception of a root item.
- */
- protected CurrentItem<?> wrapper;
- /**
- * Model of jsonb binding.
- */
- protected JsonBindingModel model;
- /**
- * In case of unknown object genericType.
- * Null for embedded objects such as collections, or known conversion types.
- */
- protected ClassModel classModel;
- /**
- * Runtime type resolved after expanding type variables and wildcards.
- */
- protected Type runtimeType;
- /**
- * Type is used when field model is not present.
- * In case of root, or embedded objects such as collections.
- */
- protected Type genericType;
-
- protected final JsonbContext jsonbContext;
-
- /**
- * Crate builder.
- *
- * @param jsonbContext not null
- */
- public AbstractSerializerBuilder(JsonbContext jsonbContext) {
- Objects.requireNonNull(jsonbContext);
- this.jsonbContext = jsonbContext;
- }
-
- /**
- * Wrapper item for this item.
- * @param wrapper not null
- * @return builder instance for call chaining
- */
- public T withWrapper(CurrentItem<?> wrapper) {
- this.wrapper = wrapper;
- return (T) this;
- }
-
- /**
- * Model of a field for underlying instance. In case model is present, instance type is inferred from it.
- * @param model model of a field, not null
- * @return builder instance for call chaining
- */
- public T withModel(JsonBindingModel model) {
- this.model = model;
- return (T) this;
- }
-
- /***
- * Gets or load class model for a class an its superclasses.
- *
- * @param rawType Class to get model for
- * @return Class model
- */
- protected ClassModel getClassModel(Class<?> rawType) {
- ClassModel classModel = jsonbContext.getMappingContext().getClassModel(rawType);
- if (classModel == null) {
- classModel = jsonbContext.getMappingContext().getOrCreateClassModel(rawType);
- }
- return classModel;
- }
-
- /**
- * Wrapper item for this item.
- * @return wrapper item
- */
- public CurrentItem<?> getWrapper() {
- return wrapper;
- }
-
- /**
- * Model of a for underlying instance. In case model is present, instance type is inferred from it.
- * @return model of a field
- */
- public JsonBindingModel getModel() {
- return model;
- }
-
- /**
- * Model of a class representing current item and instance (if any).
- * Known collection classes doesn't need such a model.
- * @return model of a class
- */
- public ClassModel getClassModel() {
- return classModel;
- }
-
- /**
- * Resolved runtime type for instance in case of {@link java.lang.reflect.TypeVariable} or {@link java.lang.reflect.WildcardType}
- * Otherwise provided type in type field, or type of field model.
- * @return runtime type
- */
- public Type getRuntimeType() {
- return runtimeType;
- }
-
- /**
- * Type for underlying instance to be created from.
- * In case of type variable or wildcard, will be resolved recursively from parent items.
- *
- * @param type type of instance not null
- * @return builder instance for call chaining
- */
- public T withType(Type type) {
- this.genericType = type;
- return (T) this;
- }
-
- /**
- * Jsonb runtime context.
- *
- * @return jsonb context
- */
- public JsonbContext getJsonbContext() {
- return jsonbContext;
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/AnnotationIntrospector.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/AnnotationIntrospector.java
deleted file mode 100644
index 9a4637b..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/AnnotationIntrospector.java
+++ /dev/null
@@ -1,552 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal;
-
-import org.eclipse.persistence.json.bind.internal.adapter.AdapterBinding;
-import org.eclipse.persistence.json.bind.internal.adapter.DeserializerBinding;
-import org.eclipse.persistence.json.bind.internal.adapter.SerializerBinding;
-import org.eclipse.persistence.json.bind.internal.properties.MessageKeys;
-import org.eclipse.persistence.json.bind.internal.properties.Messages;
-import org.eclipse.persistence.json.bind.internal.serializer.JsonbDateFormatter;
-import org.eclipse.persistence.json.bind.internal.serializer.JsonbNumberFormatter;
-import org.eclipse.persistence.json.bind.model.ClassCustomization;
-import org.eclipse.persistence.json.bind.model.CustomizationBuilder;
-import org.eclipse.persistence.json.bind.model.JsonbAnnotatedElement;
-import org.eclipse.persistence.json.bind.model.JsonbCreator;
-import org.eclipse.persistence.json.bind.model.Property;
-
-import javax.json.bind.JsonbException;
-import javax.json.bind.adapter.JsonbAdapter;
-import javax.json.bind.annotation.JsonbDateFormat;
-import javax.json.bind.annotation.JsonbNillable;
-import javax.json.bind.annotation.JsonbNumberFormat;
-import javax.json.bind.annotation.JsonbProperty;
-import javax.json.bind.annotation.JsonbPropertyOrder;
-import javax.json.bind.annotation.JsonbTransient;
-import javax.json.bind.annotation.JsonbTypeAdapter;
-import javax.json.bind.annotation.JsonbTypeDeserializer;
-import javax.json.bind.annotation.JsonbTypeSerializer;
-import javax.json.bind.annotation.JsonbVisibility;
-import javax.json.bind.config.PropertyVisibilityStrategy;
-import javax.json.bind.serializer.JsonbDeserializer;
-import javax.json.bind.serializer.JsonbSerializer;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Executable;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.lang.reflect.Parameter;
-import java.time.format.DateTimeFormatter;
-import java.time.temporal.TemporalAccessor;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Queue;
-import java.util.Set;
-
-/**
- * Introspects configuration on classes and their properties by reading annotations.
- *
- * @author Roman Grigoriadi
- */
-public class AnnotationIntrospector {
-
- private final JsonbContext jsonbContext;
-
- /**
- * Creates annotation introspecting component passing {@link JsonbContext} inside.
- *
- * @param jsonbContext mandatory
- */
- public AnnotationIntrospector(JsonbContext jsonbContext) {
- Objects.requireNonNull(jsonbContext);
- this.jsonbContext = jsonbContext;
- }
-
- /**
- * Gets a name of property for JSON marshalling.
- * Can be different writeName for same property.
- * @param property property representation - field, getter, setter (not null)
- * @return read name
- */
- public String getJsonbPropertyJsonWriteName(Property property) {
- Objects.requireNonNull(property);
- return getJsonbPropertyCustomizedName(property, property.getGetterElement());
- }
-
- /**
- * Gets a name of property for JSON unmarshalling.
- * Can be different from writeName for same property.
- * @param property property representation - field, getter, setter (not null)
- * @return write name
- */
- public String getJsonbPropertyJsonReadName(Property property) {
- Objects.requireNonNull(property);
- return getJsonbPropertyCustomizedName(property, property.getSetterElement());
- }
-
- private String getJsonbPropertyCustomizedName(Property property, JsonbAnnotatedElement<Method> methodElement) {
- JsonbProperty methodAnnotation = getMethodAnnotation(JsonbProperty.class, methodElement);
- if (methodAnnotation != null && !methodAnnotation.value().isEmpty()) {
- return methodAnnotation.value();
- }
- //in case of property name getter/setter override field value
- JsonbProperty fieldAnnotation = getFieldAnnotation(JsonbProperty.class, property.getFieldElement());
- if (fieldAnnotation != null && !fieldAnnotation.value().isEmpty()) {
- return fieldAnnotation.value();
- }
-
- return null;
- }
-
-
- /**
- * Searches for JsonbCreator annotation on constructors and static methods.
- *
- * @param clazz class to search
- * @return JsonbCreator metadata object
- */
- public JsonbCreator getCreator(Class<?> clazz) {
- JsonbCreator jsonbCreator = null;
- for (Constructor<?> constructor : clazz.getDeclaredConstructors()) {
- final javax.json.bind.annotation.JsonbCreator annot = findAnnotation(constructor.getDeclaredAnnotations(), javax.json.bind.annotation.JsonbCreator.class);
- if (annot != null) {
- jsonbCreator = createJsonbCreator(constructor, jsonbCreator, clazz);
- }
- }
-
- for (Method method : clazz.getDeclaredMethods()) {
- final javax.json.bind.annotation.JsonbCreator annot = findAnnotation(method.getDeclaredAnnotations(), javax.json.bind.annotation.JsonbCreator.class);
- if (annot != null && Modifier.isStatic(method.getModifiers())) {
- if (!clazz.equals(method.getReturnType())) {
- throw new JsonbException(Messages.getMessage(MessageKeys.INCOMPATIBLE_FACTORY_CREATOR_RETURN_TYPE, method, clazz));
- }
- jsonbCreator = createJsonbCreator(method, jsonbCreator, clazz);
- }
- }
- return jsonbCreator;
- }
-
- private JsonbCreator createJsonbCreator(Executable executable, JsonbCreator existing, Class<?> clazz) {
- if (existing != null) {
- throw new JsonbException(Messages.getMessage(MessageKeys.MULTIPLE_JSONB_CREATORS, clazz));
- }
- List<String> paramNames = new ArrayList<>();
- for (Parameter param : executable.getParameters()) {
- paramNames.add(param.getName());
- }
- return new JsonbCreator(executable, paramNames.toArray(new String[paramNames.size()]));
- }
-
- /**
- * Checks for {@link JsonbAdapter} on a property.
- * @param property property not null
- * @return adapter info
- */
- public AdapterBinding getAdapterBinding(Property property) {
- Objects.requireNonNull(property);
- JsonbTypeAdapter adapterAnnotation = getAnnotationFromProperty(JsonbTypeAdapter.class, property)
- .orElseGet(()-> getAnnotationFromPropertyType(property, JsonbTypeAdapter.class));
- if (adapterAnnotation == null) {
- return null;
- }
-
- return getAdapterBindingFromAnnotation(adapterAnnotation, ReflectionUtils.getOptionalRawType(property.getPropertyType()));
- }
-
- private AdapterBinding getAdapterBindingFromAnnotation(JsonbTypeAdapter adapterAnnotation, Optional<Class<?>> expectedClass) {
- final Class<? extends JsonbAdapter> adapterClass = adapterAnnotation.value();
- final AdapterBinding adapterBinding = jsonbContext.getComponentMatcher().introspectAdapterBinding(adapterClass, null);
-
- if (expectedClass.isPresent() && !(ReflectionUtils.getRawType(adapterBinding.getBindingType()).equals(expectedClass.get()))) {
- throw new JsonbException(Messages.getMessage(MessageKeys.ADAPTER_INCOMPATIBLE, adapterBinding.getBindingType(), expectedClass.get()));
- }
- return adapterBinding;
- }
-
- /**
- * Checks for {@link JsonbDeserializer} on a property.
- * @param property property not null
- * @return adapter info
- */
- public DeserializerBinding getDeserializerBinding(Property property) {
- Objects.requireNonNull(property);
- JsonbTypeDeserializer deserializerAnnotation = getAnnotationFromProperty(JsonbTypeDeserializer.class, property)
- .orElseGet(()-> getAnnotationFromPropertyType(property, JsonbTypeDeserializer.class));
- if (deserializerAnnotation == null) {
- return null;
- }
-
- final Class<? extends JsonbDeserializer> deserializerClass = deserializerAnnotation.value();
- return jsonbContext.getComponentMatcher().introspectDeserializerBinding(deserializerClass, null);
- }
-
- /**
- * Checks for {@link JsonbSerializer} on a property.
- * @param property property not null
- * @return adapter info
- */
- public SerializerBinding getSerializerBinding(Property property) {
- Objects.requireNonNull(property);
- JsonbTypeSerializer serializerAnnotation = getAnnotationFromProperty(JsonbTypeSerializer.class, property)
- .orElseGet(()-> getAnnotationFromPropertyType(property, JsonbTypeSerializer.class));
- if (serializerAnnotation == null) {
- return null;
- }
-
- final Class<? extends JsonbSerializer> serializerClass = serializerAnnotation.value();
- return jsonbContext.getComponentMatcher().introspectSerialzierBinding(serializerClass, null);
-
- }
-
- private <T extends Annotation> T getAnnotationFromPropertyType(Property property, Class<T> annotationClass) {
- final Optional<Class<?>> optionalRawType = ReflectionUtils.getOptionalRawType(property.getPropertyType());
- if (!optionalRawType.isPresent()) {
- //TODO will not work for type variable properties, which are bound to class that is annotated.
- return null;
- }
- //TODO performance hit if class scanning is done often (jsonb is not reused)
- return findAnnotation(collectAnnotations(optionalRawType.get()).getAnnotations(), annotationClass);
- }
-
- /**
- * Checks if property is nillable.
- * Looks for {@link JsonbProperty} nillable attribute only.
- * JsonbNillable is checked only for ClassModels.
- *
- * @param property property to search in, not null
- * @return True if property should be serialized when null.
- */
- public boolean isPropertyNillable(Property property) {
- Objects.requireNonNull(property);
-
- final Optional<JsonbProperty> jsonbProperty = getAnnotationFromProperty(JsonbProperty.class, property);
- return jsonbProperty.isPresent() && jsonbProperty.get().nillable();
-
- }
-
- /**
- * Checks for JsonbNillable annotation on a class, its superclasses and interfaces.
- *
- * @param clazzElement class to search JsonbNillable in.
- * @return true if found
- */
- public boolean isClassNillable(JsonbAnnotatedElement<Class<?>> clazzElement) {
- final JsonbNillable jsonbNillable = findAnnotation(clazzElement.getAnnotations(), JsonbNillable.class);
- return jsonbNillable != null && jsonbNillable.value();
- }
-
- /**
- * Checks for {@link JsonbPropertyOrder} annotation.
- *
- * @param clazzElement class to search on
- * @return ordered properties names or null if not found
- */
- public String[] getPropertyOrder(JsonbAnnotatedElement<Class<?>> clazzElement) {
- final JsonbPropertyOrder jsonbPropertyOrder = clazzElement.getElement().getAnnotation(JsonbPropertyOrder.class);
- return jsonbPropertyOrder != null ? jsonbPropertyOrder.value() : null;
- }
-
- /**
- * Checks if property is annotated transient.
- * If JsonbTransient annotation is present on field getter or setter, and other annotation is present on either
- * of it, JsonbException is thrown with message describing collision.
- *
- * @param property not null
- * @return JsonbTransient annotation is found on field, getter of setter of a property
- */
- public boolean isTransient(Property property) {
- Objects.requireNonNull(property);
- final Optional<JsonbTransient> jsonbTransient = getAnnotationFromProperty(JsonbTransient.class, property);
- if (jsonbTransient.isPresent()) {
- final Class[] FORBIDDEN_ANNOTATIONS = new Class[]{JsonbProperty.class, JsonbNillable.class, JsonbCreator.class, JsonbDateFormat.class, JsonbNumberFormat.class, JsonbPropertyOrder.class, JsonbVisibility.class};
- for (Class annotClass : FORBIDDEN_ANNOTATIONS) {
- if (getAnnotationFromProperty(annotClass, property).isPresent()) {
- throw new JsonbException(String.format("JsonbTransient annotation collides with %s for property %s", annotClass, property.getName()));
- }
- }
- return true;
- }
- return false;
- }
-
- /**
- * Search for {@link JsonbDateFormat} annotation on java property and construct {@link JsonbDateFormatter}.
- * @param property property to search not null
- * @return formatter to use
- */
- public JsonbDateFormatter getJsonbDateFormat(Property property) {
- Objects.requireNonNull(property);
-
- final JsonbDateFormat annotation = getAnnotationFromProperty(JsonbDateFormat.class, property)
- .orElseGet(()->{
- //if property is not TypeVariable and its class is not date skip it
- final Optional<Class<?>> propertyRawTypeOptional = ReflectionUtils.getOptionalRawType(property.getPropertyType());
- if (propertyRawTypeOptional.isPresent()) {
- Class<?> rawType = propertyRawTypeOptional.get();
- if (!(Date.class.isAssignableFrom(rawType) || Calendar.class.isAssignableFrom(rawType)
- || TemporalAccessor.class.isAssignableFrom(rawType))) {
- return null;
- }
- }
- return findAnnotation(property.getDeclaringClassElement().getAnnotations(), JsonbDateFormat.class);
- });
- if (annotation == null) {
- return null;
- }
-
- return createJsonbDateFormatter(annotation.value(), annotation.locale(), property);
- }
-
- /**
- * Search for {@link JsonbDateFormat} annotation on java class and construct {@link JsonbDateFormatter}.
- * If not found looks at annotations declared on property type class.
- * @param clazzElement class to search not null
- * @return formatter to use
- */
- public JsonbDateFormatter getJsonbDateFormat(JsonbAnnotatedElement<Class<?>> clazzElement) {
- Objects.requireNonNull(clazzElement);
- final JsonbDateFormat format = findAnnotation(clazzElement.getAnnotations(), JsonbDateFormat.class);
- if (format == null) {
- return null;
- }
- return new JsonbDateFormatter(format.value(), format.locale());
- }
-
- /**
- * Search for {@link JsonbNumberFormat} annotation on java class.
- *
- * @param clazzElement class to search not null
- * @return formatter to use
- */
- public JsonbNumberFormatter getJsonbNumberFormat(JsonbAnnotatedElement<Class<?>> clazzElement) {
- final JsonbNumberFormat formatAnnotation = findAnnotation(clazzElement.getAnnotations(), JsonbNumberFormat.class);
- if (formatAnnotation == null) {
- return null;
- }
- return new JsonbNumberFormatter(formatAnnotation.value(), formatAnnotation.locale());
- }
-
- /**
- * Search {@link JsonbNumberFormat} on property, if not found looks at annotations declared on property type class.
- * @param property
- * @return
- */
- public JsonbNumberFormatter getJsonbNumberFormat(Property property) {
- final JsonbNumberFormat annotation = getAnnotationFromProperty(JsonbNumberFormat.class, property)
- .orElseGet(()->{
- //if property is not TypeVariable and its class is not number skip it
- final Optional<Class<?>> propertyRawTypeOptional = ReflectionUtils.getOptionalRawType(property.getPropertyType());
- if (propertyRawTypeOptional.isPresent()) {
- Class<?> rawType = propertyRawTypeOptional.get();
- if (!Number.class.isAssignableFrom(rawType)) {
- return null;
- }
- }
- return findAnnotation(property.getDeclaringClassElement().getAnnotations(), JsonbNumberFormat.class);
- });
-
- if (annotation == null) {
- return null;
- }
- return new JsonbNumberFormatter(annotation.value(), annotation.locale());
- }
-
- /**
- * Creates {@link JsonbDateFormatter} caches formatter instance if possible.
- * For DEFAULT_FORMAT appropriate singleton instances from java.time.format.DateTimeFormatter
- * are used in date converters.
- */
- private JsonbDateFormatter createJsonbDateFormatter(String format, String locale, Property property) {
- if (JsonbDateFormat.TIME_IN_MILLIS.equals(format) || JsonbDateFormat.DEFAULT_FORMAT.equals(format)) {
- //for epochMillis formatter is not used, for default format singleton instances of DateTimeFormatter
- //are used in the converters
- return new JsonbDateFormatter(format, locale);
- }
-
- final Optional<Class<?>> optionalRawType = ReflectionUtils.getOptionalRawType(property.getPropertyType());
-
- //Can't resolve date type if it is declared as generic type var
- if (!optionalRawType.isPresent()) {
- return new JsonbDateFormatter(DateTimeFormatter.ofPattern(format, Locale.forLanguageTag(locale)), format, locale);
- }
-
- final Class<?> propertyRawType = optionalRawType.get();
-
- //Calendar and dates
- if (Date.class.isAssignableFrom(propertyRawType) || Calendar.class.isAssignableFrom(propertyRawType)) {
- return new JsonbDateFormatter(format, locale);
- }
-
- if (!TemporalAccessor.class.isAssignableFrom(propertyRawType)) {
- throw new IllegalStateException(Messages.getMessage(MessageKeys.UNSUPPORTED_DATE_TYPE, propertyRawType));
- }
- return new JsonbDateFormatter(DateTimeFormatter.ofPattern(format, Locale.forLanguageTag(locale)), format, locale);
- }
-
- /**
- * Get a @JsonbVisibility annotation from a class or its package.
- * @param clazz Class to lookup annotation
- * @return Instantiated PropertyVisibilityStrategy if annotation is present
- */
- public Optional<PropertyVisibilityStrategy> getPropertyVisibilityStrategy(Class<?> clazz) {
- JsonbVisibility visibilityAnnotation = findAnnotation(clazz.getDeclaredAnnotations(), JsonbVisibility.class);
- if (visibilityAnnotation == null) {
- visibilityAnnotation = findAnnotation(clazz.getPackage().getDeclaredAnnotations(), JsonbVisibility.class);
- }
- final Optional<JsonbVisibility> visibilityOptional = Optional.ofNullable(visibilityAnnotation);
- return visibilityOptional.map(jsonbVisibility -> ReflectionUtils.createNoArgConstructorInstance(jsonbVisibility.value()));
- }
-
- /**
- * Gets an annotation from first resolved annotation in a property in this order:
- * <p>1. Field, 2. Getter, 3 Setter.</p>
- * First found overrides other.
- *
- * @param annotationClass Annotation class to search for
- * @param property property to search in
- * @param <T> Annotation type
- * @return Annotation if found, null otherwise
- */
- private <T extends Annotation> Optional<T> getAnnotationFromProperty(Class<T> annotationClass, Property property) {
- T fieldAnnotation = getFieldAnnotation(annotationClass, property.getFieldElement());
- if (fieldAnnotation != null) {
- return Optional.of(fieldAnnotation);
- }
-
- T getterAnnotation = getMethodAnnotation(annotationClass, property.getGetterElement());
- if (getterAnnotation != null) {
- return Optional.of(getterAnnotation);
- }
-
- T setterAnnotation = getMethodAnnotation(annotationClass, property.getSetterElement());
- if (setterAnnotation != null) {
- return Optional.of(setterAnnotation);
- }
-
- return Optional.empty();
- }
-
-
- private <T extends Annotation> T getFieldAnnotation(Class<T> annotationClass, JsonbAnnotatedElement<Field> fieldElement) {
- if (fieldElement == null) {
- return null;
- }
- return findAnnotation(fieldElement.getAnnotations(), annotationClass);
- }
-
- private <T extends Annotation> T findAnnotation(Annotation[] declaredAnnotations, Class<T> annotationClass) {
- return findAnnotation(declaredAnnotations, annotationClass, new HashSet<>());
- }
-
- /**
- * Searches for annotation, collects processed, to avoid StackOverflow.
- */
- private <T extends Annotation> T findAnnotation(Annotation[] declaredAnnotations, Class<T> annotationClass, Set<Annotation> processed) {
- for (Annotation candidate : declaredAnnotations) {
- final Class<? extends Annotation> annType = candidate.annotationType();
- if (annType.equals(annotationClass)) {
- return (T) candidate;
- }
- processed.add(candidate);
- final List<Annotation> inheritedAnnotations = new ArrayList<>(Arrays.asList(annType.getDeclaredAnnotations()));
- inheritedAnnotations.removeAll(processed);
- if (inheritedAnnotations.size() > 0) {
- final T inherited = findAnnotation(inheritedAnnotations.toArray(new Annotation[inheritedAnnotations.size()]), annotationClass, processed);
- if (inherited != null) {
- return inherited;
- }
- }
- }
- return null;
- }
-
- private <T extends Annotation> T getMethodAnnotation(Class<T> annotationClass, JsonbAnnotatedElement<Method> methodElement) {
- if (methodElement == null) {
- return null;
- }
- return findAnnotation(methodElement.getAnnotations(), annotationClass);
- }
-
- private <T extends Annotation> void collectFromInterfaces(Class<T> annotationClass, Class clazz, Map<Class<?>, T> collectedAnnotations) {
-
- for (Class<?> interfaceClass : clazz.getInterfaces()) {
- T annotation = findAnnotation(interfaceClass.getDeclaredAnnotations(), annotationClass);
- if (annotation != null) {
- collectedAnnotations.put(interfaceClass, annotation);
- }
- collectFromInterfaces(annotationClass, interfaceClass, collectedAnnotations);
- }
- }
-
- /**
- * Get class interfaces recursively.
- */
- public Set<Class<?>> collectInterfaces(Class<?> cls) {
- Set<Class<?>> collected = new LinkedHashSet<>();
- Queue<Class<?>> toScan = new LinkedList<>();
- toScan.addAll(Arrays.asList(cls.getInterfaces()));
- Class<?> nextIfc;
- while((nextIfc = toScan.poll()) != null) {
- collected.add(nextIfc);
- toScan.addAll(Arrays.asList(nextIfc.getInterfaces()));
- }
- return collected;
- }
-
- public ClassCustomization introspectCustomization(JsonbAnnotatedElement<Class<?>> clsElement) {
- final CustomizationBuilder builder = new CustomizationBuilder();
- builder.setNillable(isClassNillable(clsElement));
- builder.setDateFormatter(getJsonbDateFormat(clsElement));
- builder.setNumberFormat(getJsonbNumberFormat(clsElement));
- builder.setCreator(getCreator(clsElement.getElement()));
- builder.setPropertyOrder(getPropertyOrder(clsElement));
- return builder.buildClassCustomization();
- }
-
- /**
- * Collect annotations of a class and its interfaces.
- * @return element with class and annotations
- */
- public JsonbAnnotatedElement<Class<?>> collectAnnotations(Class<?> clazz) {
- JsonbAnnotatedElement<Class<?>> classElement = new JsonbAnnotatedElement<>(clazz);
-
- for (Class<?> ifc : collectInterfaces(clazz)) {
- addIfNotPresent(classElement, ifc.getDeclaredAnnotations());
- }
-
- if (!clazz.isPrimitive() && !clazz.isArray()) {
- addIfNotPresent(classElement, clazz.getPackage().getAnnotations());
- }
- return classElement;
- }
-
- private void addIfNotPresent(JsonbAnnotatedElement<?> element, Annotation... annotations) {
- for (Annotation annotation : annotations) {
- if (element.getAnnotation(annotation.annotationType()) == null) {
- element.putAnnotation(annotation);
- }
- }
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/ClassInterfacesVisitor.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/ClassInterfacesVisitor.java
deleted file mode 100644
index c704d26..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/ClassInterfacesVisitor.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal;
-
-import java.util.Objects;
-import java.util.function.Consumer;
-
-/**
- * Visits the class interfaces and its superinterfaces.
- *
- * @author Roman Grigoriadi
- */
-public class ClassInterfacesVisitor {
-
- private final Consumer<Class<?>> consumer;
-
- public ClassInterfacesVisitor(Consumer<Class<?>> consumer) {
- this.consumer = consumer;
- }
-
- public void visitClass(Class<?> clazz) {
- Objects.requireNonNull(clazz);
- for (Class iface : clazz.getInterfaces()) {
- consumer.accept(iface);
- visitClass(iface);
- }
-
- }
-
-
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/ClassParser.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/ClassParser.java
deleted file mode 100644
index 10e400f..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/ClassParser.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Dmitry Kornilov - initial implementation
- ******************************************************************************/
-package org.eclipse.persistence.json.bind.internal;
-
-import org.eclipse.persistence.json.bind.model.ClassModel;
-import org.eclipse.persistence.json.bind.model.JsonbAnnotatedElement;
-import org.eclipse.persistence.json.bind.model.Property;
-import org.eclipse.persistence.json.bind.model.PropertyModel;
-
-import javax.json.bind.JsonbException;
-import javax.json.bind.config.PropertyNamingStrategy;
-import java.beans.Introspector;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-
-/**
- * Created a class internal model.
- *
- * @author Dmitry Kornilov
- */
-class ClassParser {
-
- public static final String IS_PREFIX = "is";
-
- public static final String GET_PREFIX = "get";
-
- public static final String SET_PREFIX = "set";
-
- public static final String GENERATED_PREFIX = "this$";
-
- private final JsonbContext jsonbContext;
-
- ClassParser(JsonbContext jsonbContext) {
- this.jsonbContext = jsonbContext;
- }
-
- /**
- * Parse class fields and getters setters. Merge to java bean like properties.
- *
- * @return model of a class
- */
- public void parseProperties(ClassModel classModel, JsonbAnnotatedElement<Class<?>> classElement) {
-
- final Map<String, Property> classProperties = new HashMap<>();
- parseFields(classElement, classProperties);
- parseClassAndInterfaceMethods(classElement, classProperties);
-
- final List<PropertyModel> sortedProperties = new ArrayList<>();
-
- final ClassModel parentClassModel = classModel.getParentClassModel();
- if (parentClassModel != null) {
- for (PropertyModel parentProp : parentClassModel.getSortedProperties()) {
- //don't replace overridden properties
- if (!classProperties.containsKey(parentProp.getPropertyName())) {
- sortedProperties.add(parentProp);
- }
- }
- }
-
- Map<String, PropertyModel> unsorted = new HashMap<>();
- for (Map.Entry<String, Property> entry : classProperties.entrySet()) {
- unsorted.put(entry.getKey(), new PropertyModel(classModel, entry.getValue(), jsonbContext));
- }
-
- sortedProperties.addAll(jsonbContext.getPropertyOrdering().orderProperties(unsorted, classModel));
-
- checkPropertyNameClash(sortedProperties, classModel.getType());
- classModel.setProperties(sortedProperties);
-
- }
-
- private void parseClassAndInterfaceMethods(JsonbAnnotatedElement<Class<?>> classElement, Map<String, Property> classProperties) {
- Class<?> concreteClass = classElement.getElement();
- parseMethods(concreteClass, classElement, classProperties);
- for (Class<?> ifc : jsonbContext.getAnnotationIntrospector().collectInterfaces(concreteClass)) {
- parseIfaceMethodAnnotations(ifc, classProperties);
- }
- }
-
- private void parseIfaceMethodAnnotations(Class<?> ifc, Map<String, Property> classProperties) {
- for(Method method : ifc.getDeclaredMethods()) {
- final String methodName = method.getName();
- if (!isPropertyMethod(methodName)) {
- continue;
- }
- String propertyName = toPropertyMethod(methodName);
- final Property property = classProperties.get(propertyName);
- if (property == null) {
- //May happen for classes which both extend a class with some method and implement interface with same method.
- continue;
- }
- JsonbAnnotatedElement<Method> methodElement = isGetter(methodName) ?
- property.getGetterElement() : property.getSetterElement();
- //Only push iface annotations if not overridden on impl classes
- for (Annotation ann : method.getDeclaredAnnotations()) {
- if (methodElement.getAnnotation(ann.annotationType()) == null) {
- methodElement.putAnnotation(ann);
- }
- }
- }
- }
-
- private void parseMethods(Class<?> clazz, JsonbAnnotatedElement<Class<?>> classElement, Map<String, Property> classProperties) {
- for (Method method : clazz.getDeclaredMethods()) {
- String name = method.getName();
- if (!isPropertyMethod(name)) {
- continue;
- }
- final String propertyName = toPropertyMethod(name);
-
- Property property = classProperties.get(propertyName);
- if (property == null) {
- property= new Property(propertyName, classElement);
- classProperties.put(propertyName, property);
- }
-
- if (isSetter(name)) {
- property.setSetter(method);
- } else {
- property.setGetter(method);
- }
- }
- }
-
- private boolean isGetter(String methodName) {
- return methodName.startsWith(GET_PREFIX) || methodName.startsWith(IS_PREFIX);
- }
-
- private boolean isSetter(String methodName) {
- return methodName.startsWith(SET_PREFIX);
- }
-
- private String toPropertyMethod(String name) {
- return Introspector.decapitalize(name.substring(name.startsWith(IS_PREFIX) ? 2 : 3, name.length()));
- }
-
- private boolean isPropertyMethod(String name) {
- return name.startsWith(GET_PREFIX) || name.startsWith(SET_PREFIX) || name.startsWith(IS_PREFIX);
- }
-
- private void parseFields(JsonbAnnotatedElement<Class<?>> classElement, Map<String, Property> classProperties) {
- for (Field field : classElement.getElement().getDeclaredFields()) {
- final String name = field.getName();
- if (field.getName().startsWith(GENERATED_PREFIX)) {
- continue;
- }
- final Property property = new Property(name, classElement);
- property.setField(field);
- classProperties.put(name, property);
- }
- }
-
- private void checkPropertyNameClash(List<PropertyModel> collectedProperties, Class cls) {
- final List<PropertyModel> checkedProperties = new ArrayList<>();
- for (PropertyModel collectedPropertyModel : collectedProperties) {
- for (PropertyModel checkedPropertyModel : checkedProperties) {
-
- if (checkedPropertyModel.getReadName().equals(collectedPropertyModel.getReadName()) ||
- checkedPropertyModel.getWriteName().equals(collectedPropertyModel.getWriteName())) {
- throw new JsonbException(String.format("Property %s clashes with property %s by read or write name in class %s.",
- checkedPropertyModel.getPropertyName(), collectedPropertyModel.getPropertyName(), cls.getName()));
- }
- }
- checkedProperties.add(collectedPropertyModel);
- }
- }
-
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/ComponentMatcher.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/ComponentMatcher.java
deleted file mode 100644
index 0f20779..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/ComponentMatcher.java
+++ /dev/null
@@ -1,326 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal;
-
-import org.eclipse.persistence.json.bind.internal.adapter.AbstractComponentBinding;
-import org.eclipse.persistence.json.bind.internal.adapter.AdapterBinding;
-import org.eclipse.persistence.json.bind.internal.adapter.ComponentBindings;
-import org.eclipse.persistence.json.bind.internal.adapter.DeserializerBinding;
-import org.eclipse.persistence.json.bind.internal.adapter.SerializerBinding;
-import org.eclipse.persistence.json.bind.internal.serializer.JsonbDateFormatter;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-import org.eclipse.persistence.json.bind.model.PropertyModel;
-import org.eclipse.persistence.json.bind.model.TypeWrapper;
-
-import javax.json.bind.JsonbConfig;
-import javax.json.bind.adapter.JsonbAdapter;
-import javax.json.bind.serializer.JsonbDeserializer;
-import javax.json.bind.serializer.JsonbSerializer;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-/**
- * Searches for a registered adapter or Serializer for a given type.
- *
- * @author Roman Grigoriadi
- */
-public class ComponentMatcher {
-
- private final JsonbContext jsonbContext;
-
- /**
- * Supplier for component binging.
- * @param <T> component binding class
- */
- private interface ComponentSupplier<T extends AbstractComponentBinding> {
-
- T getComponent(ComponentBindings componentBindings);
- }
-
- private final ConcurrentMap<Type, ComponentBindings> userComponents;
-
- /**
- * Create component matcher.
- * @param context mandatory
- */
- ComponentMatcher(JsonbContext context) {
- Objects.requireNonNull(context);
- this.jsonbContext = context;
- userComponents = new ConcurrentHashMap<>();
- init();
- }
-
- /**
- * Called during context creation, introspecting user components provided with JsonbConfig.
- */
- void init() {
- final JsonbSerializer<?>[] serializers = (JsonbSerializer<?>[])jsonbContext.getConfig().getProperty(JsonbConfig.SERIALIZERS).orElseGet(()->new JsonbSerializer<?>[]{});
- for (JsonbSerializer serializer : serializers) {
- introspectSerialzierBinding(serializer.getClass(), serializer);
- }
- final JsonbDeserializer<?>[] deserializers = (JsonbDeserializer<?>[])jsonbContext.getConfig().getProperty(JsonbConfig.DESERIALIZERS).orElseGet(()->new JsonbDeserializer<?>[]{});
- for (JsonbDeserializer deserializer : deserializers) {
- introspectDeserializerBinding(deserializer.getClass(), deserializer);
- }
-
- final JsonbAdapter<?, ?>[] adapters = (JsonbAdapter<?, ?>[]) jsonbContext.getConfig().getProperty(JsonbConfig.ADAPTERS).orElseGet(()->new JsonbAdapter<?, ?>[]{});
- for (JsonbAdapter<?, ?> adapter : adapters) {
- introspectAdapterBinding(adapter.getClass(), adapter);
- }
- }
-
- private ComponentBindings getBindingInfo(Type type) {
- return userComponents.compute(type, (type1, bindingInfo) -> bindingInfo != null ? bindingInfo : new ComponentBindings(type1));
- }
-
- private void addSeserializer(Type bindingType, SerializerBinding serializer) {
- userComponents.computeIfPresent(bindingType, (type, bindings) -> {
- if (bindings.getSerializer() != null) {
- return bindings;
- }
- registerGeneric(bindingType);
- return new ComponentBindings(bindingType, serializer, bindings.getDeserializer(), bindings.getAdapterInfo());
- });
- }
-
- private void addDeserializer(Type bindingType, DeserializerBinding deserializer) {
- userComponents.computeIfPresent(bindingType, (type, bindings) -> {
- if (bindings.getDeserializer() != null) {
- return bindings;
- }
- registerGeneric(bindingType);
- return new ComponentBindings(bindingType, bindings.getSerializer(), deserializer, bindings.getAdapterInfo());
- });
- }
-
- private void addApapter(Type bindingType, AdapterBinding adapter) {
- userComponents.computeIfPresent(bindingType, (type, bindings) -> {
- if (bindings.getAdapterInfo() != null) {
- return bindings;
- }
- registerGeneric(bindingType);
- return new ComponentBindings(bindingType, bindings.getSerializer(), bindings.getDeserializer(), adapter);
- });
- }
-
- /**
- * If type is not parametrized runtime component resolution doesn't has to happen.
- *
- * @param bindingType component binding type
- * @return true if parameterized
- */
- private void registerGeneric(Type bindingType) {
- if (bindingType instanceof ParameterizedType && !jsonbContext.genericComponentsPresent()) {
- jsonbContext.registerGenericComponentFlag();
- }
- }
-
- /**
- * Lookup serializer binding for a given property runtime type.
- * @param propertyRuntimeType runtime type of a property
- * @param propertyModel model of a property
- * @return serializer optional
- */
- @SuppressWarnings("unchecked")
- public Optional<SerializerBinding<?>> getSerialzierBinding(Type propertyRuntimeType, JsonBindingModel propertyModel) {
- if (propertyModel == null || propertyModel.getCustomization() == null || propertyModel.getCustomization().getSerializerBinding() == null) {
- return searchComponentBinding(propertyRuntimeType, ComponentBindings::getSerializer);
- }
- return getComponentBinding(propertyRuntimeType, propertyModel.getCustomization().getSerializerBinding());
- }
-
- /**
- * Lookup deserializer binding for a given property runtime type.
- * @param propertyRuntimeType runtime type of a property
- * @param model model of a property
- * @return serializer optional
- */
- @SuppressWarnings("unchecked")
- public Optional<DeserializerBinding<?>> getDeserialzierBinding(Type propertyRuntimeType, JsonBindingModel model) {
- if (model == null || model.getCustomization().getDeserializerBinding() == null) {
- return searchComponentBinding(propertyRuntimeType, ComponentBindings::getDeserializer);
- }
- return getComponentBinding(propertyRuntimeType, model.getCustomization().getDeserializerBinding());
- }
-
- /**
- * Get adapter from property model (if declared by annotation and runtime type matches),
- * or return adapter searched by runtime type
- *
- * @param propertyRuntimeType runtime type not null
- * @param model model nullable
- * @return adapter info if present
- */
- public Optional<AdapterBinding> getAdapterBinding(Type propertyRuntimeType, JsonBindingModel model) {
- //TODO do we need type wrapper adapters at all? Make better check or remove.
- if (model != null && model instanceof PropertyModel && ((PropertyModel) model).getClassModel().getType() == TypeWrapper.class) {
- return Optional.empty();
- }
- if (model == null || model.getCustomization() == null || model.getCustomization().getAdapterBinding() == null) {
- return searchComponentBinding(propertyRuntimeType, ComponentBindings::getAdapterInfo);
- }
- return getComponentBinding(propertyRuntimeType, model.getCustomization().getAdapterBinding());
- }
-
- private <T extends AbstractComponentBinding> Optional<T> getComponentBinding(Type propertyRuntimeType, T componentBinding) {
- //need runtime check, ParameterizedType property may have generic adapter assigned which is not compatible
- //for given runtime type
- if (matches(propertyRuntimeType, componentBinding.getBindingType())) {
- return Optional.of(componentBinding);
- }
- return Optional.empty();
- }
-
- private <T extends AbstractComponentBinding> Optional<T> searchComponentBinding(Type runtimeType, ComponentSupplier<T> supplier) {
- for (ComponentBindings componentBindings : userComponents.values()) {
- final T component = supplier.getComponent(componentBindings);
- if (component != null && matches(runtimeType, componentBindings.getBindingType())) {
- return Optional.of(component);
- }
- }
- return Optional.empty();
- }
-
- private boolean matches(Type runtimeType, Type componentBindingType) {
- if (componentBindingType.equals(runtimeType)) {
- return true;
- }
- //don't try to runtime generic scan if not needed
- if (!jsonbContext.genericComponentsPresent()) {
- return false;
- }
- if (componentBindingType instanceof Class && runtimeType instanceof Class) {
- //for polymorphic adapters
- return ((Class<?>) componentBindingType).isAssignableFrom((Class) runtimeType);
- }
- return runtimeType instanceof ParameterizedType && componentBindingType instanceof ParameterizedType &&
- ReflectionUtils.getRawType(runtimeType) == ReflectionUtils.getRawType(componentBindingType) &&
- matchTypeArguments((ParameterizedType) runtimeType, (ParameterizedType) componentBindingType);
- }
-
- /**
- * If runtimeType to adapt is a ParametrizedType, check all type args to match against adapter args.
- */
- private boolean matchTypeArguments(ParameterizedType requiredType, ParameterizedType componentBound) {
- final Type[] requiredTypeArguments = requiredType.getActualTypeArguments();
- final Type[] adapterBoundTypeArguments = componentBound.getActualTypeArguments();
- if (requiredTypeArguments.length != adapterBoundTypeArguments.length) {
- return false;
- }
- for(int i = 0; i< requiredTypeArguments.length; i++) {
- Type adapterTypeArgument = adapterBoundTypeArguments[i];
- if (!requiredTypeArguments[i].equals(adapterTypeArgument)) {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Introspect adapter generic information and put resolved types into metadata wrapper.
- *
- * @param adapterClass class of an adapter
- * @param instance adapter instance
- * @return introspected info with resolved typevar types.
- */
- AdapterBinding introspectAdapterBinding(Class<? extends JsonbAdapter> adapterClass, JsonbAdapter instance) {
- final ParameterizedType adapterRuntimeType = ReflectionUtils.findParameterizedType(adapterClass, JsonbAdapter.class);
- final Type[] adapterTypeArguments = adapterRuntimeType.getActualTypeArguments();
- Type adaptFromType = resolveTypeArg(adapterTypeArguments[0], adapterClass);
- Type adaptToType = resolveTypeArg(adapterTypeArguments[1], adapterClass);
- final ComponentBindings componentBindings = getBindingInfo(adaptFromType);
- if (componentBindings.getAdapterInfo() != null && componentBindings.getAdapterInfo().getAdapter().getClass().equals(adapterClass)) {
- return componentBindings.getAdapterInfo();
- }
- JsonbAdapter newAdapter = instance != null ? instance : jsonbContext.getComponentInstanceCreator().getOrCreateComponent(adapterClass);
- final AdapterBinding adapterInfo = new AdapterBinding(adaptFromType, adaptToType, newAdapter);
- addApapter(adaptFromType, adapterInfo);
- return adapterInfo;
- }
-
- /**
- * If an instance of deserializerClass is present in context and is bound for same type, return that instance.
- * Otherwise create new instance and set it to context.
- *
- * @param deserializerClass class of deserialzier
- * @param instance instance to use if not cached already
- * @return wrapper used in property models
- */
- DeserializerBinding introspectDeserializerBinding(Class<? extends JsonbDeserializer> deserializerClass, JsonbDeserializer instance) {
- final ParameterizedType deserializerRuntimeType = ReflectionUtils.findParameterizedType(deserializerClass, JsonbDeserializer.class);
- Type deserBindingType = resolveTypeArg(deserializerRuntimeType.getActualTypeArguments()[0], deserializerClass.getClass());
- final ComponentBindings componentBindings = getBindingInfo(deserBindingType);
- if (componentBindings.getDeserializer() != null && componentBindings.getDeserializer().getClass().equals(deserializerClass)) {
- return componentBindings.getDeserializer();
- } else {
- JsonbDeserializer deserializer = instance != null ? instance : jsonbContext.getComponentInstanceCreator()
- .getOrCreateComponent(deserializerClass);
- final DeserializerBinding deserializerBinding = new DeserializerBinding(deserBindingType, deserializer);
- addDeserializer(deserBindingType, deserializerBinding);
- return deserializerBinding;
- }
- }
-
- /**
- * If an instance of serializerClass is present in context and is bound for same type, return that instance.
- * Otherwise create new instance and set it to context.
- *
- * @param serializerClass class of deserialzier
- * @param instance instance to use if not cached
- * @return wrapper used in property models
- */
- SerializerBinding introspectSerialzierBinding(Class<? extends JsonbSerializer> serializerClass, JsonbSerializer instance) {
- final ParameterizedType serializerRuntimeType = ReflectionUtils.findParameterizedType(serializerClass, JsonbSerializer.class);
- Type serBindingType = resolveTypeArg(serializerRuntimeType.getActualTypeArguments()[0], serializerClass.getClass());
- final ComponentBindings componentBindings = getBindingInfo(serBindingType);
- if (componentBindings.getSerializer() != null && componentBindings.getSerializer().getClass().equals(serializerClass)) {
- return componentBindings.getSerializer();
- } else {
- JsonbSerializer serializer = instance != null ? instance : jsonbContext.getComponentInstanceCreator()
- .getOrCreateComponent(serializerClass);
- final SerializerBinding serializerBinding = new SerializerBinding(serBindingType, serializer);
- addSeserializer(serBindingType, serializerBinding);
- return serializerBinding;
- }
-
- }
-
-
- private Type resolveTypeArg(Type adapterTypeArg, Type adapterType) {
- if(adapterTypeArg instanceof ParameterizedType) {
- return ReflectionUtils.resolveTypeArguments((ParameterizedType) adapterTypeArg, adapterType);
- } else if (adapterTypeArg instanceof TypeVariable) {
- return ReflectionUtils.resolveItemVariableType(new RuntimeTypeHolder(null, adapterType), (TypeVariable<?>) adapterTypeArg);
- } else {
- return adapterTypeArg;
- }
- }
-
- /**
- * Resolves date formatter either from model or global config.
- * @param model model of processed value (field or collection item)
- * @return formatter
- */
- public JsonbDateFormatter getDateFormatter(JsonBindingModel model) {
- if (model == null || model.getCustomization() == null || model.getCustomization().getDateTimeFormatter() == null) {
- return jsonbContext.getConfigDateFormatter();
- }
- return model.getCustomization().getDateTimeFormatter();
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/JsonBinding.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/JsonBinding.java
deleted file mode 100644
index d0a4ccc..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/JsonBinding.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-package org.eclipse.persistence.json.bind.internal;
-
-import org.eclipse.persistence.json.bind.internal.cdi.JsonbComponentInstanceCreatorFactory;
-import org.eclipse.persistence.json.bind.internal.properties.MessageKeys;
-import org.eclipse.persistence.json.bind.internal.properties.Messages;
-
-import javax.json.bind.Jsonb;
-import javax.json.bind.JsonbConfig;
-import javax.json.bind.JsonbException;
-import javax.json.spi.JsonProvider;
-import javax.json.stream.JsonGenerator;
-import javax.json.stream.JsonParser;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.Reader;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.io.Writer;
-import java.lang.reflect.Type;
-import java.nio.charset.Charset;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Optional;
-
-/**
- * Implementation of Jsonb interface.
- *
- * @author Dmitry Kornilov
- */
-public class JsonBinding implements Jsonb {
-
- private final JsonbContext jsonbContext;
-
- JsonBinding(JsonBindingBuilder builder) {
- this.jsonbContext = new JsonbContext(builder.getConfig(), builder.getProvider().orElseGet(JsonProvider::provider));
- }
-
- private <T> T deserialize(final Type type, final JsonParser parser, final Unmarshaller unmarshaller) {
- return unmarshaller.deserialize(type, parser);
- }
-
- @Override
- public <T> T fromJson(String str, Class<T> type) throws JsonbException {
- final JsonParser parser = new JsonbRiParser(jsonbContext.getJsonProvider().createParser(new StringReader(str)));
- final Unmarshaller unmarshaller = new Unmarshaller(jsonbContext);
- return deserialize(type, parser, unmarshaller);
- }
-
- @Override
- public <T> T fromJson(String str, Type type) throws JsonbException {
- JsonParser parser = new JsonbRiParser(jsonbContext.getJsonProvider().createParser(new StringReader(str)));
- Unmarshaller unmarshaller = new Unmarshaller(jsonbContext);
- return deserialize(type, parser, unmarshaller);
- }
-
- @Override
- public <T> T fromJson(Reader reader, Class<T> type) throws JsonbException {
- JsonParser parser = new JsonbRiParser(jsonbContext.getJsonProvider().createParser(reader));
- Unmarshaller unmarshaller = new Unmarshaller(jsonbContext);
- return deserialize(type, parser, unmarshaller);
- }
-
- @Override
- public <T> T fromJson(Reader reader, Type type) throws JsonbException {
- JsonParser parser = new JsonbRiParser(jsonbContext.getJsonProvider().createParser(reader));
- Unmarshaller unmarshaller = new Unmarshaller(jsonbContext);
- return deserialize(type, parser, unmarshaller);
- }
-
- @Override
- public <T> T fromJson(InputStream stream, Class<T> clazz) throws JsonbException {
- Unmarshaller unmarshaller = new Unmarshaller(jsonbContext);
- return deserialize(clazz, inputStreamParser(stream), unmarshaller);
- }
-
- @Override
- public <T> T fromJson(InputStream stream, Type type) throws JsonbException {
- Unmarshaller unmarshaller = new Unmarshaller(jsonbContext);
- return deserialize(type, inputStreamParser(stream), unmarshaller);
- }
-
- private JsonParser inputStreamParser(InputStream stream) {
- return new JsonbRiParser(jsonbContext.getJsonProvider().createParserFactory(createJsonpProperties(jsonbContext.getConfig()))
- .createParser(stream,
- Charset.forName((String) jsonbContext.getConfig().getProperty(JsonbConfig.ENCODING).orElse("UTF-8"))));
- }
-
- @Override
- public String toJson(Object object) throws JsonbException {
- StringWriter writer = new StringWriter();
- final JsonGenerator generator = writerGenerator(writer);
- new Marshaller(jsonbContext).marshall(object, generator);
- return writer.toString();
- }
-
- @Override
- public String toJson(Object object, Type type) throws JsonbException {
- StringWriter writer = new StringWriter();
- final JsonGenerator generator = writerGenerator(writer);
- new Marshaller(jsonbContext, type).marshall(object, generator);
- return writer.toString();
- }
-
- @Override
- public void toJson(Object object, Writer writer) throws JsonbException {
- final Marshaller marshaller = new Marshaller(jsonbContext);
- marshaller.marshall(object, writerGenerator(writer));
- }
-
- @Override
- public void toJson(Object object, Type type, Writer writer) throws JsonbException {
- final Marshaller marshaller = new Marshaller(jsonbContext, type);
- marshaller.marshall(object, writerGenerator(writer));
- }
-
- private JsonGenerator writerGenerator(Writer writer) {
- Map<String, ?> factoryProperties = createJsonpProperties(jsonbContext.getConfig());
- if (factoryProperties.isEmpty()) {
- return jsonbContext.getJsonProvider().createGenerator(writer);
- }
- return jsonbContext.getJsonProvider().createGeneratorFactory(factoryProperties).createGenerator(writer);
- }
-
- @Override
- public void toJson(Object object, OutputStream stream) throws JsonbException {
- final Marshaller marshaller = new Marshaller(jsonbContext);
- marshaller.marshall(object, streamGenerator(stream));
- }
-
- @Override
- public void toJson(Object object, Type type, OutputStream stream) throws JsonbException {
- final Marshaller marshaller = new Marshaller(jsonbContext, type);
- marshaller.marshall(object, streamGenerator(stream));
- }
-
- private JsonGenerator streamGenerator(OutputStream stream) {
- Map<String, ?> factoryProperties = createJsonpProperties(jsonbContext.getConfig());
- final String encoding = (String) jsonbContext.getConfig().getProperty(JsonbConfig.ENCODING).orElse("UTF-8");
- return jsonbContext.getJsonProvider().createGeneratorFactory(factoryProperties).createGenerator(stream, Charset.forName(encoding));
- }
-
- @Override
- public void close() throws Exception {
- jsonbContext.getComponentInstanceCreator().close();
- }
-
- /**
- * Propagates properties from JsonbConfig to JSONP generator / parser factories.
- *
- * @param jsonbConfig jsonb config
- * @return properties for JSONP generator / parser
- */
- protected Map<String, ?> createJsonpProperties(JsonbConfig jsonbConfig) {
- //JSONP 1.0 actually ignores the value, just checks the key is present. Only set if JsonbConfig.FORMATTING is true.
- final Optional<Object> property = jsonbConfig.getProperty(JsonbConfig.FORMATTING);
- final Map<String, Object> factoryProperties = new HashMap<>();
- if (property.isPresent()) {
- final Object value = property.get();
- if (!(value instanceof Boolean)) {
- throw new JsonbException(Messages.getMessage(MessageKeys.JSONB_CONFIG_FORMATTING_ILLEGAL_VALUE));
- }
- if ((Boolean) value) {
- factoryProperties.put(JsonGenerator.PRETTY_PRINTING, Boolean.TRUE);
- }
- return factoryProperties;
- }
- return factoryProperties;
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/JsonBindingBuilder.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/JsonBindingBuilder.java
deleted file mode 100644
index 6c25fad..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/JsonBindingBuilder.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Dmitry Kornilov
- * Roman Grigoriadi
- ******************************************************************************/
-package org.eclipse.persistence.json.bind.internal;
-
-import javax.json.bind.Jsonb;
-import javax.json.bind.JsonbBuilder;
-import javax.json.bind.JsonbConfig;
-import javax.json.spi.JsonProvider;
-import java.util.Optional;
-
-/**
- * JsonbBuilder implementation.
- *
- * @author Dmitry Kornilov
- */
-public class JsonBindingBuilder implements JsonbBuilder {
- private Optional<JsonbConfig> config = Optional.of(new JsonbConfig());
- private Optional<JsonProvider> provider = Optional.empty();
-
- @Override
- public JsonbBuilder withConfig(JsonbConfig config) {
- this.config = Optional.of(config);
- return this;
- }
-
- @Override
- public JsonbBuilder withProvider(JsonProvider jsonpProvider) {
- this.provider = Optional.of(jsonpProvider);
- return this;
- }
-
- public JsonbConfig getConfig() {
- return config.get();
- }
-
- public Optional<JsonProvider> getProvider() {
- return provider;
- }
-
- @Override
- public Jsonb build() {
- return new JsonBinding(this);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/JsonbContext.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/JsonbContext.java
deleted file mode 100644
index 139e371..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/JsonbContext.java
+++ /dev/null
@@ -1,309 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal;
-
-import org.eclipse.persistence.json.bind.internal.cdi.JsonbComponentInstanceCreator;
-import org.eclipse.persistence.json.bind.internal.cdi.JsonbComponentInstanceCreatorFactory;
-import org.eclipse.persistence.json.bind.internal.internalOrdering.AnyOrderStrategy;
-import org.eclipse.persistence.json.bind.internal.internalOrdering.LexicographicalOrderStrategy;
-import org.eclipse.persistence.json.bind.internal.internalOrdering.PropOrderStrategy;
-import org.eclipse.persistence.json.bind.internal.internalOrdering.ReverseOrderStrategy;
-import org.eclipse.persistence.json.bind.internal.naming.DefaultNamingStrategies;
-import org.eclipse.persistence.json.bind.internal.naming.IdentityStrategy;
-import org.eclipse.persistence.json.bind.internal.properties.MessageKeys;
-import org.eclipse.persistence.json.bind.internal.properties.Messages;
-import org.eclipse.persistence.json.bind.internal.serializer.JsonbDateFormatter;
-
-import javax.json.Json;
-import javax.json.bind.JsonbConfig;
-import javax.json.bind.JsonbException;
-import javax.json.bind.annotation.JsonbDateFormat;
-import javax.json.bind.config.BinaryDataStrategy;
-import javax.json.bind.config.PropertyNamingStrategy;
-import javax.json.bind.config.PropertyOrderStrategy;
-import javax.json.bind.config.PropertyVisibilityStrategy;
-import javax.json.spi.JsonProvider;
-import java.time.format.DateTimeFormatter;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
-
-/**
- * Jsonb context holding central components and configuration of jsonb runtime. Scoped to instance of Jsonb runtime.
- * Thread safe.
- *
- * @author Roman Grigoriadi
- */
-public class JsonbContext {
-
- private final JsonbConfig jsonbConfig;
-
- private final MappingContext mappingContext;
-
- private final JsonbComponentInstanceCreator componentInstanceCreator;
-
- private final PropertyVisibilityStrategy propertyVisibilityStrategy;
-
- private final PropertyNamingStrategy propertyNamingStrategy;
-
- private final JsonProvider jsonProvider;
-
- private final ComponentMatcher componentMatcher;
-
- private final JsonbDateFormatter dateFormatter;
-
- private final AnnotationIntrospector annotationIntrospector;
-
- private final PropertyOrdering propertyOrdering;
-
- private boolean genericComponents;
-
- /**
- * Creates and initialize context.
- *
- * @param jsonbConfig jsonb jsonbConfig not null
- * @param jsonProvider provider of JSONP
- */
- public JsonbContext(JsonbConfig jsonbConfig, JsonProvider jsonProvider) {
- Objects.requireNonNull(jsonbConfig);
- this.jsonbConfig = jsonbConfig;
- this.mappingContext = new MappingContext(this);
- this.componentInstanceCreator = JsonbComponentInstanceCreatorFactory.getComponentInstanceCreator();
- this.componentMatcher = new ComponentMatcher(this);
- this.annotationIntrospector = new AnnotationIntrospector(this);
- this.propertyNamingStrategy = resolvePropertyNamingStrategy();
- this.propertyVisibilityStrategy = resolvePropertyVisibilityStrategy();
- this.jsonProvider = jsonProvider;
- this.propertyOrdering = new PropertyOrdering(initOrderStrategy());
- this.dateFormatter = initDateFormatter();
- }
-
- private PropOrderStrategy initOrderStrategy() {
- final Optional<Object> property = jsonbConfig.getProperty(JsonbConfig.PROPERTY_ORDER_STRATEGY);
- if (property.isPresent()) {
- final Object strategy = property.get();
- if (!(strategy instanceof String)) {
- throw new JsonbException(Messages.getMessage(MessageKeys.PROPERTY_ORDER, strategy));
- }
- switch ((String) strategy) {
- case PropertyOrderStrategy.LEXICOGRAPHICAL:
- return new LexicographicalOrderStrategy();
- case PropertyOrderStrategy.REVERSE:
- return new ReverseOrderStrategy();
- case PropertyOrderStrategy.ANY:
- return new AnyOrderStrategy();
- default:
- throw new JsonbException(Messages.getMessage(MessageKeys.PROPERTY_ORDER, strategy));
- }
- }
- //default by spec
- return new LexicographicalOrderStrategy();
- }
-
- private PropertyNamingStrategy resolvePropertyNamingStrategy() {
- final Optional<Object> property = jsonbConfig.getProperty(JsonbConfig.PROPERTY_NAMING_STRATEGY);
- if (!property.isPresent()) {
- return new IdentityStrategy();
- }
- Object propertyNamingStrategy = property.get();
- if (propertyNamingStrategy instanceof String) {
- String namingStrategyName = (String) propertyNamingStrategy;
- final PropertyNamingStrategy foundNamingStrategy = DefaultNamingStrategies.getStrategy(namingStrategyName);
- if (foundNamingStrategy == null) {
- throw new JsonbException("No property naming strategy was found for: " + namingStrategyName);
- }
- return foundNamingStrategy;
- }
- if (!(propertyNamingStrategy instanceof PropertyNamingStrategy)) {
- throw new JsonbException(Messages.getMessage(MessageKeys.PROPERTY_NAMING_STRATEGY_INVALID));
- }
- return (PropertyNamingStrategy) property.get();
- }
-
- private PropertyVisibilityStrategy resolvePropertyVisibilityStrategy() {
- final Optional<Object> property = jsonbConfig.getProperty(JsonbConfig.PROPERTY_VISIBILITY_STRATEGY);
- if (!property.isPresent()) {
- return null;
- }
- final Object propertyVisibilityStrategy = property.get();
- if (!(propertyVisibilityStrategy instanceof PropertyVisibilityStrategy)) {
- throw new JsonbException("JsonbConfig.PROPERTY_VISIBILITY_STRATEGY must be instance of " + PropertyVisibilityStrategy.class);
- }
- return (PropertyVisibilityStrategy) propertyVisibilityStrategy;
- }
-
-
- /**
- * Instance of Jsonb jsonbConfig.
- * @return jsonb jsonbConfig
- */
- public JsonbConfig getConfig() {
- return jsonbConfig;
- }
-
- /**
- * Instance of MappingContext.
- * @return mapping context
- */
- public MappingContext getMappingContext() {
- return mappingContext;
- }
-
- /**
- * Property visibility strategy.
- * @return strategy for property visibility
- */
- public PropertyVisibilityStrategy getPropertyVisibilityStrategy() {
- return propertyVisibilityStrategy;
- }
-
- /**
- * Property naming strategy.
- * @return strategy for property naming.
- */
- public PropertyNamingStrategy getPropertyNamingStrategy() {
- return propertyNamingStrategy;
- }
-
- /**
- * Provider of JSONP implementation.
- * @return JSONP provider.
- */
- public JsonProvider getJsonProvider() {
- return jsonProvider;
- }
-
- /**
- * Implementation creating instances of user components used by JSONB, such as adapters and strategies.
- *
- * @return instance creator
- */
- public JsonbComponentInstanceCreator getComponentInstanceCreator() {
- return componentInstanceCreator;
- }
-
- /**
- * Component matcher for lookup of (de)serializers and adapters.
- * @return component matcher
- */
- public ComponentMatcher getComponentMatcher() {
- return componentMatcher;
- }
-
- /**
- * Checks for binary data strategy to use.
- *
- * @return binary data strategy
- */
- public String getBinaryDataStrategy() {
- final Optional<Boolean> iJson = jsonbConfig.getProperty(JsonbConfig.STRICT_IJSON).map((obj->(Boolean)obj));
- if (iJson.isPresent() && iJson.get()) {
- return BinaryDataStrategy.BASE_64_URL;
- }
- final Optional<String> strategy = jsonbConfig.getProperty(JsonbConfig.BINARY_DATA_STRATEGY).map((obj) -> (String) obj);
- return strategy.orElse(BinaryDataStrategy.BYTE);
- }
-
- private JsonbDateFormatter initDateFormatter() {
- final String dateFormat = getGlobalConfigJsonbDateFormat();
- final Locale locale = getConfigLocale();
- //In case of java.time singleton formats will be used inside related (de)serializers,
- //in case of java.util.Date and Calendar new instances will be created TODO PERF consider synchronization
- if (JsonbDateFormat.DEFAULT_FORMAT.equals(dateFormat) || JsonbDateFormat.TIME_IN_MILLIS.equals(dateFormat)) {
- return new JsonbDateFormatter(dateFormat, locale.toLanguageTag());
- }
- //if possible create shared instance of java.time formatter.
- return new JsonbDateFormatter(DateTimeFormatter.ofPattern(dateFormat, locale), dateFormat, locale.toLanguageTag());
- }
-
- /**
- * DateFormatter of JsonbConfig.
- * @return date formatter
- */
- private String getGlobalConfigJsonbDateFormat() {
- final Optional<Object> formatProperty = jsonbConfig.getProperty(JsonbConfig.DATE_FORMAT);
- return formatProperty.map(f -> {
- if (!(f instanceof String)) {
- throw new JsonbException(Messages.getMessage(MessageKeys.JSONB_CONFIG_PROPERTY_INVALID_TYPE, JsonbConfig.DATE_FORMAT, String.class.getSimpleName()));
- }
- return (String) f;
- }).orElse(JsonbDateFormat.DEFAULT_FORMAT);
- }
-
- public Locale getLocale(String locale) {
- if (locale.equals(JsonbDateFormat.DEFAULT_LOCALE)) {
- return getConfigLocale();
- }
- return Locale.forLanguageTag(locale);
- }
-
- /**
- * Locale of JsonbConfig.
- * @return locale
- */
- public Locale getConfigLocale() {
- final Optional<Object> localeProperty = jsonbConfig.getProperty(JsonbConfig.LOCALE);
- return localeProperty.map(loc -> {
- if (!(loc instanceof Locale)) {
- throw new JsonbException(Messages.getMessage(MessageKeys.JSONB_CONFIG_PROPERTY_INVALID_TYPE, JsonbConfig.LOCALE, Locale.class.getSimpleName()));
- }
- return (Locale) loc;
- }).orElseGet(Locale::getDefault);
- }
-
- /**
- * Instantiated shared config date formatter.
- * @return date formatter
- */
- public JsonbDateFormatter getConfigDateFormatter() {
- return dateFormatter;
- }
-
- /**
- * Component for annotation parsing.
- *
- * @return annotation introspector
- */
- public AnnotationIntrospector getAnnotationIntrospector() {
- return annotationIntrospector;
- }
-
- /**
- * Property ordering component.
- *
- * @return component for ordering properties
- */
- public PropertyOrdering getPropertyOrdering() {
- return propertyOrdering;
- }
-
- /**
- * Flag for searching for generic serializers and adapters in runtime.
- *
- * @return true if generic components are present
- */
- public boolean genericComponentsPresent() {
- return genericComponents;
- }
-
- /**
- * Set flag for searching for generic serializers and adapters in runtime.
- */
- public void registerGenericComponentFlag() {
- this.genericComponents = true;
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/JsonbParser.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/JsonbParser.java
deleted file mode 100644
index 629de65..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/JsonbParser.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal;
-
-import javax.json.stream.JsonParser;
-
-/**
- * Jsonb parsing helper methods on top of JSOPN parser.
- * @author Roman Grigoriadi
- */
-public interface JsonbParser extends JsonParser {
-
- /**
- * Moves parser to required event, if current event is equal to required does nothing.
- * @param event required event
- */
- void moveTo(JsonParser.Event event);
-
- /**
- * Moves parser cursor to any JSON value.
- */
- Event moveToValue();
-
- /**
- * Moves parser cursor to START_OBJECT or START_ARRAY.
- */
- Event moveToStartStructure();
-
- /**
- * Current level of JsonbRiParser.
- * @return current level
- */
- JsonbRiParser.LevelContext getCurrentLevel();
-
- /**
- * Skips a value or a structure.
- * If current event is START_ARRAY or START_OBJECT, whole structure is skipped to end.
- */
- void skipJsonStructure();
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/JsonbRiParser.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/JsonbRiParser.java
deleted file mode 100644
index e44b70b..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/JsonbRiParser.java
+++ /dev/null
@@ -1,228 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal;
-
-import org.eclipse.persistence.json.bind.internal.properties.MessageKeys;
-import org.eclipse.persistence.json.bind.internal.properties.Messages;
-
-import javax.json.bind.JsonbException;
-import javax.json.stream.JsonLocation;
-import javax.json.stream.JsonParser;
-import java.math.BigDecimal;
-import java.util.Arrays;
-import java.util.Stack;
-
-/**
- * Decorator for JSONP parser used by JSONB.
- * @author Roman Grigoriadi
- */
-public class JsonbRiParser implements JsonParser, JsonbParser {
-
- /**
- * State holder for current json structure level.
- */
- public static class LevelContext {
- private final LevelContext parent;
- private JsonParser.Event lastEvent;
- private String lastStringValue;
- private String lastKeyName;
- private boolean parsed;
-
- public LevelContext(LevelContext parent) {
- this.parent = parent;
- }
-
- public JsonParser.Event getLastEvent() {
- return lastEvent;
- }
-
- private void setLastEvent(JsonParser.Event lastEvent) {
- this.lastEvent = lastEvent;
- }
-
- public String getLastStringValue() {
- return lastStringValue;
- }
-
- private void setLastStringValue(String lastStringValue) {
- this.lastStringValue = lastStringValue;
- }
-
- public String getLastKeyName() {
- return lastKeyName;
- }
-
- private void setLastKeyName(String lastKeyName) {
- this.lastKeyName = lastKeyName;
- }
-
- public LevelContext getParent() {
- return parent;
- }
-
- public boolean isParsed() {
- return parsed;
- }
-
- private void finish() {
- if (parsed) {
- throw new IllegalStateException("Level already parsed");
- }
- parsed = true;
- }
- }
-
- private final JsonParser jsonParser;
-
- private final Stack<LevelContext> level = new Stack<>();
-
- public JsonbRiParser(JsonParser jsonParser) {
- this.jsonParser = jsonParser;
- }
-
- public boolean hasNext() {
- return jsonParser.hasNext();
- }
-
- public long getLong() {
- return jsonParser.getLong();
- }
-
- public int getInt() {
- return jsonParser.getInt();
- }
-
- public JsonParser.Event next() {
- final JsonParser.Event next = jsonParser.next();
- LevelContext current = level.empty() ? null : level.peek();
- if (current != null) {
- current.setLastEvent(next);
- }
- switch (next) {
- case START_ARRAY:
- case START_OBJECT:
- final LevelContext newLevel = new LevelContext(current);
- newLevel.setLastEvent(next);
- level.push(newLevel);
- break;
- case END_ARRAY:
- case END_OBJECT:
- level.pop().finish();
- break;
- case KEY_NAME:
- getCurrentLevel().setLastKeyName(jsonParser.getString());
- break;
- default:
- break;
- }
- return next;
- }
-
- public boolean isIntegralNumber() {
- return jsonParser.isIntegralNumber();
- }
-
- public BigDecimal getBigDecimal() {
- return jsonParser.getBigDecimal();
- }
-
- public JsonLocation getLocation() {
- return jsonParser.getLocation();
- }
-
- public void close() {
- jsonParser.close();
- }
-
- public String getString() {
- final String value = jsonParser.getString();
- getCurrentLevel().setLastStringValue(value);
- return value;
- }
-
- @Override
- public void moveTo(JsonParser.Event required) {
- if (!level.empty() && level.peek().getLastEvent() == required) {
- return;
- }
-
- final Event next = next();
- if (next == required) {
- return;
- }
-
- throw new JsonbException(Messages.getMessage(MessageKeys.INTERNAL_ERROR, "Event " + required + " not found." + getLastDataMsg()));
- }
-
- @Override
- public Event moveToValue() {
- return moveTo(Event.VALUE_STRING, Event.VALUE_NUMBER, Event.VALUE_FALSE, Event.VALUE_TRUE, Event.VALUE_NULL);
- }
-
- @Override
- public Event moveToStartStructure() {
- return moveTo(Event.START_OBJECT, Event.START_ARRAY);
- }
-
- private Event moveTo(Event... events) {
- if (!level.empty() && contains(events, level.peek().getLastEvent())) {
- return level.peek().getLastEvent();
- }
-
- final Event next = next();
- if (contains(events, next)) {
- return next;
- }
-
- throw new JsonbException(Messages.getMessage(MessageKeys.INTERNAL_ERROR, "Parser event ["+Arrays.toString(events)+"] not found." + getLastDataMsg()));
- }
-
- private boolean contains(Event[] events, Event candidate) {
- for (Event event : events) {
- if (event == candidate) {
- return true;
- }
- }
- return false;
- }
-
- private String getLastDataMsg() {
- StringBuilder builder = new StringBuilder();
- final LevelContext currentLevel = getCurrentLevel();
- builder.append(" Last data: [").append("EVENT: ").append(currentLevel.getLastEvent()).append(" KEY_NAME: ")
- .append(currentLevel.getLastKeyName()).append("]");
- return builder.toString();
- }
-
- @Override
- public LevelContext getCurrentLevel() {
- return level.peek();
- }
-
-
- @Override
- public void skipJsonStructure() {
- final LevelContext currentLevel = level.peek();
- switch (currentLevel.getLastEvent()) {
- case START_ARRAY:
- case START_OBJECT:
- while (!currentLevel.isParsed()) {
- next();
- }
- return;
- default:
- return;
- }
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/MappingContext.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/MappingContext.java
deleted file mode 100644
index 590ffa3..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/MappingContext.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- * <p>
- * Contributors:
- * Dmitry Kornilov - initial implementation
- ******************************************************************************/
-package org.eclipse.persistence.json.bind.internal;
-
-import org.eclipse.persistence.json.bind.internal.serializer.ContainerSerializerProvider;
-import org.eclipse.persistence.json.bind.internal.serializer.ISerializerProvider;
-import org.eclipse.persistence.json.bind.model.ClassCustomization;
-import org.eclipse.persistence.json.bind.model.ClassModel;
-import org.eclipse.persistence.json.bind.model.JsonbAnnotatedElement;
-
-import java.util.Iterator;
-import java.util.Objects;
-import java.util.Stack;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.function.Function;
-
-/**
- * JSONB mappingContext. Created once per {@link javax.json.bind.Jsonb} instance. Represents a global scope.
- * Holds internal model.
- *
- * Thread safe
- *
- * @author Dmitry Kornilov
- * @author Roman Grigoriadi
- */
-public class MappingContext {
-
- private static class ParseClassModelFunction implements Function<Class, ClassModel> {
-
- private ClassModel parentClassModel;
-
- private ClassParser classParser;
-
- private JsonbContext jsonbContext;
-
- public ParseClassModelFunction(ClassModel parentClassModel, ClassParser classParser, JsonbContext jsonbContext) {
- this.parentClassModel = parentClassModel;
- this.classParser = classParser;
- this.jsonbContext = jsonbContext;
- }
-
- @Override
- public ClassModel apply(Class aClass) {
- final JsonbAnnotatedElement<Class<?>> clsElement = jsonbContext.getAnnotationIntrospector().collectAnnotations(aClass);
- final ClassCustomization customization = jsonbContext.getAnnotationIntrospector().introspectCustomization(clsElement);
- final ClassModel newClassModel = new ClassModel(aClass, customization, parentClassModel, jsonbContext.getPropertyNamingStrategy());
- classParser.parseProperties(newClassModel, clsElement);
- return newClassModel;
- }
-
- }
- private final JsonbContext jsonbContext;
-
- private final ConcurrentHashMap<Class<?>, ClassModel> classes = new ConcurrentHashMap<>();
-
- private final ConcurrentHashMap<Class<?>, ContainerSerializerProvider> serializers = new ConcurrentHashMap<>();
-
- private final ClassParser classParser;
-
- /**
- * Create mapping context which is scoped to jsonb runtime.
- *
- * @param jsonbContext required
- */
- public MappingContext(JsonbContext jsonbContext) {
- Objects.requireNonNull(jsonbContext);
- this.jsonbContext = jsonbContext;
- this.classParser = new ClassParser(jsonbContext);
- }
-
- /**
- * Search for class model.
- * Parse class and create one if not found.
- * @param clazz clazz to search by or parse, not null.
- */
- public ClassModel getOrCreateClassModel(Class<?> clazz) {
- ClassModel classModel = classes.get(clazz);
- if (classModel != null) {
- return classModel;
- }
- final Stack<Class> newClassModels = new Stack<>();
- for (Class classToParse = clazz; classToParse != Object.class; classToParse = classToParse.getSuperclass()) {
- newClassModels.push(classToParse);
- }
-
- ClassModel parentClassModel = null;
- while (!newClassModels.empty()) {
- Class toParse = newClassModels.pop();
- parentClassModel = classes.computeIfAbsent(toParse, new ParseClassModelFunction(parentClassModel, classParser, jsonbContext));
- }
- return classes.get(clazz);
- }
-
- /**
- * Provided class class model is returned first by iterator.
- * Following class models are sorted by hierarchy from provided class up to the Object.class.
- *
- * @param clazz class to start iteration of class models from
- * @return iterator of class models
- */
- public Iterator<ClassModel> classModelIterator(final Class<?> clazz) {
- return new Iterator<ClassModel>() {
- private Class<?> next = clazz;
-
- @Override
- public boolean hasNext() {
- return next != Object.class;
- }
-
- @Override
- public ClassModel next() {
- final ClassModel result = classes.get(next);
- next = next.getSuperclass();
- return result;
- }
- };
- }
-
- /**
- * Search for class model, without parsing if not found.
- * @param clazz clazz to search by or parse, not null.
- * @return model of a class if found.
- */
- public ClassModel getClassModel(Class<?> clazz) {
- return classes.get(clazz);
- }
-
- public ContainerSerializerProvider getSerializerProvider(Class<?> clazz) {
- return serializers.get(clazz);
- }
-
- public void addSerializerProvider(Class<?> clazz, ContainerSerializerProvider serializerProvider) {
- serializers.putIfAbsent(clazz, serializerProvider);
- }
-
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/Marshaller.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/Marshaller.java
deleted file mode 100644
index d05ebe6..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/Marshaller.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- * <p>
- * Contributors:
- * Dmitry Kornilov - initial implementation
- ******************************************************************************/
-package org.eclipse.persistence.json.bind.internal;
-
-import org.eclipse.persistence.json.bind.internal.serializer.ContainerSerializerProvider;
-import org.eclipse.persistence.json.bind.internal.serializer.SerializerBuilder;
-import org.eclipse.persistence.json.bind.internal.unmarshaller.ContainerModel;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-import org.eclipse.persistence.json.bind.model.JsonContext;
-
-import javax.json.bind.JsonbException;
-import javax.json.bind.serializer.JsonbSerializer;
-import javax.json.bind.serializer.SerializationContext;
-import javax.json.stream.JsonGenerationException;
-import javax.json.stream.JsonGenerator;
-import java.lang.reflect.Type;
-import java.util.Objects;
-import java.util.logging.Logger;
-
-/**
- * JSONB marshaller. Created each time marshalling operation called.
- *
- * @author Dmitry Kornilov
- * @author Roman Grigoriadi
- */
-public class Marshaller extends ProcessingContext implements SerializationContext {
-
- private static final Logger logger = Logger.getLogger(Marshaller.class.getName());
-
- private Type runtimeType;
-
- /**
- * Creates Marshaller for generation to String.
- *
- * @param jsonbContext
- * @param rootRuntimeType type of root object
- */
- public Marshaller(JsonbContext jsonbContext, Type rootRuntimeType) {
- super(jsonbContext);
- this.runtimeType = rootRuntimeType;
- }
-
- /**
- * Creates Marshaller for generation to String.
- *
- * @param jsonbContext
- */
- public Marshaller(JsonbContext jsonbContext) {
- super(jsonbContext);
- this.runtimeType = null;
- }
-
- /**
- * Marshals given object to provided Writer or OutputStream.
- *
- * @param object object to marshall
- * @param jsonGenerator generator to use
- */
- public void marshall(Object object, JsonGenerator jsonGenerator) {
- try {
- //TODO remove default customization
- final ContainerModel model = new ContainerModel(runtimeType != null ? runtimeType : object.getClass(), null, JsonContext.ROOT, null);
- serializeRoot(object, jsonGenerator, model);
- } catch (JsonbException e) {
- logger.severe(e.getMessage());
- throw e;
- } finally {
- try {
- jsonGenerator.close();
- } catch (JsonGenerationException jge) {
- logger.severe(jge.getMessage());
- }
- }
- }
-
- @Override
- public <T> void serialize(String key, T object, JsonGenerator generator) {
- Objects.requireNonNull(key);
- Objects.requireNonNull(object);
- final ContainerModel model = new ContainerModel(object.getClass(), null, JsonContext.JSON_OBJECT, key);
- serializeRoot(object, generator, model);
- }
-
- @Override
- public <T> void serialize(T object, JsonGenerator generator) {
- Objects.requireNonNull(object);
- final ContainerModel model = new ContainerModel(object.getClass(), null, JsonContext.JSON_ARRAY, null);
- serializeRoot(object, generator, model);
- }
-
- @SuppressWarnings("unchecked")
- public <T> void serializeRoot(T root, JsonGenerator generator, JsonBindingModel model) {
- final JsonbSerializer<T> rootSerializer = (JsonbSerializer<T>) getRootSerializer(root.getClass(), model);
- rootSerializer.serialize(root, generator, this);
- }
-
- private JsonbSerializer<?> getRootSerializer(Class<?> rootClazz, JsonBindingModel model) {
- final ContainerSerializerProvider serializerProvider = getMappingContext().getSerializerProvider(rootClazz);
- if (serializerProvider != null) {
- return serializerProvider.provideSerializer(null, runtimeType, getMappingContext().getClassModel(rootClazz), model);
- }
- return new SerializerBuilder(jsonbContext).withObjectClass(rootClazz)
- .withType(model.getType()).withModel(model).build();
- }
-
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/ProcessingContext.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/ProcessingContext.java
deleted file mode 100644
index 8d170ae..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/ProcessingContext.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- * Dmitry Kornilov - initial implementation
- ******************************************************************************/
-package org.eclipse.persistence.json.bind.internal;
-
-/**
- * Jsonb processing (serializing/deserialzing) context.
- * Instance is thread bound (in contrast to {@link JsonbContext}.
- *
- * @author Roman Grigoriadi
- */
-public abstract class ProcessingContext {
-
- protected static final String NULL = "null";
-
-
- protected final JsonbContext jsonbContext;
- /**
- * Parent instance for marshaller and unmarshaller.
- *
- * @param jsonbContext context of Jsonb
- */
- public ProcessingContext(JsonbContext jsonbContext) {
- this.jsonbContext = jsonbContext;
- }
-
- /**
- * Jsonb context.
- * @return jsonb context
- */
- public JsonbContext getJsonbContext() {
- return jsonbContext;
- }
-
- /**
- * Mapping context.
- * @return mapping context
- */
- public MappingContext getMappingContext() {
- return getJsonbContext().getMappingContext();
- }
-
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/PropertyOrdering.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/PropertyOrdering.java
deleted file mode 100644
index 57c1094..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/PropertyOrdering.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package org.eclipse.persistence.json.bind.internal;
-
-import org.eclipse.persistence.json.bind.internal.internalOrdering.PropOrderStrategy;
-import org.eclipse.persistence.json.bind.internal.properties.MessageKeys;
-import org.eclipse.persistence.json.bind.internal.properties.Messages;
-import org.eclipse.persistence.json.bind.model.ClassModel;
-import org.eclipse.persistence.json.bind.model.PropertyModel;
-
-import javax.json.bind.JsonbConfig;
-import javax.json.bind.JsonbException;
-import javax.json.bind.config.PropertyOrderStrategy;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-
-/**
- * Order properties in bean object. {@link javax.json.bind.annotation.JsonbPropertyOrder} have always precedence.
- * If configured with {@link JsonbConfig} provided property order strategy will be used.
- *
- * @author Roman Grigoriadi
- */
-public class PropertyOrdering {
-
- private PropOrderStrategy propertyOrderStrategy;
-
- /**
- * Property ordering.
- *
- * @param propertyOrderStrategy not null
- */
- public PropertyOrdering(PropOrderStrategy propertyOrderStrategy) {
- Objects.requireNonNull(propertyOrderStrategy);
- this.propertyOrderStrategy = propertyOrderStrategy;
- }
-
- /**
- * Sorts class properties either, by class {@link javax.json.bind.annotation.JsonbPropertyOrder} annotation,
- * or by {@link PropertyOrderStrategy} if set in JsonbConfig.
- * @param properties
- * @param classModel
- * @return
- */
- public List<PropertyModel> orderProperties(Map<String, PropertyModel> properties, ClassModel classModel) {
- String[] order = classModel.getClassCustomization().getPropertyOrder();
- if (order != null) {
- //if @JsonbPropertyOrder annotation is defined on a class
- List<PropertyModel> sortedProperties = new ArrayList<>();
- for (String propName : order) {
- final PropertyModel remove = properties.remove(propName);
- if (remove != null) {
- sortedProperties.add(remove);
- }
- }
- /* TODO currently disabled, should remaining fields (unspecified in JsonbPropertyOrder) appear in json?
- for (Map.Entry<String, PropertyModel> entry : properties.entrySet()) {
- sortedProperties.add(entry.getValue());
- }*/
- return sortedProperties;
- }
-
- //No annotation, check JsonbConfig for ordering strategy use LEXICOGRAPHICAL as default
- return propertyOrderStrategy.sortProperties(properties.values());
- }
-
- /**
- * Property order strategy from jsonbconfig (if present)
- * @return
- */
- public PropOrderStrategy getPropertyOrderStrategy() {
- return propertyOrderStrategy;
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/ReflectionUtils.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/ReflectionUtils.java
deleted file mode 100644
index 405558e..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/ReflectionUtils.java
+++ /dev/null
@@ -1,283 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-package org.eclipse.persistence.json.bind.internal;
-
-import org.eclipse.persistence.json.bind.internal.properties.MessageKeys;
-import org.eclipse.persistence.json.bind.internal.properties.Messages;
-import org.eclipse.persistence.json.bind.internal.unmarshaller.AbstractItem;
-import org.eclipse.persistence.json.bind.internal.unmarshaller.EmbeddedItem;
-import org.eclipse.persistence.json.bind.internal.unmarshaller.ResolvedParameterizedType;
-
-import javax.json.bind.JsonbException;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.GenericArrayType;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
-import java.lang.reflect.WildcardType;
-import java.util.Arrays;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.logging.Logger;
-
-/**
- * Utility class for resolution of generics during unmarshalling.
- *
- * @author Roman Grigoriadi
- */
-public class ReflectionUtils {
-
- private static final Logger logger = Logger.getLogger(ReflectionUtils.class.getName());
-
- /**
- * Get raw type by type.
- * Only for ParametrizedTypes, GenericArrayTypes and Classes.
- *
- * Empty optional is returned if raw type cannot be resolved.
- *
- * @param type Type to get class information from, not null.
- * @return Class of a type.
- */
- public static Optional<Class<?>> getOptionalRawType(Type type) {
- if (type instanceof Class) {
- return Optional.of((Class<?>) type);
- } else if (type instanceof ParameterizedType) {
- return Optional.of((Class<?>) ((ParameterizedType) type).getRawType());
- } else if (type instanceof GenericArrayType) {
- return Optional.of(((GenericArrayType) type).getClass());
- }
- return Optional.empty();
- }
-
- /**
- * Get raw type by type.
- * Resolves only ParametrizedTypes, GenericArrayTypes and Classes.
- *
- * Exception is thrown if raw type cannot be resolved.
- *
- * @param type Type to get class information from, not null.
- * @return Class of a raw type.
- */
- public static Class<?> getRawType(Type type) {
- return getOptionalRawType(type)
- .orElseThrow(()->new JsonbException(Messages.getMessage(MessageKeys.TYPE_RESOLUTION_ERROR, type)));
- }
-
- /**
- * Get a raw type of any type.
- * If type is a {@link TypeVariable} recursively search {@link AbstractItem} for resolution of typevar.
- * If type is a {@link WildcardType} find most specific upper / lower bound, which can be used. If most specific
- * bound is a {@link TypeVariable}, perform typevar resolution.
- *
- * @param item item containing wrapper class of a type field, not null.
- * @param type type to resolve, typically field type or generic bound, not null.
- * @return resolved raw class
- */
- public static Class<?> resolveRawType(RuntimeTypeInfo item, Type type) {
- if (type instanceof Class) {
- return (Class<?>) type;
- } else if (type instanceof ParameterizedType) {
- return (Class<?>) ((ParameterizedType) type).getRawType();
- } else {
- return getRawType(resolveType(item, type));
- }
- }
-
- /**
- * Resolve a type by item.
- * If type is a {@link TypeVariable} recursively search {@link AbstractItem} for resolution of typevar.
- * If type is a {@link WildcardType} find most specific upper / lower bound, which can be used. If most specific
- * bound is a {@link TypeVariable}, perform typevar resolution.
- *
- * @param item item containing wrapper class of a type field, not null.
- * @param type type to resolve, typically field type or generic bound, not null.
- * @return resolved type
- */
- public static Type resolveType(RuntimeTypeInfo item, Type type) {
- if (type instanceof WildcardType) {
- return resolveMostSpecificBound(item, (WildcardType) type);
- } else if (type instanceof TypeVariable) {
- return resolveItemVariableType(item, (TypeVariable<?>) type);
- } else if (type instanceof ParameterizedType && item != null) {
- return resolveTypeArguments((ParameterizedType) type, item.getRuntimeType());
- }
- return type;
- }
-
- /**
- * Resolve a bounded type variable type by its wrapper types.
- * Resolution could be done only if a compile time generic information is provided, either:
- * by generic field or subclass of a generic class.
- * @param item item to search "runtime" generic type of a TypeVariable.
- * @param typeVariable type to search in item for, not null.
- * @return Type of a generic "runtime" bound, not null.
- */
- public static Type resolveItemVariableType(RuntimeTypeInfo item, TypeVariable<?> typeVariable) {
- if (item == null) {
- //Bound not found, treat it as an Object.class
- //TODO needs a field declaration identification.
- logger.warning(Messages.getMessage(MessageKeys.GENERIC_BOUND_NOT_FOUND, typeVariable, typeVariable.getGenericDeclaration()));
- return Object.class;
- }
-
- //Embedded items doesn't hold information about variable types
- if (item instanceof EmbeddedItem) {
- return resolveItemVariableType(item.getWrapper(), typeVariable);
- }
-
- ParameterizedType wrapperParameterizedType = findParameterizedSuperclass(item.getRuntimeType());
-
- VariableTypeInheritanceSearch search = new VariableTypeInheritanceSearch();
- Type foundType = search.searchParametrizedType(wrapperParameterizedType, typeVariable);
- if (foundType != null) {
- if (foundType instanceof TypeVariable) {
- return resolveItemVariableType(item.getWrapper(), (TypeVariable<?>) foundType);
- }
- return foundType;
- }
-
- return resolveItemVariableType(item.getWrapper(), typeVariable);
- }
-
- public static Type resolveTypeArguments(ParameterizedType typeToResolve, Type typeToSearch) {
- final Type[] unresolvedArgs = typeToResolve.getActualTypeArguments();
- Type[] resolvedArgs = new Type[unresolvedArgs.length];
- for (int i = 0; i< unresolvedArgs.length; i++) {
- if (!(unresolvedArgs[i] instanceof TypeVariable)) {
- resolvedArgs[i] = unresolvedArgs[i];
- } else {
- resolvedArgs[i] = new VariableTypeInheritanceSearch().searchParametrizedType(typeToSearch, (TypeVariable<?>) unresolvedArgs[i]);
- if (resolvedArgs[i] == null) {
- //TODO happens with mistyped runtime type, better explanation whats wrong
- throw new IllegalStateException();
-// logger.warning(Messages.getMessage(MessageKeys.GENERIC_BOUND_NOT_FOUND, unresolvedArgs[i], typeToSearch));
- }
- }
- if (resolvedArgs[i] instanceof ParameterizedType) {
- resolvedArgs[i] = resolveTypeArguments((ParameterizedType) resolvedArgs[i], typeToSearch);
- }
- }
- return Arrays.equals(resolvedArgs, unresolvedArgs) ?
- typeToResolve : new ResolvedParameterizedType(typeToResolve, resolvedArgs);
- }
-
- /**
- * Search for no argument constructor of a class and create instance.
- *
- * @param clazz not null
- * @param <T> type of instance
- * @return instance
- */
- public static <T> T createNoArgConstructorInstance(Class<T> clazz) {
- Objects.requireNonNull(clazz);
- try {
- final Constructor<T> declaredConstructor = clazz.getDeclaredConstructor();
- declaredConstructor.setAccessible(true);
- return declaredConstructor.newInstance();
- } catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
- throw new JsonbException("Can't create instance", e);
- } catch (NoSuchMethodException e) {
- throw new JsonbException(Messages.getMessage(MessageKeys.NO_DEFAULT_CONSTRUCTOR, clazz), e);
- }
- }
-
- /**
- * For generic adapters like:
- * <p>
- * {@code
- * interface ContainerAdapter<T> extends JsonbAdapter<Box<T>, Crate<T>>...;
- * class IntegerBoxToCrateAdapter implements ContainerAdapter<Integer>...;
- * }
- * </p>
- * We need to find a JsonbAdapter class which will hold basic generic type arguments,
- * and resolve them if they are TypeVariables from there.
- *
- * @param classToSearch class to resolve parameterized interface
- * @param parameterizedInterface interface to search
- *
- * @return type of JsonbAdapter
- */
- public static ParameterizedType findParameterizedType(Class<?> classToSearch, Class<?> parameterizedInterface) {
- Class current = classToSearch;
- while (current != Object.class) {
- for (Type currentInterface : current.getGenericInterfaces()) {
- if (currentInterface instanceof ParameterizedType &&
- ((ParameterizedType) currentInterface).getRawType().equals(parameterizedInterface)) {
- return (ParameterizedType) currentInterface;
- }
- }
- current = current.getSuperclass();
- }
- //TODO messages
- throw new JsonbException(String.format("Type: %s does not implement a parametrized type interface", parameterizedInterface));
- }
-
- /**
- * Check if type needs resolution. If type is a class or a parametrized type with all type arguments as classes
- * than it is considered resolved. If any of types is type variable or wildcard type is not resolved.
- *
- * @param type type to check.
- * @return true if resolved
- */
- public static boolean isResolvedType(Type type) {
- if (type instanceof ParameterizedType) {
- for(Type typeArg : ((ParameterizedType)type).getActualTypeArguments()) {
- if (!isResolvedType(typeArg)) {
- return false;
- }
- }
- return true;
- }
- return type instanceof Class<?>;
- }
-
- private static ParameterizedType findParameterizedSuperclass(Type type) {
- if (type == null || type instanceof ParameterizedType) {
- return (ParameterizedType) type;
- }
- if (!(type instanceof Class)) {
- throw new JsonbException("Can't resolve ParameterizedType superclass for: " + type);
- }
- return findParameterizedSuperclass(((Class) type).getGenericSuperclass());
- }
-
- /**
- * Resolves a wildcard most specific upper or lower bound.
- */
- private static Type resolveMostSpecificBound(RuntimeTypeInfo item, WildcardType wildcardType) {
- Class<?> result = Object.class;
- for (Type upperBound : wildcardType.getUpperBounds()) {
- result = getMostSpecificBound(item, result, upperBound);
- }
- for (Type lowerBound : wildcardType.getLowerBounds()) {
- result = getMostSpecificBound(item, result, lowerBound);
- }
- return result;
- }
-
- private static Class<?> getMostSpecificBound(RuntimeTypeInfo item, Class<?> result, Type bound) {
- if (bound == Object.class) {
- return result;
- }
- //if bound is type variable search recursively for wrapper generic expansion
- Type resolvedBoundType = bound instanceof TypeVariable ? resolveType(item, bound) : bound;
- Class<?> boundRawType = getRawType(resolvedBoundType);
- //resolved class is a subclass of a result candidate
- if (result.isAssignableFrom(boundRawType)) {
- result = boundRawType;
- }
- return result;
- }
-
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/RuntimeTypeHolder.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/RuntimeTypeHolder.java
deleted file mode 100644
index 478ea8a..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/RuntimeTypeHolder.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal;
-
-import java.lang.reflect.Type;
-
-/**
- * Holds runtime type and wrapper runtime type info if any.
- * @author Roman Grigoriadi
- */
-public class RuntimeTypeHolder implements RuntimeTypeInfo {
-
- private final RuntimeTypeInfo wrapper;
-
- private final Type runtimeType;
-
- public RuntimeTypeHolder(RuntimeTypeInfo wrapper, Type runtimeType) {
- this.wrapper = wrapper;
- this.runtimeType = runtimeType;
- }
-
- /**
- * Wrapper containing property of this type.
- * @return wrapper
- */
- @Override
- public RuntimeTypeInfo getWrapper() {
- return wrapper;
- }
-
- /**
- * Runtime type of this item.
- * @return runtime type
- */
- @Override
- public Type getRuntimeType() {
- return runtimeType;
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/RuntimeTypeInfo.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/RuntimeTypeInfo.java
deleted file mode 100644
index faf99dd..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/RuntimeTypeInfo.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal;
-
-import java.lang.reflect.Type;
-
-/**
- * Holds runtime type info of the class. Used for generic type resolution, especially during unmarshalling.
- *
- * @author Roman Grigoriadi
- */
-public interface RuntimeTypeInfo {
-
- /**
- * Runtime type holder of a wrapper class of this runtime type.
- *
- * @return Runtime type info
- */
- RuntimeTypeInfo getWrapper();
-
- /**
- * Runtime type of a class. Can be a class, ParameterizedType, or TypeVariable.
- * When a field or a class is declared including generic information this will return runtime type info.
- *
- * @return
- */
- Type getRuntimeType();
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/Unmarshaller.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/Unmarshaller.java
deleted file mode 100644
index a489e3f..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/Unmarshaller.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- * <p>
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-package org.eclipse.persistence.json.bind.internal;
-
-
-import org.eclipse.persistence.json.bind.internal.unmarshaller.CurrentItem;
-import org.eclipse.persistence.json.bind.internal.unmarshaller.DeserializerBuilder;
-import org.eclipse.persistence.json.bind.internal.unmarshaller.JsonValueType;
-
-import javax.json.bind.serializer.DeserializationContext;
-import javax.json.bind.serializer.JsonbDeserializer;
-import javax.json.stream.JsonParser;
-import java.lang.reflect.Type;
-
-/**
- * JSONB unmarshaller.
- * Uses {@link JsonParser} to navigate through json string.
- *
- * @author Roman Grigoriadi
- */
-public class Unmarshaller extends ProcessingContext implements DeserializationContext {
-
- /**
- * Creates instance of unmarshaller.
- * @param jsonbContext context to use
- */
- public Unmarshaller(JsonbContext jsonbContext) {
- super(jsonbContext);
- }
-
- private CurrentItem<?> current;
-
- @Override
- public <T> T deserialize(Class<T> clazz, JsonParser parser) {
- return deserializeItem(clazz, parser);
- }
-
- @Override
- public <T> T deserialize(Type type, JsonParser parser) {
- return deserializeItem(type, parser);
- }
-
- @SuppressWarnings("unchecked")
- private <T> T deserializeItem(Type type, JsonParser parser) {
- final JsonbDeserializer<?> item = new DeserializerBuilder(jsonbContext).withWrapper(current)
- .withType(type).withJsonValueType(JsonValueType.of(getRootEvent(parser))).build();
- return (T) item.deserialize(parser, this, type);
- }
-
- /**
- * Get root value event, either for new deserialization process, or deserialization subprocess invoked from
- * custom user deserialzier.
- */
- private JsonParser.Event getRootEvent(JsonParser parser) {
- if (parser.getLocation().getStreamOffset() == 0) {
- return parser.next();
- }
- final JsonParser.Event lastEvent = ((JsonbParser) parser).getCurrentLevel().getLastEvent();
- return lastEvent == JsonParser.Event.KEY_NAME ? parser.next() : lastEvent;
- }
-
- /**
- * Get currently processed json item.
- * @return current item
- */
- public CurrentItem<?> getCurrent() {
- return current;
- }
-
- /**
- * Set currently processed item.
- * @param current current item
- */
- public void setCurrent(CurrentItem<?> current) {
- this.current = current;
- }
-
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/VariableTypeInheritanceSearch.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/VariableTypeInheritanceSearch.java
deleted file mode 100644
index 839c7a8..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/VariableTypeInheritanceSearch.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal;
-
-import org.eclipse.persistence.json.bind.internal.properties.MessageKeys;
-import org.eclipse.persistence.json.bind.internal.properties.Messages;
-
-import javax.json.bind.JsonbException;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.lang.reflect.TypeVariable;
-import java.util.Stack;
-
-/**
- * Search for type variable in inheritance hierarchy and resolve if possible.
- *
- * @author Roman Grigoriadi
- */
-public class VariableTypeInheritanceSearch {
-
- private final Stack<ParameterizedType> parameterizedSubclasses = new Stack<>();
-
- /**
- * Searches the hierarchy of classes to resolve a type variable. If typevar resolved value is another typevar redirection (propagated from wrapping class),
- * this typevar is returned.
- *
- * <pre>
- *
- * Example 1: typevar is resolved
- *
- *
- * class GenericClass <T> {
- * private T genericField;
- * }
- * class ConcreteClass extends SomeTypeVarClass<MyPojo> {
- * //...
- * }
- *
- * In above case when ConcreteClass type is passed as runtime type and <T> as type variable, T is resolved to MyPojo.
- * </pre>
- *
- *
- * <pre>
- * Example 2: typevar is resolved to another propagated typevar
- *
- *
- * class WrapperGenericClass<X> {
- * private GenericClass<X> propagatedGenericField
- * }
- *
- * class AnotherClass extends WrapperGenericClass<MyPojo> {
- * }
- *
- *
- * In second case when GenericClass {@link ParameterizedType} is passed as runtime type and <T> as type variable,
- * T is resolved to propagated <X> by WrapperGenericClass.
- *
- * Resolution on <X> must be performed thereafter with AnotherClass runtime type.
- * </pre>
- *
- * @param typeToSearch runtime type to search for typevar in, not null
- * @param typeVar type variable to resolve, not null
- * @return resolved runtime type, or type variable
- */
- public Type searchParametrizedType(Type typeToSearch, TypeVariable<?> typeVar) {
- ParameterizedType parameterizedType = findParameterizedSuperclass(typeToSearch);
- if (parameterizedType == null) {
- return null;
- }
- Type matchedGenericType = searchRuntimeTypeArgument(parameterizedType, typeVar);
- if (matchedGenericType != null) {
- return matchedGenericType;
- }
- parameterizedSubclasses.push(parameterizedType);
- return searchParametrizedType(((Class) parameterizedType.getRawType()).getGenericSuperclass(), typeVar);
- }
-
- private Type checkSubclassRuntimeInfo(TypeVariable typeVar) {
- if (parameterizedSubclasses.size() == 0) {
- return typeVar;
- }
- ParameterizedType parametrizedSubclass = parameterizedSubclasses.pop();
- return searchRuntimeTypeArgument(parametrizedSubclass, typeVar);
- }
-
- private Type searchRuntimeTypeArgument(ParameterizedType runtimeType, TypeVariable<?> typeVar) {
- if (ReflectionUtils.getRawType(runtimeType) != typeVar.getGenericDeclaration()) {
- return null;
- }
- TypeVariable[] bounds = typeVar.getGenericDeclaration().getTypeParameters();
- for (int i = 0; i < bounds.length; i++) {
- if (bounds[i].equals(typeVar)) {
- Type matchedGenericType = runtimeType.getActualTypeArguments()[i];
- //Propagated generic types to another generic classes
- if (matchedGenericType instanceof TypeVariable<?>) {
- return checkSubclassRuntimeInfo((TypeVariable) matchedGenericType);
- }
- //found runtime matchedGenericType
- return matchedGenericType;
- }
- }
- return null;
- }
-
- private static ParameterizedType findParameterizedSuperclass(Type type) {
- if (type == null || type instanceof ParameterizedType) {
- return (ParameterizedType) type;
- }
- if (!(type instanceof Class)) {
- throw new JsonbException(Messages.getMessage(MessageKeys.RESOLVE_PARAMETRIZED_TYPE, type));
- }
- return findParameterizedSuperclass(((Class) type).getGenericSuperclass());
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/adapter/AbstractComponentBinding.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/adapter/AbstractComponentBinding.java
deleted file mode 100644
index 03941f1..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/adapter/AbstractComponentBinding.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.adapter;
-
-import java.lang.reflect.Type;
-import java.util.Objects;
-
-/**
- * Wrapper for user components, adapter, (de)serializer.
- * Contains resolved binding type an component.
- *
- * @author Roman Grigoriadi
- */
-public abstract class AbstractComponentBinding {
-
- private final Type bindingType;
-
- /**
- * Creates info.
- * @param bindingType type to which component is bound.
- */
- public AbstractComponentBinding(Type bindingType) {
- Objects.requireNonNull(bindingType);
- this.bindingType = bindingType;
- }
-
- /**
- * Resolved binding type of a component.
- *
- * @return binding type
- */
- public Type getBindingType() {
- return bindingType;
- }
-
- /**
- * Class of user component.
- * @return component class
- */
- public abstract Class<?> getComponentClass();
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/adapter/AdapterBinding.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/adapter/AdapterBinding.java
deleted file mode 100644
index 12a6c7d..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/adapter/AdapterBinding.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.adapter;
-
-import javax.json.bind.adapter.JsonbAdapter;
-import java.lang.reflect.Type;
-import java.util.Objects;
-
-/**
- * Wrapper for JsonbAdapter generic information and an adapter itself.
- *
- * @author Roman Grigoriadi
- */
-public class AdapterBinding extends AbstractComponentBinding {
-
- private final Type toType;
-
- private final JsonbAdapter<?,?> adapter;
-
- /**
- * Adapter info with type to "adapt from", type to "adapt to" and an adapter itself.
- * @param fromType from not null
- * @param toType to not null
- * @param adapter adapter not null
- */
- public AdapterBinding(Type fromType, Type toType, JsonbAdapter<?, ?> adapter) {
- super(fromType);
- Objects.requireNonNull(toType);
- Objects.requireNonNull(adapter);
- this.toType = toType;
- this.adapter = adapter;
- }
-
- /**
- * Represents a type to which to adapt into.
- *
- * During marshalling object property is adapted to this type and result is marshalled
- * During unmarshalling object is unmarshalled into this type first, than converted to field type and set.
- *
- * @return Type from which to adapt
- */
- public Type getToType() {
- return toType;
- }
-
- /**
- * Get actual adapter to adapt object value
- * @return adapter
- */
- public JsonbAdapter<?, ?> getAdapter() {
- return adapter;
- }
-
- @Override
- public Class<?> getComponentClass() {
- return adapter.getClass();
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/adapter/ComponentBindings.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/adapter/ComponentBindings.java
deleted file mode 100644
index 7d815a4..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/adapter/ComponentBindings.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.adapter;
-
-import java.lang.reflect.Type;
-
-/**
- * Wrapper holding singleton instances of user defined components - Adapters, (De)Serializers.
- * @author Roman Grigoriadi
- */
-public class ComponentBindings {
-
- private final Type bindingType;
-
- private final SerializerBinding serializer;
-
- private final DeserializerBinding deserializer;
-
- private final AdapterBinding adapterInfo;
-
- /**
- * Construct empty bindings for a given type.
- * @param bindingType type components are bound to
- */
- public ComponentBindings(Type bindingType) {
- this(bindingType, null, null, null);
- }
-
- /**
- * Construct populated bindings for a given type.
- * @param bindingType type components are bound to
- */
- public ComponentBindings(Type bindingType, SerializerBinding serializer, DeserializerBinding deserializer, AdapterBinding adapter) {
- this.bindingType = bindingType;
- this.serializer = serializer;
- this.deserializer = deserializer;
- this.adapterInfo = adapter;
- }
-
- /**
- * Type to which components are bound.
- * @return bound type
- */
- public Type getBindingType() {
- return bindingType;
- }
-
- /**
- * Serializer if any.
- * @return serializer
- */
- public SerializerBinding getSerializer() {
- return serializer;
- }
-
- /**
- * Deserializer if any.
- * @return deserializer
- */
- public DeserializerBinding getDeserializer() {
- return deserializer;
- }
-
- /**
- * Adapter info if any.
- * @return adapterInfo
- */
- public AdapterBinding getAdapterInfo() {
- return adapterInfo;
- }
-
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/adapter/DeserializerBinding.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/adapter/DeserializerBinding.java
deleted file mode 100644
index 9a798c6..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/adapter/DeserializerBinding.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.adapter;
-
-import javax.json.bind.serializer.JsonbDeserializer;
-import java.lang.reflect.Type;
-
-/**
- * Component containing deserializer.
- *
- * @author Roman Grigoriadi
- */
-public class DeserializerBinding<T> extends AbstractComponentBinding {
-
- private final JsonbDeserializer<T> jsonbDeserializer;
-
- public DeserializerBinding(Type bindingType, JsonbDeserializer<T> jsonbDeserializer) {
- super(bindingType);
- this.jsonbDeserializer = jsonbDeserializer;
- }
-
- /**
- * Deserializer if any.
- *
- * @return deserializer
- */
- public JsonbDeserializer<T> getJsonbDeserializer() {
- return jsonbDeserializer;
- }
-
- @Override
- public Class<?> getComponentClass() {
- return jsonbDeserializer.getClass();
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/adapter/SerializerBinding.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/adapter/SerializerBinding.java
deleted file mode 100644
index bbd9ad0..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/adapter/SerializerBinding.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.adapter;
-
-import javax.json.bind.serializer.JsonbSerializer;
-import java.lang.reflect.Type;
-
-/**
- * Binding for user Serializer component.
- * @author Roman Grigoriadi
- */
-public class SerializerBinding<T> extends AbstractComponentBinding {
-
- private final JsonbSerializer<T> jsonbSerializer;
-
-
- /**
- * Constructs info.
- * @param bindingType generic type argument of serializer and deserializer not null
- * @param jsonbSerializer serializer nullable
- */
- public SerializerBinding(Type bindingType, JsonbSerializer<T> jsonbSerializer) {
- super(bindingType);
- this.jsonbSerializer = jsonbSerializer;
- }
-
- /**
- * Serializer if any.
- * @return serializer
- */
- public JsonbSerializer<T> getJsonbSerializer() {
- return jsonbSerializer;
- }
-
- /**
- * Class of user component.
- *
- * @return component class
- */
- @Override
- public Class<?> getComponentClass() {
- return jsonbSerializer.getClass();
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/cdi/BeanManagerInstanceCreator.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/cdi/BeanManagerInstanceCreator.java
deleted file mode 100644
index 9ca9970..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/cdi/BeanManagerInstanceCreator.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.cdi;
-
-import org.eclipse.persistence.json.bind.internal.JsonBinding;
-
-import javax.enterprise.context.spi.CreationalContext;
-import javax.enterprise.inject.spi.AnnotatedType;
-import javax.enterprise.inject.spi.BeanManager;
-import javax.enterprise.inject.spi.InjectionTarget;
-import java.io.IOException;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
-/**
- * CDI instance manager.
- * Instances are are created and stored per instance of {@link JsonBinding}.
- * Calling close on JsonBinding, cleans up Jsonb CDI instances and in case of "dependant" scope its dependencies.
- *
- * @author Roman Grigoriadi
- */
-public class BeanManagerInstanceCreator implements JsonbComponentInstanceCreator {
-
- private final BeanManager beanManager;
-
- private final ConcurrentMap<Class<?>, CDIManagedBean<?>> injectionTargets = new ConcurrentHashMap<>();
-
- /**
- * Create instance.
- */
- public BeanManagerInstanceCreator(BeanManager beanManager) {
- this.beanManager = beanManager;
- }
-
- /**
- * Creates an instance of the CDI managed bean.
- * Calls CDI API to inject into the bean.
- *
- * @param componentClass bean class to be instantiated.
- * @return New instance of bean class with injected content.
- */
- @Override
- @SuppressWarnings("unchecked")
- public <T> T getOrCreateComponent(Class<T> componentClass) {
- return (T) injectionTargets.computeIfAbsent(componentClass, clazz -> {
- final AnnotatedType<T> aType = beanManager.createAnnotatedType(componentClass);
- final InjectionTarget<T> injectionTarget = beanManager.createInjectionTarget(aType);
- CreationalContext<T> creationalContext = beanManager.createCreationalContext(null);
- final T beanInstance = injectionTarget.produce(creationalContext);
- injectionTarget.inject(beanInstance, creationalContext);
- injectionTarget.postConstruct(beanInstance);
- return new CDIManagedBean(beanInstance, injectionTarget, creationalContext);
- }).getInstance();
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public void close() throws IOException {
- injectionTargets.forEach((clazz,target)-> cleanupBean(target));
- injectionTargets.clear();
- }
-
- private <T> void cleanupBean(CDIManagedBean<T> bean) {
- bean.getInjectionTarget().preDestroy(bean.getInstance());
- bean.getInjectionTarget().dispose(bean.getInstance());
- bean.getCreationalContext().release();
- }
-
- /**
- * Holder for bean instance and its injection target.
- */
- private static final class CDIManagedBean<T> {
- private final T instance;
- private final InjectionTarget<T> injectionTarget;
- private final CreationalContext<T> creationalContext;
-
- public CDIManagedBean(T instance, InjectionTarget<T> injectionTarget, CreationalContext<T> creationalContext) {
- this.instance = instance;
- this.injectionTarget = injectionTarget;
- this.creationalContext = creationalContext;
- }
-
- /**
- * @return CDI InjectionTarget
- */
- private InjectionTarget<T> getInjectionTarget() {
- return injectionTarget;
- }
-
- /**
- * @return managed instance of a bean
- */
- private T getInstance() {
- return instance;
- }
-
- /**
- * @return creational context
- */
- private CreationalContext<T> getCreationalContext() {
- return creationalContext;
- }
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/cdi/DefaultConstructorCreator.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/cdi/DefaultConstructorCreator.java
deleted file mode 100644
index e8399b8..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/cdi/DefaultConstructorCreator.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.cdi;
-
-import org.eclipse.persistence.json.bind.internal.ReflectionUtils;
-
-import java.io.IOException;
-
-/**
- * Creates adapter instance with default constructor.
- *
- * @author Roman Grigoriadi
- */
-public class DefaultConstructorCreator implements JsonbComponentInstanceCreator {
-
- @Override
- public <T> T getOrCreateComponent(Class<T> componentClass) {
- return ReflectionUtils.createNoArgConstructorInstance(componentClass);
- }
-
- @Override
- public void close() throws IOException {
-
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/cdi/JsonbComponentInstanceCreator.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/cdi/JsonbComponentInstanceCreator.java
deleted file mode 100644
index f02adb8..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/cdi/JsonbComponentInstanceCreator.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.cdi;
-
-import java.io.Closeable;
-
-/**
- * Creates instances of JsonbComponents such as JsonbAdapter.
- * If CDI is available uses BeanManager to create instance, otherwise calls no parameter constructor.
- *
- * @author Roman Grigoriadi
- */
-public interface JsonbComponentInstanceCreator extends Closeable {
-
- <T> T getOrCreateComponent(Class<T> componentClass);
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/cdi/JsonbComponentInstanceCreatorFactory.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/cdi/JsonbComponentInstanceCreatorFactory.java
deleted file mode 100644
index bde9dcc..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/cdi/JsonbComponentInstanceCreatorFactory.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.cdi;
-
-import org.eclipse.persistence.json.bind.internal.properties.MessageKeys;
-import org.eclipse.persistence.json.bind.internal.properties.Messages;
-
-import javax.enterprise.inject.spi.BeanManager;
-import javax.enterprise.inject.spi.CDI;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import java.util.logging.Logger;
-
-/**
- * Factory method for Jsonb component instance creator.
- *
- * @author Roman Grigoriadi
- */
-public class JsonbComponentInstanceCreatorFactory {
-
- private static final Logger log = Logger.getLogger(JsonbComponentInstanceCreator.class.getName());
-
- public static final String BEAN_MANAGER_NAME = "java:comp/BeanManager";
-
- /**
- * First check a CDI provider, if available use those.
- * Try to lookup in a JNDI if no provider is registered.
- * If one of the above is found {@link BeanManagerInstanceCreator} is returned,
- * or {@link DefaultConstructorCreator} otherwise.
- * @return Component instance creator, either CDI or default constructor.
- */
- public static JsonbComponentInstanceCreator getComponentInstanceCreator() {
- try {
- return new BeanManagerInstanceCreator(CDI.current().getBeanManager());
- } catch (IllegalStateException e) {
- log.finest(Messages.getMessage(MessageKeys.BEAN_MANAGER_NOT_FOUND_NO_PROVIDER));
- try {
- InitialContext context = new InitialContext();
- final BeanManager lookup = (BeanManager) context.lookup(BEAN_MANAGER_NAME);
- return new BeanManagerInstanceCreator(lookup);
- } catch (NamingException e1) {
- log.finest(Messages.getMessage(MessageKeys.BEAN_MANAGER_NOT_FOUND_JNDI, BEAN_MANAGER_NAME, e1.getExplanation()));
- }
- }
- log.finest(Messages.getMessage(MessageKeys.BEAN_MANAGER_NOT_FOUND_USING_DEFAULT));
- return new DefaultConstructorCreator();
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/internalOrdering/AnyOrderStrategy.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/internalOrdering/AnyOrderStrategy.java
deleted file mode 100644
index c416e63..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/internalOrdering/AnyOrderStrategy.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * David Kral - initial implementation
- ******************************************************************************/
-package org.eclipse.persistence.json.bind.internal.internalOrdering;
-
-import org.eclipse.persistence.json.bind.model.PropertyModel;
-
-import javax.json.bind.config.PropertyNamingStrategy;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.List;
-
-/**
- * Any ordering strategy
- *
- * @author David Kral
- */
-public class AnyOrderStrategy extends PropOrderStrategy {
-
- @Override
- public List<PropertyModel> sortProperties(Collection<PropertyModel> properties) {
- return new ArrayList<>(properties);
- }
-
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/internalOrdering/LexicographicalOrderStrategy.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/internalOrdering/LexicographicalOrderStrategy.java
deleted file mode 100644
index 616bc0b..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/internalOrdering/LexicographicalOrderStrategy.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * David Kral - initial implementation
- ******************************************************************************/
-package org.eclipse.persistence.json.bind.internal.internalOrdering;
-
-import org.eclipse.persistence.json.bind.model.PropertyModel;
-
-import javax.json.bind.config.PropertyNamingStrategy;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.List;
-
-import static java.util.stream.Collectors.toList;
-
-/**
- * Lexicographical ordering strategy
- *
- * @author David Kral
- */
-public class LexicographicalOrderStrategy extends PropOrderStrategy implements Comparator<PropertyModel> {
-
- @Override
- public List<PropertyModel> sortProperties(Collection<PropertyModel> properties) {
- return properties.stream().sorted(this).collect(toList());
- }
-
- @Override
- public int compare(PropertyModel object1, PropertyModel object2) {
- return object1.getWriteName().compareTo(object2.getWriteName());
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/internalOrdering/PropOrderStrategy.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/internalOrdering/PropOrderStrategy.java
deleted file mode 100644
index b7c13aa..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/internalOrdering/PropOrderStrategy.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * David Kral - initial implementation
- ******************************************************************************/
-package org.eclipse.persistence.json.bind.internal.internalOrdering;
-
-import org.eclipse.persistence.json.bind.model.PropertyModel;
-
-import javax.json.bind.config.PropertyNamingStrategy;
-import java.util.Collection;
-import java.util.List;
-import java.util.Objects;
-
-/**
- * JSONB property ordering
- *
- * @author David Kral
- */
-public abstract class PropOrderStrategy {
-
-
- /**
- * Sorts properties
- *
- * @param properties properties for ordering
- * @return sorted List of properties
- */
- public abstract List<PropertyModel> sortProperties(Collection<PropertyModel> properties);
-
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/internalOrdering/ReverseOrderStrategy.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/internalOrdering/ReverseOrderStrategy.java
deleted file mode 100644
index b3a035b..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/internalOrdering/ReverseOrderStrategy.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * David Kral - initial implementation
- ******************************************************************************/
-package org.eclipse.persistence.json.bind.internal.internalOrdering;
-
-import org.eclipse.persistence.json.bind.model.PropertyModel;
-
-import javax.json.bind.config.PropertyNamingStrategy;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.List;
-
-import static java.util.stream.Collectors.toList;
-
-/**
- * Revers ordering strategy
- *
- * @author David Kral
- */
-public class ReverseOrderStrategy extends PropOrderStrategy implements Comparator<PropertyModel> {
-
- @Override
- public List<PropertyModel> sortProperties(Collection<PropertyModel> properties) {
- return properties.stream().sorted(this).collect(toList());
- }
-
- @Override
- public int compare(PropertyModel object1, PropertyModel object2) {
- return object2.getWriteName().compareTo(object1.getWriteName());
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/naming/CaseInsensitiveStrategy.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/naming/CaseInsensitiveStrategy.java
deleted file mode 100644
index 5e64540..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/naming/CaseInsensitiveStrategy.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.naming;
-
-import javax.json.bind.config.PropertyNamingStrategy;
-import java.util.Objects;
-
-/**
- * Leaves name unmodified during serialization, but ignores case during deserialization.
- * @author Roman Grigoriadi
- */
-public class CaseInsensitiveStrategy implements PropertyNamingStrategy {
-
- @Override
- public String translateName(String propertyName) {
- Objects.requireNonNull(propertyName);
- return propertyName;
- }
-
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/naming/DefaultNamingStrategies.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/naming/DefaultNamingStrategies.java
deleted file mode 100644
index ceb4878..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/naming/DefaultNamingStrategies.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.naming;
-
-import javax.json.bind.config.PropertyNamingStrategy;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Holds and provides instances of known naming strategies.
- *
- * @author Roman Grigoriadi
- */
-public class DefaultNamingStrategies {
-
- /**
- * Map of strategies with its name according to {@link javax.json.bind.config.PropertyNamingStrategy}
- */
- private static final Map<String, PropertyNamingStrategy> strategies;
-
- static {
- Map<String, PropertyNamingStrategy> collector = new HashMap<>();
- collector.put(PropertyNamingStrategy.LOWER_CASE_WITH_UNDERSCORES, new LowerCaseWithUnderscoresStrategy());
- collector.put(PropertyNamingStrategy.LOWER_CASE_WITH_DASHES, new LowerCaseWithDashesStrategy());
- collector.put(PropertyNamingStrategy.UPPER_CAMEL_CASE, new UpperCamelCaseStrategy());
- collector.put(PropertyNamingStrategy.UPPER_CAMEL_CASE_WITH_SPACES, new UpperCamelCaseWithSpacesStrategy());
- collector.put(PropertyNamingStrategy.IDENTITY, new IdentityStrategy());
- collector.put(PropertyNamingStrategy.CASE_INSENSITIVE, new CaseInsensitiveStrategy());
- strategies = Collections.unmodifiableMap(collector);
- }
-
- /**
- * Gets naming conversion strategy by name, see {@link javax.json.bind.config.PropertyNamingStrategy}
- *
- * @param strategyName name not null
- * @return strategy to use for conversion
- */
- public static PropertyNamingStrategy getStrategy(String strategyName) {
- return strategies.get(strategyName);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/naming/IdentityStrategy.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/naming/IdentityStrategy.java
deleted file mode 100644
index df84dd1..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/naming/IdentityStrategy.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.naming;
-
-import javax.json.bind.config.PropertyNamingStrategy;
-import java.util.Objects;
-
-/**
- * Leaves name unmodified.
- * @author Roman Grigoriadi
- */
-public class IdentityStrategy implements PropertyNamingStrategy {
-
- @Override
- public String translateName(String propertyName) {
- Objects.requireNonNull(propertyName);
- return propertyName;
- }
-
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/naming/LowerCaseStrategy.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/naming/LowerCaseStrategy.java
deleted file mode 100644
index 3e7c380..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/naming/LowerCaseStrategy.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.naming;
-
-import javax.json.bind.config.PropertyNamingStrategy;
-import java.nio.CharBuffer;
-import java.util.Objects;
-
-/**
- * Common parent for lowercase strategies.
- * @author Roman Grigoriadi
- */
-public abstract class LowerCaseStrategy implements PropertyNamingStrategy {
-
- @Override
- public String translateName(String propertyName) {
- Objects.requireNonNull(propertyName);
- CharBuffer charBuffer = CharBuffer.allocate(propertyName.length() * 2);
- char last = Character.MIN_VALUE;
- for(int i=0; i<propertyName.length(); i++) {
- final char current = propertyName.charAt(i);
- if (i > 0 && Character.isUpperCase(current) && isLowerCaseCharacter(last)) {
- charBuffer.append(getSerarator());
- }
- charBuffer.append(Character.toLowerCase(current));
- last = current;
- }
- return new String(charBuffer.array(), 0, charBuffer.position());
- }
-
- private boolean isLowerCaseCharacter(char character) {
- return Character.isAlphabetic(character) && Character.isLowerCase(character);
- }
-
- /**
- * Separator for replacing camel case.
- * @return separator
- */
- protected abstract char getSerarator();
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/naming/LowerCaseWithDashesStrategy.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/naming/LowerCaseWithDashesStrategy.java
deleted file mode 100644
index a4d9e76..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/naming/LowerCaseWithDashesStrategy.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.naming;
-
-/**
- * Lower case with dashes
- *
- * <pre>
- * myPropertyName -> my-property-name
- * </pre>
- *
- * @author Roman Grigoriadi
- */
-public class LowerCaseWithDashesStrategy extends LowerCaseStrategy {
-
- public final Character SEPARATOR = '-';
-
- @Override
- protected char getSerarator() {
- return SEPARATOR;
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/naming/LowerCaseWithUnderscoresStrategy.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/naming/LowerCaseWithUnderscoresStrategy.java
deleted file mode 100644
index eb728cc..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/naming/LowerCaseWithUnderscoresStrategy.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.naming;
-
-/**
- * Lower case with underscores
- *
- * <pre>
- * myPropertyName -> my_property_name
- * </pre>
- * @author Roman Grigoriadi
- */
-public class LowerCaseWithUnderscoresStrategy extends LowerCaseStrategy {
-
- public static final Character UNDERSCORE = '_';
-
- @Override
- protected char getSerarator() {
- return UNDERSCORE;
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/naming/UpperCamelCaseStrategy.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/naming/UpperCamelCaseStrategy.java
deleted file mode 100644
index 5c201f4..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/naming/UpperCamelCaseStrategy.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.naming;
-
-import javax.json.bind.config.PropertyNamingStrategy;
-import java.util.Objects;
-
-/**
- * Transforms first letter to upper case.
- *
- * @author Roman Grigoriadi
- */
-public class UpperCamelCaseStrategy implements PropertyNamingStrategy {
-
- @Override
- public String translateName(String propertyName) {
- Objects.requireNonNull(propertyName);
- final char first = Character.toUpperCase(propertyName.charAt(0));
- if (propertyName.length() == 1) {
- return String.valueOf(first);
- }
- return first + propertyName.substring(1, propertyName.length());
- }
-
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/naming/UpperCamelCaseWithSpacesStrategy.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/naming/UpperCamelCaseWithSpacesStrategy.java
deleted file mode 100644
index e739a9a..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/naming/UpperCamelCaseWithSpacesStrategy.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.naming;
-
-import java.nio.CharBuffer;
-
-/**
- * Upper case first character separate words by spaces.
- *
- * @author Roman Grigoriadi
- */
-public class UpperCamelCaseWithSpacesStrategy extends UpperCamelCaseStrategy {
-
- @Override
- public String translateName(String propertyName) {
- String upperCased = super.translateName(propertyName);
- CharBuffer buffer = CharBuffer.allocate(upperCased.length() * 2);
- char last = Character.MIN_VALUE;
- for(int i=0; i<upperCased.length(); i++) {
- char current = upperCased.charAt(i);
- if (i > 0 && Character.isUpperCase(current) && isLowerCaseCharacter(last)) {
- buffer.append(' ');
- }
- last = current;
- buffer.append(current);
- }
- return new String(buffer.array(), 0, buffer.position());
-
- }
-
- private boolean isLowerCaseCharacter(char character) {
- return Character.isAlphabetic(character) && Character.isLowerCase(character);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/properties/MessageKeys.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/properties/MessageKeys.java
deleted file mode 100644
index 58106b0..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/properties/MessageKeys.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * David Král - initial implementation
- ******************************************************************************/
-package org.eclipse.persistence.json.bind.internal.properties;
-
-/**
- * Contains all message keys present in language property files
- *
- * @author David Král
- */
-public enum MessageKeys {
-
- PROCESS_FROM_JSON("processFromJson"),
- PROCESS_TO_JSON("processToJson"),
- CANNOT_MARSHAL_OBJECT("cannotMarshallObject"),
- TYPE_RESOLUTION_ERROR("typeResolutionError"),
- GENERIC_BOUND_NOT_FOUND("genericBoundNotFound"),
- CANT_CONVERT_JSON_VALUE("cantConvertJsonValue"),
- CANT_CREATE_ROOT_INSTANCE("cantCreateRootInstance"),
- NO_DEFAULT_CONSTRUCTOR("noDefaultConstructor"),
- INVOKING_GETTER("invokingGetter"),
- GETTING_VALUE("gettingValue"),
- SETTING_VALUE("settingValue"),
- NO_LOGGER_NAME("noLoggerName"),
- RESOLVE_PARAMETRIZED_TYPE("resolveParametrizedType"),
- CANT_CREATE_INSTANCE("cantCreateInstance"),
- INFER_TYPE_FOR_UNMARSHALL("inferTypeForUnmarshall"),
- NOT_VALUE_TYPE("notValueType"),
- UNEXPECTED_PARSE_EVENT("unexpectedParseEvent"),
- CREATING_HANDLES("creatingHandles"),
- GETTING_VALUE_WITH("gettingValueWith"),
- SETTING_VALUE_WITH("settingValueWith"),
- UNPAIRED_SURROGATE("unpairedSurrogate"),
- ADAPTER_EXCEPTION("adapterException"),
- ADAPTER_FOUND("adapterFound"),
- ADAPTER_INCOMPATIBLE("adapterIncompatible"),
- PROPERTY_ORDER("propertyOrder"),
- UNSUPPORTED_JSONP_SERIALIZER_VALUE("unsupportedJsonpSerializerValue"),
- JSONB_CONFIG_FORMATTING_ILLEGAL_VALUE("Only Boolean type values are supported for JsonbConfig.FORMATTING property."),
- BEAN_MANAGER_NOT_FOUND_JNDI("beanManagerNotFoundJndi"),
- BEAN_MANAGER_NOT_FOUND_NO_PROVIDER("beanManagerNotFoundNoProvider"),
- BEAN_MANAGER_NOT_FOUND_USING_DEFAULT("usingDefaultConstructorInstantiator"),
- IJSON_ENABLED_SINGLE_VALUE("iJsonEnabledSingleValue"),
- PROPERTY_NOT_FOUND_DESERIALIZER("propertyNotFoundDeserializer"),
- SETTING_PROPERTY_DESERIALIZER("settingPropertyDeserializer"),
- CLASS_LOAD_NOT_ALLOWED("classLoadNotAllowed"),
- UNSUPPORTED_DATE_TYPE("dateTypeNotSupported"),
- DATE_PARSE_ERROR("errorParsingDate"),
- OFFSET_DATE_TIME_FROM_MILLIS("offsetDateTimeFromMillis"),
- TIME_TO_EPOCH_MILLIS_ERROR("timeToEpochMillisError"),
- JSONB_CONFIG_PROPERTY_INVALID_TYPE("configPropertyInvalidType"),
- CONVERSION_NOT_SUPPORTED("conversionNotSupported"),
- END_OF_JSON_STRUCTURE("endOfJsonStructure"),
- INVALID_DESERIALIZATION_JSON_TYPE("invalidDeserializationType"),
- ERROR_CALLING_JSONB_CREATOR("errorCallingJsonbCreator"),
- INCOMPATIBLE_FACTORY_CREATOR_RETURN_TYPE("incompatibleFactoryCreatorReturnType"),
- MULTIPLE_JSONB_CREATORS("multipleJsonbCreators"),
- INTERNAL_ERROR("internalError"),
- DESERIALIZE_VALUE_ERROR("deserializeValueError"),
- PARSING_NUMBER("parsingNumber"),
- UNKNOWN_BINARY_DATA_STRATEGY("unknownBinaryDataStrategy"),
- PROPERTY_NAMING_STRATEGY_INVALID("invalidPropertyNamingStrategy")
- ;
-
- /** Message bundle key. */
- final String key;
-
- /**
- * Creates an instance of message bundle key.
- * @param key Message key from bundle.
- */
- MessageKeys(final String key) {
- this.key = key;
- }
-
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/properties/Messages.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/properties/Messages.java
deleted file mode 100644
index 619cd89..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/properties/Messages.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * David Král - initial implementation
- ******************************************************************************/
-package org.eclipse.persistence.json.bind.internal.properties;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.net.URLConnection;
-import java.text.MessageFormat;
-import java.util.Locale;
-import java.util.PropertyResourceBundle;
-import java.util.ResourceBundle;
-
-/**
- * JSONB properties file manager.
- *
- * @author David Král
- */
-public class Messages {
-
- private final static String MESSAGE_BUNDLE = "messages";
- private final static String ENCODING = "UTF-8";
-
- private Messages() {
- }
-
- public static String getMessage(MessageKeys key, Object... objects) {
- return getMessage(key, Locale.getDefault(), objects);
- }
-
- public static String getMessage(MessageKeys key, Locale locale, Object... objects) {
- ResourceBundle messages = ResourceBundle.getBundle(MESSAGE_BUNDLE, locale, new UTF8Control());
- MessageFormat formatter = new MessageFormat(messages.getString(key.key));
- return formatter.format(objects);
- }
-
- static class UTF8Control extends ResourceBundle.Control {
- public ResourceBundle newBundle
- (String baseName, Locale locale, String format, ClassLoader loader, boolean reload)
- throws IllegalAccessException, InstantiationException, IOException
- {
- // The below is a copy of the default implementation.
- String bundleName = toBundleName(baseName, locale);
- String resourceName = toResourceName(bundleName, "properties");
- ResourceBundle bundle = null;
- InputStream stream = null;
- if (reload) {
- URL url = loader.getResource(resourceName);
- if (url != null) {
- URLConnection connection = url.openConnection();
- if (connection != null) {
- connection.setUseCaches(false);
- stream = connection.getInputStream();
- }
- }
- } else {
- stream = loader.getResourceAsStream(resourceName);
- }
- if (stream != null) {
- try {
- // Only this line is changed to make it to read properties files as UTF-8.
- bundle = new PropertyResourceBundle(new InputStreamReader(stream, ENCODING));
- } finally {
- stream.close();
- }
- }
- return bundle;
- }
- }
-
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/AbstractArraySerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/AbstractArraySerializer.java
deleted file mode 100644
index 2ca292d..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/AbstractArraySerializer.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.AbstractContainerSerializer;
-import org.eclipse.persistence.json.bind.internal.ReflectionUtils;
-import org.eclipse.persistence.json.bind.internal.unmarshaller.ContainerModel;
-import org.eclipse.persistence.json.bind.internal.unmarshaller.EmbeddedItem;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-import org.eclipse.persistence.json.bind.model.JsonContext;
-
-import javax.json.stream.JsonGenerator;
-import java.lang.reflect.GenericArrayType;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-
-/**
- * Common serializer for arrays.
- *
- * @author Roman Grigoriadi
- */
-public abstract class AbstractArraySerializer<T> extends AbstractContainerSerializer<T> implements EmbeddedItem {
-
- protected final JsonBindingModel containerModel;
-
- protected final Type arrayValType;
-
- protected AbstractArraySerializer(SerializerBuilder builder) {
- super(builder);
- arrayValType = resolveArrayType();
- containerModel = new ContainerModel(arrayValType, resolveContainerModelCustomization(arrayValType, builder.getJsonbContext()),
- JsonContext.JSON_ARRAY);
- }
-
- private Type resolveArrayType() {
- if (getRuntimeType() == null || getRuntimeType() == Object.class) {
- return Object.class;
- } else if (getRuntimeType() instanceof ParameterizedType) {
- return ReflectionUtils.resolveType(this, ((ParameterizedType) getRuntimeType()).getActualTypeArguments()[0]);
- } else if (getRuntimeType() instanceof GenericArrayType) {
- return ReflectionUtils.resolveRawType(this, ((GenericArrayType) getRuntimeType()).getGenericComponentType());
- } else {
- return ReflectionUtils.getRawType(getRuntimeType()).getComponentType();
- }
- }
-
-
- @Override
- protected void writeStart(JsonGenerator generator) {
- generator.writeStartArray();
- }
-
- @Override
- protected void writeStart(String key, JsonGenerator generator) {
- generator.writeStartArray(key);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/AbstractDateTimeDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/AbstractDateTimeDeserializer.java
deleted file mode 100644
index a8f0789..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/AbstractDateTimeDeserializer.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.ProcessingContext;
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.bind.annotation.JsonbDateFormat;
-import java.lang.reflect.Type;
-import java.time.Instant;
-import java.time.format.DateTimeFormatter;
-import java.time.temporal.TemporalAccessor;
-import java.util.Locale;
-
-/**
- * Abstract class for converting date objects from {@link java.time}.
- *
- * @author Roman Grigoriadi
- */
-
-public abstract class AbstractDateTimeDeserializer<T extends TemporalAccessor> extends AbstractValueTypeDeserializer<T> {
-
-
- public AbstractDateTimeDeserializer(Class<T> clazz, JsonBindingModel model) {
- super(clazz, model);
- }
-
- @Override
- public T deserialize(String jsonValue, Unmarshaller unmarshaller, Type rtType) {
- final JsonbDateFormatter formatter = unmarshaller.getJsonbContext().getComponentMatcher().getDateFormatter(model);
- if (JsonbDateFormat.TIME_IN_MILLIS.equals(formatter.getFormat())) {
- return fromInstant(Instant.ofEpochMilli(Long.parseLong(jsonValue)));
- } else if (formatter.getDateTimeFormatter() != null) {
- return parseWithFormatter(jsonValue, formatter.getDateTimeFormatter());
- }
- return parseDefault(jsonValue, unmarshaller.getJsonbContext().getLocale(formatter.getLocale()));
- }
-
- /**
- * Construct date object from an instant containing epoch millisecond.
- * If date object supports zone offset / zone id, system default is used and warning is logged.
- *
- * @param instant instant to construct from
- * @return date object
- */
- protected abstract T fromInstant(Instant instant);
-
- /**
- * Parse {@link java.time} date object with default formatter.
- * Different default formatter for each date object type is used.
- *
- * @param jsonValue string value to parse from
- * @param locale annotated locale or default
- * @return parsed date object
- */
- protected abstract T parseDefault(String jsonValue, Locale locale);
-
- /**
- * Parse {@link java.time} date object with provided formatter.
- *
- * @param jsonValue string value to parse from
- * @param formatter a formatter to use
- * @return parsed date object
- */
- protected abstract T parseWithFormatter(String jsonValue, DateTimeFormatter formatter);
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/AbstractDateTimeSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/AbstractDateTimeSerializer.java
deleted file mode 100644
index 9871760..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/AbstractDateTimeSerializer.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.JsonbContext;
-import org.eclipse.persistence.json.bind.internal.Marshaller;
-import org.eclipse.persistence.json.bind.model.PropertyModel;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.bind.annotation.JsonbDateFormat;
-import javax.json.bind.serializer.SerializationContext;
-import javax.json.stream.JsonGenerator;
-import java.time.Instant;
-import java.time.temporal.TemporalAccessor;
-import java.util.Locale;
-
-/**
- * Abstract class for converting date objects from {@link java.time}.
- *
- * @author Roman Grigoriadi
- */
-
-public abstract class AbstractDateTimeSerializer<T extends TemporalAccessor> extends AbstractValueTypeSerializer<T> {
-
-
- /**
- * Construct serializer with its class.
- * @param clazz class
- */
- public AbstractDateTimeSerializer(Class<T> clazz, JsonBindingModel model) {
- super(model);
- }
-
- /**
- * Serializes an object to JSON.
- *
- * @param obj object to serialize
- * @param generator JSON generator to use
- * @param ctx JSONB mapper context
- */
- @Override
- public void serialize(T obj, JsonGenerator generator, SerializationContext ctx) {
- final JsonbContext jsonbContext = ((Marshaller) ctx).getJsonbContext();
- final JsonbDateFormatter formatter = jsonbContext.getComponentMatcher().getDateFormatter(model);
- if (model instanceof PropertyModel) {
- generator.write(((PropertyModel)model).getPropertyName(), toJson(obj, formatter, jsonbContext));
- } else {
- generator.write(toJson(obj, formatter, jsonbContext));
- }
- }
-
- public String toJson(T object, JsonbDateFormatter formatter, JsonbContext jsonbContext) {
- if (JsonbDateFormat.TIME_IN_MILLIS.equals(formatter.getFormat())) {
- return String.valueOf(toInstant(object).toEpochMilli());
- } else if (formatter.getDateTimeFormatter() != null) {
- return formatter.getDateTimeFormatter().format(object);
- }
- return formatDefault(object, jsonbContext.getLocale(formatter.getLocale()));
- }
-
- /**
- * Convert java.time object to epoch milliseconds instant. Discards zone offset and zone id information.
- *
- * @param value date object to convert
- * @return instant
- */
- protected abstract Instant toInstant(T value);
-
- /**
- * Format with default formatter for a given {@link java.time} date object.
- * Different default formatter for each date object type is used.
- *
- * @param value date object
- * @param locale locale from annotation / default not null
- * @return formatted date obj as string
- */
- protected abstract String formatDefault(T value, Locale locale);
-
- @Override
- protected void serialize(T obj, JsonGenerator generator, String key, Marshaller marshaller) {
- throw new UnsupportedOperationException("Not supported in DateTimeSerializer");
- }
-
- @Override
- protected void serialize(T obj, JsonGenerator generator, Marshaller marshaller) {
- throw new UnsupportedOperationException("Not supported in DateTimeSerializer");
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/AbstractJsonpSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/AbstractJsonpSerializer.java
deleted file mode 100644
index 7f1e007..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/AbstractJsonpSerializer.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.AbstractContainerSerializer;
-
-import javax.json.JsonValue;
-
-/**
- * Common serializer functionality.
- *
- * @author Roman Grigoriadi
- */
-public abstract class AbstractJsonpSerializer<T extends JsonValue> extends AbstractContainerSerializer<T> {
-
- protected AbstractJsonpSerializer(SerializerBuilder builder) {
- super(builder);
- }
-
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/AbstractNumberDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/AbstractNumberDeserializer.java
deleted file mode 100644
index 813565e..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/AbstractNumberDeserializer.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.JsonbContext;
-import org.eclipse.persistence.json.bind.internal.ProcessingContext;
-import org.eclipse.persistence.json.bind.internal.properties.MessageKeys;
-import org.eclipse.persistence.json.bind.internal.properties.Messages;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.bind.JsonbException;
-import java.text.DecimalFormat;
-import java.text.NumberFormat;
-import java.text.ParseException;
-import java.util.Optional;
-
-/**
- * Common serializer for numbers, using number format.
- *
- * @author Roman Grigoriadi
- */
-public abstract class AbstractNumberDeserializer<T extends Number> extends AbstractValueTypeDeserializer<T> {
-
- public AbstractNumberDeserializer(Class<T> clazz, JsonBindingModel model) {
- super(clazz, model);
- }
-
-
- protected final Optional<Number> deserializeForamtted(String jsonValue, boolean integerOnly, JsonbContext jsonbContext) {
- final JsonbNumberFormatter numberFormat = model.getCustomization().getNumberFormat();
- if (numberFormat != null) {
- //TODO perf consider synchronizing on format instance or per thread cache.
- final NumberFormat format = NumberFormat.getInstance(jsonbContext.getLocale(numberFormat.getLocale()));
- ((DecimalFormat)format).applyPattern(numberFormat.getFormat());
- format.setParseIntegerOnly(integerOnly);
- try {
- return Optional.of(format.parse(jsonValue));
- } catch (ParseException e) {
- throw new JsonbException(Messages.getMessage(MessageKeys.PARSING_NUMBER, jsonValue, numberFormat.getFormat()));
- }
- }
- return Optional.empty();
- }
-
-
-
-
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/AbstractNumberSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/AbstractNumberSerializer.java
deleted file mode 100644
index 1bc454f..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/AbstractNumberSerializer.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.JsonbContext;
-import org.eclipse.persistence.json.bind.internal.Marshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.stream.JsonGenerator;
-import java.text.DecimalFormat;
-import java.text.NumberFormat;
-import java.util.function.Consumer;
-
-/**
- * Common serializer for numbers, using number format.
- *
- * @author Roman Grigoriadi
- */
-public abstract class AbstractNumberSerializer<T extends Number> extends AbstractValueTypeSerializer<T> {
-
- public AbstractNumberSerializer(Class<T> clazz, JsonBindingModel model) {
- super(model);
- }
-
- @Override
- protected final void serialize(T obj, JsonGenerator generator, String key, Marshaller marshaller) {
- if (!serializeFormatted(obj, formatted -> generator.write(key, formatted), marshaller.getJsonbContext())) {
- serializeNonFormatted(obj, generator, key);
- }
- }
-
- /**
- * Serialize raw number when NumberFormat is not present.
- * @param obj number
- * @param generator generator to use
- * @param key json key
- */
- protected abstract void serializeNonFormatted(T obj, JsonGenerator generator, String key);
-
-
- @Override
- protected void serialize(T obj, JsonGenerator generator, Marshaller marshaller) {
- if (!serializeFormatted(obj, generator::write, marshaller.getJsonbContext())) {
- serializeNonFormatted(obj, generator);
- }
- }
-
- /**
- * Serialize raw number when NumberFormat is not present.
- * @param obj number
- * @param generator generator to use
- */
- protected abstract void serializeNonFormatted(T obj, JsonGenerator generator);
-
- private boolean serializeFormatted(T obj, Consumer<String> formattedConsumer, JsonbContext jsonbContext) {
- final JsonbNumberFormatter numberFormat = model.getCustomization().getNumberFormat();
- if (numberFormat != null) {
- //TODO perf consider synchronizing on format instance or per thread cache.
- final NumberFormat format = NumberFormat.getInstance(jsonbContext.getLocale(numberFormat.getLocale()));
- ((DecimalFormat)format).applyPattern(numberFormat.getFormat());
- formattedConsumer.accept(format.format(obj));
- return true;
- }
- return false;
- }
-
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/AbstractValueTypeDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/AbstractValueTypeDeserializer.java
deleted file mode 100644
index 4d9d949..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/AbstractValueTypeDeserializer.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.JsonbParser;
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.bind.serializer.DeserializationContext;
-import javax.json.bind.serializer.JsonbDeserializer;
-import javax.json.stream.JsonParser;
-import java.lang.reflect.Type;
-
-/**
- * Common type for all supported value type serializers.
- * @author Roman Grigoriadi
- */
-public abstract class AbstractValueTypeDeserializer<T> implements JsonbDeserializer<T> {
-
- private final Class<T> clazz;
-
- protected final JsonBindingModel model;
-
- /**
- * New instance.
- * @param clazz clazz to work with
- * @param model
- */
- public AbstractValueTypeDeserializer(Class<T> clazz, JsonBindingModel model) {
- this.clazz = clazz;
- this.model = model;
- }
-
- /**
- * Extracts single string value for conversion.
- * @param parser parser to get value from
- * @param ctx unmarshaller
- * @param rtType return type
- * @return deserialized object
- */
- @Override
- public T deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) {
- Unmarshaller unmarshaller = (Unmarshaller) ctx;
- final JsonParser.Event event = ((JsonbParser) parser).moveToValue();
- if (event == JsonParser.Event.VALUE_NULL) {
- return null;
- }
-
- final String value = parser.getString();
- return deserialize(value, unmarshaller, rtType);
- }
-
- /**
- * Convert string value to object.
- * @param jsonValue json value
- * @param unmarshaller unmarshaller instance
- * @param rtType
- * @return deserialized object
- */
- protected abstract T deserialize(String jsonValue, Unmarshaller unmarshaller, Type rtType);
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/AbstractValueTypeSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/AbstractValueTypeSerializer.java
deleted file mode 100644
index c6ac5f3..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/AbstractValueTypeSerializer.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.Marshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-import org.eclipse.persistence.json.bind.model.JsonContext;
-
-import javax.json.bind.serializer.JsonbSerializer;
-import javax.json.bind.serializer.SerializationContext;
-import javax.json.stream.JsonGenerator;
-
-/**
- * Common type for all supported type serializers.
- * @author Roman Grigoriadi
- */
-public abstract class AbstractValueTypeSerializer<T> implements JsonbSerializer<T> {
-
- protected final JsonBindingModel model;
-
- /**
- * New instance.
- * @param model
- */
- public AbstractValueTypeSerializer(JsonBindingModel model) {
- this.model = model;
- }
-
- /**
- * Serializes an object to JSON.
- *
- * @param obj object to serialize
- * @param generator JSON generator to use
- * @param ctx JSONB mapper context
- */
- @Override
- public void serialize(T obj, JsonGenerator generator, SerializationContext ctx) {
- Marshaller marshaller = (Marshaller) ctx;
- if (model.getContext() == JsonContext.JSON_OBJECT) {
- serialize(obj, generator, model.getWriteName(), marshaller);
- } else {
- serialize(obj, generator, marshaller);
- }
- }
-
- protected abstract void serialize(T obj, JsonGenerator generator, String key, Marshaller marshaller);
-
- protected abstract void serialize(T obj, JsonGenerator generator, Marshaller marshaller);
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/AdaptedObjectSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/AdaptedObjectSerializer.java
deleted file mode 100644
index 1266dc8..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/AdaptedObjectSerializer.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.Marshaller;
-import org.eclipse.persistence.json.bind.internal.adapter.AdapterBinding;
-import org.eclipse.persistence.json.bind.internal.properties.MessageKeys;
-import org.eclipse.persistence.json.bind.internal.properties.Messages;
-import org.eclipse.persistence.json.bind.internal.unmarshaller.CurrentItem;
-import org.eclipse.persistence.json.bind.model.ClassModel;
-import org.eclipse.persistence.json.bind.model.Customization;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-import org.eclipse.persistence.json.bind.model.JsonContext;
-
-import javax.json.bind.JsonbException;
-import javax.json.bind.adapter.JsonbAdapter;
-import javax.json.bind.serializer.JsonbSerializer;
-import javax.json.bind.serializer.SerializationContext;
-import javax.json.stream.JsonGenerator;
-import java.lang.reflect.Type;
-
-/**
- * Serializer for adapted object.
- * Converts object using adapter first, than seriazizes result with standard process.
- * @author Roman Grigoriadi
- */
-public class AdaptedObjectSerializer<T, A> implements CurrentItem<T>, JsonbSerializer<T> {
-
- private final static class AdaptedObjectSerializerModel implements JsonBindingModel {
-
- private final JsonBindingModel wrapperSerializerModel;
-
- private final Type adaptedType;
-
- public AdaptedObjectSerializerModel(JsonBindingModel wrapperSerializerModel, Type adaptedType) {
- this.wrapperSerializerModel = wrapperSerializerModel;
- this.adaptedType = adaptedType;
- }
-
- @Override
- public String getWriteName() {
- return wrapperSerializerModel.getWriteName();
- }
-
- /**
- * Array context if root.
- */
- @Override
- public JsonContext getContext() {
- return wrapperSerializerModel != null ?
- wrapperSerializerModel.getContext() : JsonContext.JSON_ARRAY;
- }
-
- /**
- * Get wrapper customization or empty if wrapper not present (root).
- */
- @Override
- public Customization getCustomization() {
- return wrapperSerializerModel != null ?
- wrapperSerializerModel.getCustomization() : null;
- }
-
-
- @Override
- public Type getType() {
- return adaptedType;
- }
- }
-
- private final JsonBindingModel model;
-
- private final AdapterBinding adapterInfo;
-
- public AdaptedObjectSerializer(JsonBindingModel model, AdapterBinding adapter) {
- this.model = new AdaptedObjectSerializerModel(model, adapter.getToType());
- this.adapterInfo = adapter;
- }
-
- @Override
- public void serialize(T obj, JsonGenerator generator, SerializationContext ctx) {
- try {
- final JsonbAdapter<T, A> adapter = (JsonbAdapter<T, A>) adapterInfo.getAdapter();
- A adapted = adapter.adaptToJson(obj);
- final JsonbSerializer<A> serializer = resolveSerializer((Marshaller) ctx, adapted);
- serializer.serialize(adapted, generator, ctx);
- } catch (Exception e) {
- throw new JsonbException(Messages.getMessage(MessageKeys.ADAPTER_EXCEPTION, adapterInfo.getBindingType(), adapterInfo.getToType(), adapterInfo.getAdapter().getClass()), e);
- }
- }
-
- @SuppressWarnings("unchekced")
- private JsonbSerializer<A> resolveSerializer(Marshaller ctx, A adapted) {
- final ContainerSerializerProvider cached = ctx.getMappingContext().getSerializerProvider(adapted.getClass());
- if (cached != null) {
- return (JsonbSerializer<A>) cached.provideSerializer(this, adapted.getClass(), null, model);
- }
- return (JsonbSerializer<A>) new SerializerBuilder(ctx.getJsonbContext()).withObjectClass(adapted.getClass()).withModel(model).withWrapper(this).build();
- }
-
-
- /**
- * Class model containing property for this item.
- *
- * @return class model
- */
- @Override
- public ClassModel getClassModel() {
- return null;
- }
-
- /**
- * Item wrapper. Null only in case of a root item.
- *
- * @return wrapper item of this item
- */
- @Override
- public CurrentItem<?> getWrapper() {
- return null;
- }
-
- /**
- * Binding model of this item in wrapper. May be JavaBean property or a container like collection.
- *
- * @return wrapper model.
- */
- @Override
- public JsonBindingModel getWrapperModel() {
- return model;
- }
-
- /**
- * Runtime type of a class. Can be a class, ParameterizedType, or TypeVariable.
- * When a field or a class is declared including generic information this will return runtime type info.
- *
- * @return
- */
- @Override
- public Type getRuntimeType() {
- return null;
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/BigDecimalTypeDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/BigDecimalTypeDeserializer.java
deleted file mode 100644
index efe5469..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/BigDecimalTypeDeserializer.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import java.lang.reflect.Type;
-import java.math.BigDecimal;
-
-/**
- * Deserialize bigdecimal.
- * @author David Král
- */
-public class BigDecimalTypeDeserializer extends AbstractNumberDeserializer<BigDecimal> {
-
- BigDecimalTypeDeserializer(JsonBindingModel model) {
- super(BigDecimal.class, model);
- }
-
- @Override
- public BigDecimal deserialize(String jsonValue, Unmarshaller unmarshaller, Type rtType) {
- return deserializeForamtted(jsonValue, false, unmarshaller.getJsonbContext()).map(num->new BigDecimal(num.toString()))
- .orElseGet(()->new BigDecimal(jsonValue));
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/BigDecimalTypeSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/BigDecimalTypeSerializer.java
deleted file mode 100644
index 4bbd0ea..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/BigDecimalTypeSerializer.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.stream.JsonGenerator;
-import java.math.BigDecimal;
-
-/**
- * Serialize {@link BigDecimal}
- * @author David Král
- */
-public class BigDecimalTypeSerializer extends AbstractNumberSerializer<BigDecimal> {
-
- public BigDecimalTypeSerializer(JsonBindingModel model) {
- super(BigDecimal.class, model);
- }
-
- @Override
- protected void serializeNonFormatted(BigDecimal obj, JsonGenerator generator, String key) {
- generator.write(key, obj);
- }
-
- @Override
- protected void serializeNonFormatted(BigDecimal obj, JsonGenerator generator) {
- generator.write(obj);
- }
-
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/BigIntegerTypeDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/BigIntegerTypeDeserializer.java
deleted file mode 100644
index 6bbb436..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/BigIntegerTypeDeserializer.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import java.lang.reflect.Type;
-import java.math.BigInteger;
-
-/**
- * Deserialize {@link BigInteger}.
- * @author David Král
- */
-public class BigIntegerTypeDeserializer extends AbstractNumberDeserializer<BigInteger> {
-
- public BigIntegerTypeDeserializer(JsonBindingModel model) {
- super(BigInteger.class, model);
- }
-
- @Override
- public BigInteger deserialize(String jsonValue, Unmarshaller unmarshaller, Type rtType) {
- return deserializeForamtted(jsonValue, true, unmarshaller.getJsonbContext()).map(num->new BigInteger(num.toString()))
- .orElseGet(()->new BigInteger(jsonValue));
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/BigIntegerTypeSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/BigIntegerTypeSerializer.java
deleted file mode 100644
index 27a1e92..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/BigIntegerTypeSerializer.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.stream.JsonGenerator;
-import java.math.BigInteger;
-
-/**
- * Serialize {@link BigInteger}
- * @author David Král
- */
-public class BigIntegerTypeSerializer extends AbstractNumberSerializer<BigInteger> {
-
- public BigIntegerTypeSerializer(JsonBindingModel model) {
- super(BigInteger.class, model);
- }
-
- @Override
- protected void serializeNonFormatted(BigInteger obj, JsonGenerator generator, String key) {
- generator.write(key, obj);
- }
-
- @Override
- protected void serializeNonFormatted(BigInteger obj, JsonGenerator generator) {
- generator.write(obj);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/BooleanTypeDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/BooleanTypeDeserializer.java
deleted file mode 100644
index 013937c..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/BooleanTypeDeserializer.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.JsonbParser;
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-import org.eclipse.persistence.json.bind.internal.properties.MessageKeys;
-import org.eclipse.persistence.json.bind.internal.properties.Messages;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.bind.JsonbException;
-import javax.json.bind.serializer.DeserializationContext;
-import javax.json.stream.JsonParser;
-import java.lang.reflect.Type;
-
-/**
- * @author David Král
- */
-public class BooleanTypeDeserializer extends AbstractValueTypeDeserializer<Boolean> {
-
- public BooleanTypeDeserializer(JsonBindingModel model) {
- super(Boolean.class, model);
- }
-
- @Override
- public Boolean deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) {
- final JsonParser.Event event = ((JsonbParser) parser).moveToValue();
- switch (event) {
- case VALUE_TRUE:
- return Boolean.TRUE;
- case VALUE_FALSE:
- return Boolean.FALSE;
- case VALUE_STRING:
- return Boolean.parseBoolean(parser.getString());
- default:
- throw new JsonbException(Messages.getMessage(MessageKeys.INTERNAL_ERROR, "Unknown JSON value: " + event));
- }
- }
-
- @Override
- public Boolean deserialize(String jsonValue, Unmarshaller unmarshaller, Type rtType) {
- // TODO: Fix API.
- // Unfortunately, the JSON API doesn't have a getBooleanValue method, so we need to override
- // the other deserialize method and parse the value manually
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/BooleanTypeSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/BooleanTypeSerializer.java
deleted file mode 100644
index 44f04df..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/BooleanTypeSerializer.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.Marshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.stream.JsonGenerator;
-
-/**
- * @author David Král
- */
-public class BooleanTypeSerializer extends AbstractValueTypeSerializer<Boolean> {
-
- public BooleanTypeSerializer(JsonBindingModel model) {
- super(model);
- }
-
- @Override
- protected void serialize(Boolean obj, JsonGenerator generator, String key, Marshaller marshaller) {
- generator.write(key, String.valueOf(obj));
- }
-
- @Override
- protected void serialize(Boolean obj, JsonGenerator generator, Marshaller marshaller) {
- generator.write(String.valueOf(obj));
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ByteArrayBase64Serializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ByteArrayBase64Serializer.java
deleted file mode 100644
index 4f65bc4..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ByteArrayBase64Serializer.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.Marshaller;
-import org.eclipse.persistence.json.bind.internal.properties.MessageKeys;
-import org.eclipse.persistence.json.bind.internal.properties.Messages;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.bind.JsonbException;
-import javax.json.bind.config.BinaryDataStrategy;
-import javax.json.stream.JsonGenerator;
-import java.util.Base64;
-
-/**
- * Serializes byte array with Base64.
- *
- * @author Roman Grigoriadi
- */
-public class ByteArrayBase64Serializer extends AbstractValueTypeSerializer<byte[]> {
-
- /**
- * New instance.
- *
- * @param clazz clazz to work with
- * @param model
- */
- public ByteArrayBase64Serializer(Class<byte[]> clazz, JsonBindingModel model) {
- super(model);
- }
-
- @Override
- protected void serialize(byte[] obj, JsonGenerator generator, String key, Marshaller marshaller) {
- generator.write(key, getEncoder(marshaller.getJsonbContext().getBinaryDataStrategy()).encodeToString(obj));
- }
-
- @Override
- protected void serialize(byte[] obj, JsonGenerator generator, Marshaller marshaller) {
- generator.write(getEncoder(marshaller.getJsonbContext().getBinaryDataStrategy()).encodeToString(obj));
- }
-
- private Base64.Encoder getEncoder(String strategy) {
- switch (strategy) {
- case BinaryDataStrategy.BASE_64:
- return Base64.getEncoder();
- case BinaryDataStrategy.BASE_64_URL:
- return Base64.getUrlEncoder();
- default:
- throw new JsonbException(Messages.getMessage(MessageKeys.INTERNAL_ERROR,
- "Invalid strategy: " + strategy));
- }
- }
-
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ByteArraySerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ByteArraySerializer.java
deleted file mode 100644
index d151d80..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ByteArraySerializer.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import javax.json.bind.serializer.SerializationContext;
-import javax.json.stream.JsonGenerator;
-
-/**
- * Serializes byte array as JSON array of ints.
- *
- * @author Roman Grigoriadi
- */
-public class ByteArraySerializer extends AbstractArraySerializer<byte[]> {
-
- protected ByteArraySerializer(SerializerBuilder builder) {
- super(builder);
- }
-
- @Override
- protected void serializeInternal(byte[] obj, JsonGenerator generator, SerializationContext ctx) {
- for (byte b : obj) {
- generator.write(b);
- }
- }
-
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ByteTypeDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ByteTypeDeserializer.java
deleted file mode 100644
index 2f0fcc9..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ByteTypeDeserializer.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import java.lang.reflect.Type;
-
-/**
- * @author David Král
- */
-public class ByteTypeDeserializer extends AbstractNumberDeserializer<Byte> {
-
- public ByteTypeDeserializer(JsonBindingModel model) {
- super(Byte.class, model);
- }
-
- @Override
- protected Byte deserialize(String value, Unmarshaller unmarshaller, Type rtType) {
- return deserializeForamtted(value, true, unmarshaller.getJsonbContext()).map(num->Byte.parseByte(num.toString()))
- .orElseGet(()->Byte.parseByte(value));
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ByteTypeSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ByteTypeSerializer.java
deleted file mode 100644
index 216056a..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ByteTypeSerializer.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.stream.JsonGenerator;
-
-/**
- * @author David Král
- */
-public class ByteTypeSerializer extends AbstractNumberSerializer<Byte> {
-
- public ByteTypeSerializer(JsonBindingModel model) {
- super(Byte.class, model);
- }
-
- @Override
- protected void serializeNonFormatted(Byte obj, JsonGenerator generator, String key) {
- generator.write(key, obj);
- }
-
- @Override
- protected void serializeNonFormatted(Byte obj, JsonGenerator generator) {
- generator.write(obj);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/CalendarTypeDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/CalendarTypeDeserializer.java
deleted file mode 100644
index 69ed886..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/CalendarTypeDeserializer.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.JsonbContext;
-import org.eclipse.persistence.json.bind.internal.ProcessingContext;
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.bind.annotation.JsonbDateFormat;
-import java.lang.reflect.Type;
-import java.time.Instant;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.ZoneId;
-import java.time.ZonedDateTime;
-import java.time.format.DateTimeFormatter;
-import java.time.temporal.ChronoField;
-import java.time.temporal.TemporalAccessor;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.Locale;
-
-/**
- * @author David Král
- */
-public class CalendarTypeDeserializer extends AbstractValueTypeDeserializer<Calendar> {
-
- private final Calendar calendarTemplate;
-
-
- public CalendarTypeDeserializer(JsonBindingModel model) {
- super(Calendar.class, model);
- calendarTemplate = Calendar.getInstance();
- calendarTemplate.clear();
- }
-
- /**
- * Parses with ISO_DATE_TIME format and converts to util.Calendar thereafter.
- * TODO PERF subject to reconsider if conversion between java.time and java.util outweights threadsafe java.time formatter.
- * @param jsonValue value to parse
- * @param locale locale
- * @return epoch millisecond
- */
- private Long parseDefaultDateTime(String jsonValue, Locale locale) {
- DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ISO_DATE_TIME.withLocale(locale);
- final TemporalAccessor temporal = dateTimeFormatter.parse(jsonValue);
- //With timezone
- if (temporal.isSupported(ChronoField.OFFSET_SECONDS)) {
- final ZonedDateTime zdt = ZonedDateTime.from(temporal);
- return zdt.toInstant().toEpochMilli();
- }
- //No timezone
- LocalDateTime dateTime = LocalDateTime.from(temporal);
- return dateTime.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
- }
-
- private Date parseDefaultDate(String jsonValue, Locale locale) {
- DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ISO_DATE.withLocale(locale);
- LocalDate localDate = LocalDate.parse(jsonValue, dateTimeFormatter);
- return Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
- }
-
- @Override
- protected Calendar deserialize(String jsonValue, Unmarshaller unmarshaller, Type rtType) {
- final JsonbContext jsonbContext = unmarshaller.getJsonbContext();
- final JsonbDateFormatter formatter = jsonbContext.getComponentMatcher().getDateFormatter(model);
- Calendar result = (Calendar) calendarTemplate.clone();
- final String format = formatter.getFormat();
- if (JsonbDateFormat.TIME_IN_MILLIS.equals(format)) {
- result.setTimeInMillis(Long.parseLong(jsonValue));
- return result;
- }
-
- Locale locale = jsonbContext.getLocale(formatter.getLocale());
- if (JsonbDateFormat.DEFAULT_FORMAT.equals(format)) {
- final boolean timed = jsonValue.contains("T");
- if (timed) {
- result.setTimeInMillis(parseDefaultDateTime(jsonValue, locale));
- return result;
- } else {
- result.setTime(parseDefaultDate(jsonValue, locale));
- return result;
- }
-
- }
-
- DateTimeFormatter customFormat = DateTimeFormatter.ofPattern(format, locale);
- final TemporalAccessor parsed = customFormat.parse(jsonValue);
- result.setTime(new Date(Instant.from(parsed).toEpochMilli()));
- return result;
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/CalendarTypeSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/CalendarTypeSerializer.java
deleted file mode 100644
index 4c1685a..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/CalendarTypeSerializer.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.JsonbContext;
-import org.eclipse.persistence.json.bind.internal.Marshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-import org.eclipse.persistence.json.bind.model.PropertyModel;
-
-import javax.json.bind.JsonbConfig;
-import javax.json.bind.annotation.JsonbDateFormat;
-import javax.json.bind.serializer.SerializationContext;
-import javax.json.stream.JsonGenerator;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.time.ZonedDateTime;
-import java.time.format.DateTimeFormatter;
-import java.util.Calendar;
-import java.util.Locale;
-import java.util.Optional;
-
-/**
- * @author David Král
- */
-public class CalendarTypeSerializer extends AbstractValueTypeSerializer<Calendar> {
-
- private final Calendar calendarTemplate;
-
-
- public CalendarTypeSerializer(JsonBindingModel model) {
- super(model);
- calendarTemplate = Calendar.getInstance();
- calendarTemplate.clear();
- }
-
-
- private String toJson(Calendar object, JsonbDateFormatter formatter, JsonbContext jsonbContext) {
- if (JsonbDateFormat.TIME_IN_MILLIS.equals(formatter.getFormat())) {
- return String.valueOf(object.getTime().getTime());
- }
-
- Locale locale = jsonbContext.getLocale(formatter.getLocale());
- if (JsonbDateFormat.DEFAULT_FORMAT.equals(formatter.getFormat())) {
- final Optional<Object> strictJson =
- jsonbContext.getConfig().getProperty(JsonbConfig.STRICT_IJSON);
-
- //Use ISO_DATE_TIME, convert to java.time first
- //TODO PERF subject to reconsider if conversion between java.time and java.util outweights threadsafe java.time formatter.
- if (strictJson.isPresent() && (Boolean) strictJson.get()
- || object.isSet(Calendar.HOUR) || object.isSet(Calendar.HOUR_OF_DAY)) {
-
- ZonedDateTime zdt = ZonedDateTime.ofInstant(object.toInstant(), object.getTimeZone().toZoneId());
- return DateTimeFormatter.ISO_DATE_TIME.withLocale(locale).format(zdt);
- }
- final DateFormat defaultFormat = new SimpleDateFormat(JsonbDateFormatter.ISO_8601_DATE_FORMAT, locale);
- defaultFormat.setTimeZone(object.getTimeZone());
- return defaultFormat.format(object.getTime());
- }
-
- DateFormat custom = new SimpleDateFormat(formatter.getFormat(), locale);
- custom.setTimeZone(object.getTimeZone());
- return custom.format(object.getTime());
- }
-
- @Override
- public void serialize(Calendar obj, JsonGenerator generator, SerializationContext ctx) {
- final Marshaller marshaller = (Marshaller) ctx;
- final JsonbDateFormatter formatter = marshaller.getJsonbContext().getComponentMatcher().getDateFormatter(model);
- if (model instanceof PropertyModel) {
- generator.write(((PropertyModel)model).getPropertyName(), toJson(obj, formatter, marshaller.getJsonbContext()));
- } else {
- generator.write(toJson(obj, formatter, marshaller.getJsonbContext()));
- }
- }
-
- @Override
- protected void serialize(Calendar obj, JsonGenerator generator, String key, Marshaller marshaller) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected void serialize(Calendar obj, JsonGenerator generator, Marshaller marshaller) {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/CharacterTypeDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/CharacterTypeDeserializer.java
deleted file mode 100644
index 3c36db0..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/CharacterTypeDeserializer.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import java.lang.reflect.Type;
-
-/**
- * @author David Král
- */
-public class CharacterTypeDeserializer extends AbstractValueTypeDeserializer<Character> {
-
- public CharacterTypeDeserializer(JsonBindingModel model) {
- super(Character.class, model);
- }
-
-
- @Override
- protected Character deserialize(String value, Unmarshaller unmarshaller, Type rtType) {
- return value.charAt(0);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/CharacterTypeSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/CharacterTypeSerializer.java
deleted file mode 100644
index 8a64088..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/CharacterTypeSerializer.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.Marshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.stream.JsonGenerator;
-
-/**
- * @author David Král
- */
-public class CharacterTypeSerializer extends AbstractValueTypeSerializer<Character> {
-
- public CharacterTypeSerializer(JsonBindingModel model) {
- super(model);
- }
-
- @Override
- protected void serialize(Character obj, JsonGenerator generator, String key, Marshaller marshaller) {
- generator.write(key, String.valueOf(obj));
- }
-
- @Override
- protected void serialize(Character obj, JsonGenerator generator, Marshaller marshaller) {
- generator.write(String.valueOf(obj));
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/CollectionSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/CollectionSerializer.java
deleted file mode 100644
index dbb95d3..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/CollectionSerializer.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.AbstractContainerSerializer;
-import org.eclipse.persistence.json.bind.internal.Marshaller;
-import org.eclipse.persistence.json.bind.internal.ReflectionUtils;
-import org.eclipse.persistence.json.bind.internal.unmarshaller.ContainerModel;
-import org.eclipse.persistence.json.bind.internal.unmarshaller.EmbeddedItem;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-import org.eclipse.persistence.json.bind.model.JsonContext;
-
-import javax.json.bind.serializer.JsonbSerializer;
-import javax.json.bind.serializer.SerializationContext;
-import javax.json.stream.JsonGenerator;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.util.Collection;
-
-/**
- * Serializer for collections.
- *
- * @author Roman Grigoriadi
- */
-public class CollectionSerializer<T extends Collection> extends AbstractContainerSerializer<T> implements EmbeddedItem {
-
- private final JsonBindingModel containerModel;
-
- private final Type collectionValueType;
-
- protected CollectionSerializer(SerializerBuilder builder) {
- super(builder);
- collectionValueType = getRuntimeType() instanceof ParameterizedType ?
- ReflectionUtils.resolveType(this, ((ParameterizedType) getRuntimeType()).getActualTypeArguments()[0])
- : Object.class;
- containerModel = new ContainerModel(collectionValueType, resolveContainerModelCustomization(collectionValueType, builder.getJsonbContext()),
- JsonContext.JSON_ARRAY);
- }
-
- @Override
- protected void serializeInternal(T collection, JsonGenerator generator, SerializationContext ctx) {
- for (Object item : collection) {
- if (item == null) {
- generator.writeNull();
- continue;
- }
- final JsonbSerializer<?> serializer = new SerializerBuilder(((Marshaller)ctx).getJsonbContext()).withObjectClass(item.getClass()).withWrapper(this).withModel(containerModel).build();
- serializerCaptor(serializer, item, generator, ctx);
- }
- }
-
- @Override
- protected void writeStart(JsonGenerator generator) {
- generator.writeStartArray();
- }
-
- @Override
- protected void writeStart(String key, JsonGenerator generator) {
- generator.writeStartArray(key);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ContainerSerializerProvider.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ContainerSerializerProvider.java
deleted file mode 100644
index af939a8..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ContainerSerializerProvider.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.unmarshaller.CurrentItem;
-import org.eclipse.persistence.json.bind.model.ClassModel;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.bind.serializer.JsonbSerializer;
-import java.lang.reflect.Type;
-
-/**
- * Provides container serializer instance.
- *
- * @author Roman Grigoriadi
- */
-public interface ContainerSerializerProvider {
-
- JsonbSerializer<?> provideSerializer(CurrentItem<?> wrapper, Type runtimeType, ClassModel classModel, JsonBindingModel wrapperModel);
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/DateTypeDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/DateTypeDeserializer.java
deleted file mode 100644
index 0b9fc22..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/DateTypeDeserializer.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.JsonbContext;
-import org.eclipse.persistence.json.bind.internal.ProcessingContext;
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-import org.eclipse.persistence.json.bind.internal.properties.MessageKeys;
-import org.eclipse.persistence.json.bind.internal.properties.Messages;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.bind.JsonbException;
-import javax.json.bind.annotation.JsonbDateFormat;
-import java.lang.reflect.Type;
-import java.text.DateFormat;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Locale;
-
-/**
- * @author David Král
- */
-public class DateTypeDeserializer extends AbstractValueTypeDeserializer<Date> {
-
-
- public DateTypeDeserializer(JsonBindingModel model) {
- super(Date.class, model);
- }
-
- private DateFormat getDateFormat(JsonbDateFormatter formatter, Locale locale) {
- if (JsonbDateFormat.DEFAULT_FORMAT.equals(formatter.getFormat())) {
- return new SimpleDateFormat(JsonbDateFormatter.ISO_8601_DATE_TIME_FORMAT, locale);
- }
- return new SimpleDateFormat(formatter.getFormat(), locale);
- }
-
-
- @Override
- protected Date deserialize(String jsonValue, Unmarshaller unmarshaller, Type rtType) {
-
- final JsonbDateFormatter dateFormatter = unmarshaller.getJsonbContext().getComponentMatcher().getDateFormatter(model);
- if(JsonbDateFormat.TIME_IN_MILLIS.equals(dateFormatter.getFormat())) {
- return new Date(Long.parseLong(jsonValue));
- }
- final DateFormat dateFormat = getDateFormat(dateFormatter, unmarshaller.getJsonbContext().getLocale(dateFormatter.getLocale()));
- try {
- return dateFormat.parse(jsonValue);
- } catch (ParseException e) {
- throw new JsonbException(Messages.getMessage(MessageKeys.DATE_PARSE_ERROR, jsonValue, dateFormat));
- }
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/DateTypeSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/DateTypeSerializer.java
deleted file mode 100644
index f28e59d..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/DateTypeSerializer.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.JsonbContext;
-import org.eclipse.persistence.json.bind.internal.Marshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-import org.eclipse.persistence.json.bind.model.JsonContext;
-
-import javax.json.bind.annotation.JsonbDateFormat;
-import javax.json.bind.serializer.SerializationContext;
-import javax.json.stream.JsonGenerator;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Locale;
-
-/**
- * @author David Král
- */
-public class DateTypeSerializer extends AbstractValueTypeSerializer<Date> {
-
-
- public DateTypeSerializer(JsonBindingModel model) {
- super(model);
- }
-
- private String toJson(Date object, JsonbDateFormatter formatter, JsonbContext jsonbContext) {
- if (JsonbDateFormat.TIME_IN_MILLIS.equals(formatter.getFormat())) {
- return String.valueOf(object.getTime());
- }
- Locale locale = jsonbContext.getLocale(formatter.getLocale());
- return getDateFormat(formatter, locale).format(object);
- }
-
- private DateFormat getDateFormat(JsonbDateFormatter formatter, Locale locale) {
- if (JsonbDateFormat.DEFAULT_FORMAT.equals(formatter.getFormat())) {
- return new SimpleDateFormat(JsonbDateFormatter.ISO_8601_DATE_TIME_FORMAT, locale);
- }
- return new SimpleDateFormat(formatter.getFormat(), locale);
- }
-
- @Override
- public void serialize(Date obj, JsonGenerator generator, SerializationContext ctx) {
- final JsonbContext jsonbContext = ((Marshaller) ctx).getJsonbContext();
- final JsonbDateFormatter formatter = jsonbContext.getComponentMatcher().getDateFormatter(model);
- if (model.getContext() == JsonContext.JSON_OBJECT) {
- generator.write(model.getWriteName(), toJson(obj, formatter, jsonbContext));
- } else {
- generator.write(toJson(obj, formatter, jsonbContext));
- }
- }
-
- @Override
- protected void serialize(Date obj, JsonGenerator generator, String key, Marshaller marshaller) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- protected void serialize(Date obj, JsonGenerator generator, Marshaller marshaller) {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/DefaultSerializers.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/DefaultSerializers.java
deleted file mode 100644
index 1aa1ba2..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/DefaultSerializers.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import javax.json.JsonArray;
-import javax.json.JsonNumber;
-import javax.json.JsonObject;
-import javax.json.JsonString;
-import javax.json.JsonValue;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.net.URI;
-import java.net.URL;
-import java.time.Duration;
-import java.time.Instant;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.LocalTime;
-import java.time.OffsetDateTime;
-import java.time.OffsetTime;
-import java.time.Period;
-import java.time.ZoneId;
-import java.time.ZoneOffset;
-import java.time.ZonedDateTime;
-import java.util.Calendar;
-import java.util.Collections;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Optional;
-import java.util.OptionalDouble;
-import java.util.OptionalInt;
-import java.util.OptionalLong;
-import java.util.TimeZone;
-
-/**
- * @author Roman Grigoriadi
- */
-public class DefaultSerializers {
-
- private static final DefaultSerializers instance = new DefaultSerializers();
-
- private final Map<Class<?>, SerializerProviderWrapper> serializers;
-
- private final SerializerProviderWrapper enumProvider;
-
- private DefaultSerializers() {
- this.serializers = initSerializers();
- enumProvider = new SerializerProviderWrapper(EnumTypeSerializer::new, EnumTypeDeserializer::new);
- }
-
- private Map<Class<?>, SerializerProviderWrapper> initSerializers() {
- final Map<Class<?>, SerializerProviderWrapper> serializers = new HashMap<>();
-
- serializers.put(Boolean.class, new SerializerProviderWrapper(BooleanTypeSerializer::new, BooleanTypeDeserializer::new));
- serializers.put(Boolean.TYPE, new SerializerProviderWrapper(BooleanTypeSerializer::new, BooleanTypeDeserializer::new));
- serializers.put(Byte.class, new SerializerProviderWrapper(ByteTypeSerializer::new, ByteTypeDeserializer::new));
- serializers.put(Byte.TYPE, new SerializerProviderWrapper(ByteTypeSerializer::new, ByteTypeDeserializer::new));
- serializers.put(Calendar.class, new SerializerProviderWrapper(CalendarTypeSerializer::new, CalendarTypeDeserializer::new));
- serializers.put(GregorianCalendar.class, new SerializerProviderWrapper(CalendarTypeSerializer::new, CalendarTypeDeserializer::new));
- serializers.put(Character.class, new SerializerProviderWrapper(CharacterTypeSerializer::new, CharacterTypeDeserializer::new));
- serializers.put(Character.TYPE, new SerializerProviderWrapper(CharacterTypeSerializer::new, CharacterTypeDeserializer::new));
- serializers.put(Date.class, new SerializerProviderWrapper(DateTypeSerializer::new, DateTypeDeserializer::new));
- serializers.put(Double.class, new SerializerProviderWrapper(DoubleTypeSerializer::new, DoubleTypeDeserializer::new));
- serializers.put(Double.TYPE, new SerializerProviderWrapper(DoubleTypeSerializer::new, DoubleTypeDeserializer::new));
- serializers.put(Float.class, new SerializerProviderWrapper(FloatTypeSerializer::new, FloatTypeDeserializer::new));
- serializers.put(Float.TYPE, new SerializerProviderWrapper(FloatTypeSerializer::new, FloatTypeDeserializer::new));
- serializers.put(Instant.class, new SerializerProviderWrapper(InstantTypeSerializer::new, InstantTypeDeserializer::new));
- serializers.put(Integer.class, new SerializerProviderWrapper(IntegerTypeSerializer::new, IntegerTypeDeserializer::new));
- serializers.put(Integer.TYPE, new SerializerProviderWrapper(IntegerTypeSerializer::new, IntegerTypeDeserializer::new));
- serializers.put(JsonNumber.class, new SerializerProviderWrapper(JsonValueSerializer::new, JsonNumberTypeDeserializer::new));
- serializers.put(JsonString.class, new SerializerProviderWrapper(JsonValueSerializer::new, JsonStringTypeDeserializer::new));
- serializers.put(JsonValue.class, new SerializerProviderWrapper(JsonValueSerializer::new, JsonValueDeserializer::new));
- serializers.put(LocalDateTime.class, new SerializerProviderWrapper(LocalDateTimeTypeSerializer::new, LocalDateTimeTypeDeserializer::new));
- serializers.put(LocalDate.class, new SerializerProviderWrapper(LocalDateTypeSerializer::new, LocalDateTypeDeserializer::new));
- serializers.put(LocalTime.class, new SerializerProviderWrapper(LocalTimeTypeSerializer::new, LocalTimeTypeDeserializer::new));
- serializers.put(Long.class, new SerializerProviderWrapper(LongTypeSerializer::new, LongTypeDeserializer::new));
- serializers.put(Long.TYPE, new SerializerProviderWrapper(LongTypeSerializer::new, LongTypeDeserializer::new));
- serializers.put(Number.class, new SerializerProviderWrapper(NumberTypeSerializer::new, NumberTypeDeserializer::new));
- serializers.put(OffsetDateTime.class, new SerializerProviderWrapper(OffsetDateTimeTypeSerializer::new, OffsetDateTimeTypeDeserializer::new));
- serializers.put(OffsetTime.class, new SerializerProviderWrapper(OffsetTimeTypeSerializer::new, OffsetTimeTypeDeserializer::new));
- serializers.put(OptionalDouble.class, new SerializerProviderWrapper(OptionalDoubleTypeSerializer::new, OptionalDoubleTypeDeserializer::new));
- serializers.put(OptionalInt.class, new SerializerProviderWrapper(OptionalIntTypeSerializer::new, OptionalIntTypeDeserializer::new));
- serializers.put(OptionalLong.class, new SerializerProviderWrapper(OptionalLongTypeSerializer::new, OptionalLongTypeDeserializer::new));
- serializers.put(Short.class, new SerializerProviderWrapper(ShortTypeSerializer::new, ShortTypeDeserializer::new));
- serializers.put(Short.TYPE, new SerializerProviderWrapper(ShortTypeSerializer::new, ShortTypeDeserializer::new));
- serializers.put(String.class, new SerializerProviderWrapper(StringTypeSerializer::new, StringTypeDeserializer::new));
- serializers.put(TimeZone.class, new SerializerProviderWrapper(TimeZoneTypeSerializer::new, TimeZoneTypeDeserializer::new));
- serializers.put(URI.class, new SerializerProviderWrapper(URITypeSerializer::new, URITypeDeserializer::new));
- serializers.put(URL.class, new SerializerProviderWrapper(URLTypeSerializer::new, URLTypeDeserializer::new));
- serializers.put(ZonedDateTime.class, new SerializerProviderWrapper(ZonedDateTimeTypeSerializer::new, ZonedDateTimeTypeDeserializer::new));
- serializers.put(Duration.class, new SerializerProviderWrapper(DurationTypeSerializer::new, DurationTypeDeserializer::new));
- serializers.put(Period.class, new SerializerProviderWrapper(PeriodTypeSerializer::new, PeriodTypeDeserializer::new));
- serializers.put(ZoneId.class, new SerializerProviderWrapper(ZoneIdTypeSerializer::new, ZoneIdTypeDeserializer::new));
- serializers.put(BigInteger.class, new SerializerProviderWrapper(BigIntegerTypeSerializer::new, BigIntegerTypeDeserializer::new));
- serializers.put(BigDecimal.class, new SerializerProviderWrapper(BigDecimalTypeSerializer::new, BigDecimalTypeDeserializer::new));
- serializers.put(ZoneOffset.class, new SerializerProviderWrapper(ZoneOffsetTypeSerializer::new, ZoneOffsetTypeDeserializer::new));
-
- return Collections.unmodifiableMap(serializers);
- }
-
- /**
- * Look for a provider for a supported value type. These serializers are basically singleton stateless shared instances.
- *
- * @param clazz supported type class
- * @param <T> Type of serializer
- * @return serializer if found
- */
- @SuppressWarnings("unchecked")
- public <T> Optional<SerializerProviderWrapper> findValueSerializerProvider(Class<T> clazz) {
- Class<?> candidate = clazz;
- do {
- final SerializerProviderWrapper provider = serializers.get(candidate);
- if (provider != null) {
- return Optional.of(provider);
- }
- candidate = candidate.getSuperclass();
- } while (candidate != null);
-
- return findByCondition(clazz);
- }
-
- private <T> Optional<SerializerProviderWrapper> findByCondition(Class<T> clazz) {
- if (clazz.isEnum()) {
- return Optional.of(enumProvider);
- } else if (JsonString.class.isAssignableFrom(clazz)) {
- return Optional.of(serializers.get(JsonString.class));
- } else if (JsonNumber.class.isAssignableFrom(clazz)) {
- return Optional.of(serializers.get(JsonNumber.class));
- } else if (JsonValue.class.isAssignableFrom(clazz) && !(JsonObject.class.isAssignableFrom(clazz) || JsonArray.class.isAssignableFrom(clazz))) {
- return Optional.of(serializers.get(JsonValue.class));
- }
- return Optional.empty();
- }
-
-
- /**
- * Singleton instance.
- * @return instance
- */
- public static DefaultSerializers getInstance() {
- return instance;
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/DoubleArraySerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/DoubleArraySerializer.java
deleted file mode 100644
index a51bfd0..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/DoubleArraySerializer.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import javax.json.bind.serializer.SerializationContext;
-import javax.json.stream.JsonGenerator;
-
-/**
- * Serializer for arrays of doubles.
- * @author Roman Grigoriadi
- */
-public class DoubleArraySerializer extends AbstractArraySerializer<double[]> {
-
- protected DoubleArraySerializer(SerializerBuilder builder) {
- super(builder);
- }
-
- @Override
- protected void serializeInternal(double[] arr, JsonGenerator generator, SerializationContext ctx) {
- for (double obj : arr) {
- generator.write(obj);
- }
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/DoubleTypeDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/DoubleTypeDeserializer.java
deleted file mode 100644
index f215750..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/DoubleTypeDeserializer.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import java.lang.reflect.Type;
-
-/**
- * @author David Král
- */
-public class DoubleTypeDeserializer extends AbstractNumberDeserializer<Double> {
-
- protected static final String POSITIVE_INFINITY = "POSITIVE_INFINITY";
- protected static final String NEGATIVE_INFINITY = "NEGATIVE_INFINITY";
- protected static final String NAN = "NaN";
-
- public DoubleTypeDeserializer(JsonBindingModel model) {
- super(Double.class, model);
- }
-
- @Override
- protected Double deserialize(String jsonValue, Unmarshaller unmarshaller, Type rtType) {
- switch (jsonValue) {
- case NAN:
- return Double.NaN;
- case POSITIVE_INFINITY:
- return Double.POSITIVE_INFINITY;
- case NEGATIVE_INFINITY:
- return Double.NEGATIVE_INFINITY;
- }
- return deserializeForamtted(jsonValue, false, unmarshaller.getJsonbContext()).map(num->Double.parseDouble(num.toString()))
- .orElseGet(()->Double.parseDouble(jsonValue));
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/DoubleTypeSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/DoubleTypeSerializer.java
deleted file mode 100644
index 6d4b3f2..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/DoubleTypeSerializer.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.stream.JsonGenerator;
-
-/**
- * @author David Král
- */
-public class DoubleTypeSerializer extends AbstractNumberSerializer<Double> {
-
-
- public DoubleTypeSerializer(JsonBindingModel model) {
- super(Double.class, model);
- }
-
-
- @Override
- protected void serializeNonFormatted(Double obj, JsonGenerator generator, String key) {
- generator.write(key, obj);
- }
-
- @Override
- protected void serializeNonFormatted(Double obj, JsonGenerator generator) {
- generator.write(obj);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/DurationTypeDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/DurationTypeDeserializer.java
deleted file mode 100644
index 349da1b..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/DurationTypeDeserializer.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import java.lang.reflect.Type;
-import java.time.Duration;
-
-/**
- * @author David Král
- */
-public class DurationTypeDeserializer extends AbstractValueTypeDeserializer<Duration> {
-
- public DurationTypeDeserializer(JsonBindingModel model) {
- super(Duration.class, model);
- }
-
- @Override
- protected Duration deserialize(String jsonValue, Unmarshaller unmarshaller, Type rtType) {
- return Duration.parse(jsonValue);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/DurationTypeSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/DurationTypeSerializer.java
deleted file mode 100644
index 29c1749..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/DurationTypeSerializer.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.Marshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.stream.JsonGenerator;
-import java.time.Duration;
-
-/**
- * @author David Král
- */
-public class DurationTypeSerializer extends AbstractValueTypeSerializer<Duration> {
-
- public DurationTypeSerializer(JsonBindingModel model) {
- super(model);
- }
-
- @Override
- protected void serialize(Duration obj, JsonGenerator generator, String key, Marshaller marshaller) {
- generator.write(key, obj.toString());
- }
-
- @Override
- protected void serialize(Duration obj, JsonGenerator generator, Marshaller marshaller) {
- generator.write(obj.toString());
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/EnumTypeDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/EnumTypeDeserializer.java
deleted file mode 100644
index 51a8e31..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/EnumTypeDeserializer.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import java.lang.reflect.Type;
-
-/**
- * @author David Král
- */
-public class EnumTypeDeserializer extends AbstractValueTypeDeserializer<Enum> {
-
- public EnumTypeDeserializer(JsonBindingModel model) {
- super(Enum.class, model);
- }
-
- @Override
- protected Enum deserialize(String jsonValue, Unmarshaller unmarshaller, Type rtType) {
- Class<? extends Enum> en = (Class<? extends Enum>) rtType;
- for (Enum c : en.getEnumConstants()) {
- if (c.name().equals(jsonValue)) {
- return c;
- }
- }
- return null;
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/EnumTypeSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/EnumTypeSerializer.java
deleted file mode 100644
index c32001f..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/EnumTypeSerializer.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.Marshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.stream.JsonGenerator;
-
-/**
- * @author David Král
- */
-public class EnumTypeSerializer extends AbstractValueTypeSerializer<Enum> {
-
- public EnumTypeSerializer(JsonBindingModel model) {
- super(model);
- }
-
- @Override
- protected void serialize(Enum obj, JsonGenerator generator, String key, Marshaller marshaller) {
- generator.write(key, obj.toString());
- }
-
- @Override
- protected void serialize(Enum obj, JsonGenerator generator, Marshaller marshaller) {
- generator.write(obj.toString());
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/FloatArraySerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/FloatArraySerializer.java
deleted file mode 100644
index 4f1379f..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/FloatArraySerializer.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import javax.json.bind.serializer.SerializationContext;
-import javax.json.stream.JsonGenerator;
-
-/**
- * Serializer for arrays of floats.
- * @author Roman Grigoriadi
- */
-public class FloatArraySerializer extends AbstractArraySerializer<float[]> {
-
- protected FloatArraySerializer(SerializerBuilder builder) {
- super(builder);
- }
-
- @Override
- protected void serializeInternal(float[] arr, JsonGenerator generator, SerializationContext ctx) {
- for (float obj : arr) {
- generator.write(obj);
- }
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/FloatTypeDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/FloatTypeDeserializer.java
deleted file mode 100644
index 82f2b38..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/FloatTypeDeserializer.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import java.lang.reflect.Type;
-
-/**
- * @author David Král
- */
-public class FloatTypeDeserializer extends AbstractNumberDeserializer<Float> {
-
- public FloatTypeDeserializer(JsonBindingModel model) {
- super(Float.class, model);
- }
-
- /**
- * Convert string value to object.
- *
- * @param jsonValue json value
- * @param unmarshaller unmarshaller instance
- * @param rtType
- * @return deserialized object
- */
- @Override
- protected Float deserialize(String jsonValue, Unmarshaller unmarshaller, Type rtType) {
- return deserializeForamtted(jsonValue, false, unmarshaller.getJsonbContext()).map(num->Float.parseFloat(num.toString()))
- .orElseGet(()->Float.parseFloat(jsonValue));
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/FloatTypeSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/FloatTypeSerializer.java
deleted file mode 100644
index 8fae99d..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/FloatTypeSerializer.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.stream.JsonGenerator;
-
-/**
- * @author David Král
- */
-public class FloatTypeSerializer extends AbstractNumberSerializer<Float> {
-
- public FloatTypeSerializer(JsonBindingModel model) {
- super(Float.class, model);
- }
-
- @Override
- protected void serializeNonFormatted(Float obj, JsonGenerator generator, String key) {
- generator.write(key, obj);
- }
-
- @Override
- protected void serializeNonFormatted(Float obj, JsonGenerator generator) {
- generator.write(obj);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/IDeserializerProvider.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/IDeserializerProvider.java
deleted file mode 100644
index f28d40e..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/IDeserializerProvider.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-/**
- * Creates instance of deserializer.
- *
- * @author Roman Grigoriadi
- */
-public interface IDeserializerProvider {
-
- /**
- * Provides new instance of deserializer.
- * @param model model to use
- * @return deserializer
- */
- AbstractValueTypeDeserializer<?> provideDeserializer(JsonBindingModel model);
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ISerializerProvider.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ISerializerProvider.java
deleted file mode 100644
index 9f5bbf2..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ISerializerProvider.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-/**
- * Create instance of a serializer.
- *
- * @author Roman Grigoriadi
- */
-public interface ISerializerProvider {
-
- /**
- * Provides new instance of serializer.
- * @param model model to use
- * @return deserializer
- */
- AbstractValueTypeSerializer<?> provideSerializer(JsonBindingModel model);
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/InstantTypeDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/InstantTypeDeserializer.java
deleted file mode 100644
index a01fade..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/InstantTypeDeserializer.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import java.lang.reflect.Type;
-import java.time.Instant;
-
-/**
- * @author David Král
- */
-public class InstantTypeDeserializer extends AbstractValueTypeDeserializer<Instant> {
-
- public InstantTypeDeserializer(JsonBindingModel model) {
- super(Instant.class, model);
- }
-
- @Override
- protected Instant deserialize(String jsonValue, Unmarshaller unmarshaller, Type rtType) {
- return Instant.parse(jsonValue);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/InstantTypeSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/InstantTypeSerializer.java
deleted file mode 100644
index e889926..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/InstantTypeSerializer.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.Marshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.stream.JsonGenerator;
-import java.time.Instant;
-import java.time.ZoneOffset;
-import java.time.format.DateTimeFormatter;
-
-/**
- * @author David Král
- */
-public class InstantTypeSerializer extends AbstractValueTypeSerializer<Instant> {
-
- public InstantTypeSerializer(JsonBindingModel model) {
- super(model);
- }
-
- @Override
- protected void serialize(Instant obj, JsonGenerator generator, String key, Marshaller marshaller) {
- generator.write(key, formatInstant(obj));
- }
-
- @Override
- protected void serialize(Instant obj, JsonGenerator generator, Marshaller marshaller) {
- generator.write(formatInstant(obj));
- }
-
- private String formatInstant(Instant obj) {
- return DateTimeFormatter.ISO_INSTANT.withZone(ZoneOffset.UTC).format(obj);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/IntArraySerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/IntArraySerializer.java
deleted file mode 100644
index b8099f6..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/IntArraySerializer.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import javax.json.bind.serializer.SerializationContext;
-import javax.json.stream.JsonGenerator;
-
-/**
- * Serializer for arrays of ints.
- * @author Roman Grigoriadi
- */
-public class IntArraySerializer extends AbstractArraySerializer<int[]> {
-
- protected IntArraySerializer(SerializerBuilder builder) {
- super(builder);
- }
-
- @Override
- protected void serializeInternal(int[] arr, JsonGenerator generator, SerializationContext ctx) {
- for (int obj : arr) {
- generator.write(obj);
- }
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/IntegerTypeDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/IntegerTypeDeserializer.java
deleted file mode 100644
index 95b39b2..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/IntegerTypeDeserializer.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import java.lang.reflect.Type;
-
-/**
- * Deserialize {@link Integer}
- * @author Roman Grigoriadi
- */
-public class IntegerTypeDeserializer extends AbstractNumberDeserializer<Integer> {
-
- public IntegerTypeDeserializer(JsonBindingModel model) {
- super(Integer.class, model);
- }
-
- @Override
- protected Integer deserialize(String jsonValue, Unmarshaller unmarshaller, Type rtType) {
- return deserializeForamtted(jsonValue, true, unmarshaller.getJsonbContext()).map(num -> Integer.parseInt(num.toString()))
- .orElseGet(()->Integer.parseInt(jsonValue));
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/IntegerTypeSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/IntegerTypeSerializer.java
deleted file mode 100644
index d650913..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/IntegerTypeSerializer.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.stream.JsonGenerator;
-
-/**
- * @author Roman Grigoriadi
- */
-public class IntegerTypeSerializer extends AbstractNumberSerializer<Integer> {
-
- public IntegerTypeSerializer(JsonBindingModel model) {
- super(Integer.class, model);
- }
-
- @Override
- protected void serializeNonFormatted(Integer obj, JsonGenerator generator, String key) {
- generator.write(key, obj);
- }
-
- @Override
- protected void serializeNonFormatted(Integer obj, JsonGenerator generator) {
- generator.write(obj);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/JsonArraySerialzier.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/JsonArraySerialzier.java
deleted file mode 100644
index 1a828ce..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/JsonArraySerialzier.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import javax.json.JsonArray;
-import javax.json.JsonValue;
-import javax.json.bind.serializer.SerializationContext;
-import javax.json.stream.JsonGenerator;
-
-/**
- * Serializes JSON array to json.
- *
- * @author Roman Grigoriadi
- */
-public class JsonArraySerialzier extends AbstractJsonpSerializer<JsonArray> {
-
- protected JsonArraySerialzier(SerializerBuilder builder) {
- super(builder);
- }
-
- @Override
- protected void serializeInternal(JsonArray obj, JsonGenerator generator, SerializationContext ctx) {
- for (JsonValue value : obj) {
- generator.write(value);
- }
- }
-
- @Override
- protected void writeStart(JsonGenerator generator) {
- generator.writeStartArray();
- }
-
- @Override
- protected void writeStart(String key, JsonGenerator generator) {
- generator.writeStartArray(key);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/JsonNumberTypeDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/JsonNumberTypeDeserializer.java
deleted file mode 100644
index ee92acc..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/JsonNumberTypeDeserializer.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.ProcessingContext;
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.JsonBuilderFactory;
-import javax.json.JsonNumber;
-import javax.json.JsonObject;
-import java.lang.reflect.Type;
-import java.math.BigDecimal;
-
-/**
- * @author David Král
- */
-public class JsonNumberTypeDeserializer extends AbstractValueTypeDeserializer<JsonNumber> {
-
- private final static String NUMBER = "number";
-
- public JsonNumberTypeDeserializer(JsonBindingModel model) {
- super(JsonNumber.class, model);
- }
-
- @Override
- protected JsonNumber deserialize(String jsonValue, Unmarshaller unmarshaller, Type rtType) {
- final JsonBuilderFactory factory = unmarshaller.getJsonbContext().getJsonProvider().createBuilderFactory(null);
- JsonObject jsonObject;
- try {
- Integer integer = Integer.parseInt(jsonValue);
-
- jsonObject = factory.createObjectBuilder()
- .add(NUMBER, integer)
- .build();
- return jsonObject.getJsonNumber(NUMBER);
- } catch (NumberFormatException exception) {
- }
- try {
- Long l = Long.parseLong(jsonValue);
-
- jsonObject = factory.createObjectBuilder()
- .add(NUMBER, l)
- .build();
- return jsonObject.getJsonNumber(NUMBER);
- } catch (NumberFormatException exception) {
- }
-
- jsonObject = factory.createObjectBuilder()
- .add(NUMBER, new BigDecimal(jsonValue))
- .build();
- return jsonObject.getJsonNumber(NUMBER);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/JsonObjectSerialzier.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/JsonObjectSerialzier.java
deleted file mode 100644
index 41a0dcb..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/JsonObjectSerialzier.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import javax.json.JsonObject;
-import javax.json.JsonValue;
-import javax.json.bind.serializer.SerializationContext;
-import javax.json.stream.JsonGenerator;
-import java.util.Map;
-
-/**
- * Serializes JSON object to json.
- *
- * @author Roman Grigoriadi
- */
-public class JsonObjectSerialzier extends AbstractJsonpSerializer<JsonObject> {
-
- protected JsonObjectSerialzier(SerializerBuilder builder) {
- super(builder);
- }
-
- @Override
- protected void serializeInternal(JsonObject obj, JsonGenerator generator, SerializationContext ctx) {
- for (Map.Entry<String, JsonValue> entry : obj.entrySet()) {
- generator.write(entry.getKey(), entry.getValue());
- }
- }
-
- @Override
- protected void writeStart(JsonGenerator generator) {
- generator.writeStartObject();
- }
-
- @Override
- protected void writeStart(String key, JsonGenerator generator) {
- generator.writeStartObject(key);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/JsonStringTypeDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/JsonStringTypeDeserializer.java
deleted file mode 100644
index cde314d..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/JsonStringTypeDeserializer.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.ProcessingContext;
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.JsonBuilderFactory;
-import javax.json.JsonObject;
-import javax.json.JsonString;
-import java.lang.reflect.Type;
-
-/**
- * @author David Král
- */
-public class JsonStringTypeDeserializer extends AbstractValueTypeDeserializer<JsonString> {
-
- public JsonStringTypeDeserializer(JsonBindingModel model) {
- super(JsonString.class, model);
- }
-
- @Override
- protected JsonString deserialize(String jsonValue, Unmarshaller unmarshaller, Type rtType) {
- final JsonBuilderFactory factory = unmarshaller.getJsonbContext().getJsonProvider().createBuilderFactory(null);
- final JsonObject jsonObject = factory.createObjectBuilder()
- .add("json", jsonValue)
- .build();
- return jsonObject.getJsonString("json");
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/JsonValueDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/JsonValueDeserializer.java
deleted file mode 100644
index 1ee50df..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/JsonValueDeserializer.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-import org.eclipse.persistence.json.bind.internal.properties.MessageKeys;
-import org.eclipse.persistence.json.bind.internal.properties.Messages;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.JsonValue;
-import javax.json.bind.JsonbException;
-import javax.json.bind.serializer.DeserializationContext;
-import javax.json.stream.JsonParser;
-import java.lang.reflect.Type;
-
-/**
- * Deserializer for Json value null, false and true.
- * @author Roman Grigoriadi
- */
-public class JsonValueDeserializer extends AbstractValueTypeDeserializer<JsonValue> {
-
- public JsonValueDeserializer(JsonBindingModel model) {
- super(JsonValue.class, model);
- }
-
- @Override
- public JsonValue deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) {
- final JsonParser.Event next = parser.next();
- switch (next) {
- case VALUE_TRUE:
- return JsonValue.TRUE;
- case VALUE_FALSE:
- return JsonValue.FALSE;
- case VALUE_NULL:
- return JsonValue.NULL;
- default:
- throw new JsonbException(Messages.getMessage(MessageKeys.INTERNAL_ERROR, "Unknown JSON value: "+next));
- }
- }
-
- @Override
- protected JsonValue deserialize(String jsonValue, Unmarshaller unmarshaller, Type rtType) {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/JsonValueSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/JsonValueSerializer.java
deleted file mode 100644
index b11af72..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/JsonValueSerializer.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.Marshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.JsonValue;
-import javax.json.stream.JsonGenerator;
-
-/**
- * Serializes single JsonValue.
- *
- * @author Roman Grigoriadi
- */
-public class JsonValueSerializer extends AbstractValueTypeSerializer<JsonValue> {
-
- public JsonValueSerializer(JsonBindingModel model) {
- super(model);
- }
-
- @Override
- protected void serialize(JsonValue obj, JsonGenerator generator, String key, Marshaller marshaller) {
- generator.write(key, obj);
- }
-
- @Override
- protected void serialize(JsonValue obj, JsonGenerator generator, Marshaller marshaller) {
- generator.write(obj);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/JsonbDateFormatter.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/JsonbDateFormatter.java
deleted file mode 100644
index 2590fbf..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/JsonbDateFormatter.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import javax.json.bind.annotation.JsonbDateFormat;
-import java.time.format.DateTimeFormatter;
-
-/**
- * Formatter wrapper for different types of dates.
- *
- * @author Roman Grigoriadi
- */
-public class JsonbDateFormatter {
-
- public static final String ISO_8601_DATE_TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss";
- public static final String ISO_8601_DATE_FORMAT = "yyyy-MM-dd";
-
- //Java 8 date formatter is thread safe, cache it if possible
- private final DateTimeFormatter dateTimeFormatter;
-
- private final String format;
-
- private final String locale;
-
- /**
- * Construct with cached {@link DateTimeFormatter}, format and locale.
- * @param dateTimeFormatter
- */
- public JsonbDateFormatter(DateTimeFormatter dateTimeFormatter, String format, String locale) {
- this.dateTimeFormatter = dateTimeFormatter;
- this.format = format;
- this.locale = locale;
- }
-
- /**
- * Construct with cached {@link DateTimeFormatter}.
- * @param dateTimeFormatter
- */
- public JsonbDateFormatter(DateTimeFormatter dateTimeFormatter) {
- this.dateTimeFormatter = dateTimeFormatter;
- this.format = null;
- this.locale = null;
- }
-
- /**
- * Construct with format string and locale. Formatter will be created on every formatting / parsing operation.
- * @param format formatter format
- * @param locale locale
- */
- public JsonbDateFormatter(String format, String locale) {
- this.format = format;
- this.locale = locale;
- this.dateTimeFormatter = null;
- }
-
- /**
- * Cached instance of {@link DateTimeFormatter} to be used.
- * @return formatter instance
- */
- public DateTimeFormatter getDateTimeFormatter() {
- return dateTimeFormatter;
- }
-
- /**
- * Format string to be used either by formatter.
- * Needed for formatting {@link java.util.Date} with {@link java.text.SimpleDateFormat},
- * which is not threadsafe.
- * @return format
- */
- public String getFormat() {
- return format;
- }
-
- /**
- * Locale to use with formatter.
- * @return locale
- */
- public String getLocale() {
- return locale;
- }
-
- /**
- * Default date formatter if none is provided.
- *
- * @return default date formatter
- */
- public static JsonbDateFormatter getDefault() {
- return new JsonbDateFormatter(JsonbDateFormat.DEFAULT_FORMAT, JsonbDateFormat.DEFAULT_LOCALE);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/JsonbNumberFormatter.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/JsonbNumberFormatter.java
deleted file mode 100644
index 99d0b6d..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/JsonbNumberFormatter.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-/**
- * Formatter for numbers.
- *
- * @author Roman Grigoriadi
- */
-public class JsonbNumberFormatter {
-
- private final String format;
-
- private final String locale;
-
-
- /**
- * Construct with format string and locale.
- *
- * @param format formatter format
- * @param locale locale
- */
- public JsonbNumberFormatter(String format, String locale) {
- this.format = format;
- this.locale = locale;
- }
-
- /**
- * Format string to be used either by formatter.
- *
- * @return format
- */
- public String getFormat() {
- return format;
- }
-
- /**
- * Locale to use with formatter.
- * @return locale
- */
- public String getLocale() {
- return locale;
- }
-
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/LocalDateTimeTypeDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/LocalDateTimeTypeDeserializer.java
deleted file mode 100644
index 3b37e01..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/LocalDateTimeTypeDeserializer.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import java.time.Instant;
-import java.time.LocalDateTime;
-import java.time.ZoneId;
-import java.time.format.DateTimeFormatter;
-import java.util.Locale;
-
-/**
- * @author David Král
- */
-public class LocalDateTimeTypeDeserializer extends AbstractDateTimeDeserializer<LocalDateTime> {
-
- public LocalDateTimeTypeDeserializer(JsonBindingModel model) {
- super(LocalDateTime.class, model);
- }
-
- @Override
- protected LocalDateTime fromInstant(Instant instant) {
- return LocalDateTime.ofInstant(instant, ZoneId.systemDefault());
- }
-
- @Override
- protected LocalDateTime parseDefault(String jsonValue, Locale locale) {
- return LocalDateTime.parse(jsonValue, DateTimeFormatter.ISO_LOCAL_DATE_TIME.withLocale(locale));
- }
-
- @Override
- protected LocalDateTime parseWithFormatter(String jsonValue, DateTimeFormatter formatter) {
- return LocalDateTime.parse(jsonValue, formatter);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/LocalDateTimeTypeSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/LocalDateTimeTypeSerializer.java
deleted file mode 100644
index 01092ff..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/LocalDateTimeTypeSerializer.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import java.time.Instant;
-import java.time.LocalDateTime;
-import java.time.ZoneId;
-import java.time.format.DateTimeFormatter;
-import java.util.Locale;
-
-/**
- * @author David Král
- */
-public class LocalDateTimeTypeSerializer extends AbstractDateTimeSerializer<LocalDateTime> {
-
- public LocalDateTimeTypeSerializer(JsonBindingModel model) {
- super(LocalDateTime.class, model);
- }
-
- @Override
- protected Instant toInstant(LocalDateTime value) {
- return value.atZone(ZoneId.systemDefault()).toInstant();
- }
-
-
- @Override
- protected String formatDefault(LocalDateTime value, Locale locale) {
- return DateTimeFormatter.ISO_LOCAL_DATE_TIME.withLocale(locale).format(value);
- }
-
-}
\ No newline at end of file
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/LocalDateTypeDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/LocalDateTypeDeserializer.java
deleted file mode 100644
index 320faa6..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/LocalDateTypeDeserializer.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import java.time.Instant;
-import java.time.LocalDate;
-import java.time.ZoneId;
-import java.time.format.DateTimeFormatter;
-import java.util.Locale;
-
-/**
- * @author David Král
- */
-public class LocalDateTypeDeserializer extends AbstractDateTimeDeserializer<LocalDate> {
-
-
- public LocalDateTypeDeserializer(JsonBindingModel model) {
- super(LocalDate.class, model);
- }
-
- @Override
- protected LocalDate fromInstant(Instant instant) {
- return instant.atZone(ZoneId.systemDefault()).toLocalDate();
- }
-
- @Override
- protected LocalDate parseDefault(String jsonValue, Locale locale) {
- return LocalDate.parse(jsonValue, DateTimeFormatter.ISO_LOCAL_DATE.withLocale(locale));
- }
-
- @Override
- protected LocalDate parseWithFormatter(String jsonValue, DateTimeFormatter formatter) {
- return LocalDate.parse(jsonValue, formatter);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/LocalDateTypeSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/LocalDateTypeSerializer.java
deleted file mode 100644
index bbfb966..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/LocalDateTypeSerializer.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import java.time.Instant;
-import java.time.LocalDate;
-import java.time.ZoneId;
-import java.time.format.DateTimeFormatter;
-import java.util.Locale;
-
-/**
- * @author David Král
- */
-public class LocalDateTypeSerializer extends AbstractDateTimeSerializer<LocalDate> {
-
-
- public LocalDateTypeSerializer(JsonBindingModel model) {
- super(LocalDate.class, model);
- }
-
- @Override
- protected Instant toInstant(LocalDate value) {
- return Instant.from(value.atStartOfDay(ZoneId.systemDefault()));
- }
-
- @Override
- protected String formatDefault(LocalDate value, Locale locale) {
- return DateTimeFormatter.ISO_LOCAL_DATE.withLocale(locale).format(value);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/LocalTimeTypeDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/LocalTimeTypeDeserializer.java
deleted file mode 100644
index a5089a9..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/LocalTimeTypeDeserializer.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.properties.MessageKeys;
-import org.eclipse.persistence.json.bind.internal.properties.Messages;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.bind.JsonbException;
-import java.time.Instant;
-import java.time.LocalTime;
-import java.time.format.DateTimeFormatter;
-import java.util.Locale;
-
-/**
- * @author David Král
- */
-public class LocalTimeTypeDeserializer extends AbstractDateTimeDeserializer<LocalTime> {
-
-
- public LocalTimeTypeDeserializer(JsonBindingModel model) {
- super(LocalTime.class, model);
- }
-
- @Override
- protected LocalTime fromInstant(Instant instant) {
- throw new JsonbException(Messages.getMessage(MessageKeys.TIME_TO_EPOCH_MILLIS_ERROR, LocalTime.class.getSimpleName()));
- }
-
- @Override
- protected LocalTime parseDefault(String jsonValue, Locale locale) {
- return LocalTime.parse(jsonValue, DateTimeFormatter.ISO_LOCAL_TIME.withLocale(locale));
- }
-
- @Override
- protected LocalTime parseWithFormatter(String jsonValue, DateTimeFormatter formatter) {
- return LocalTime.parse(jsonValue, formatter);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/LocalTimeTypeSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/LocalTimeTypeSerializer.java
deleted file mode 100644
index 8413892..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/LocalTimeTypeSerializer.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.properties.MessageKeys;
-import org.eclipse.persistence.json.bind.internal.properties.Messages;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.bind.JsonbException;
-import java.time.Instant;
-import java.time.LocalTime;
-import java.time.format.DateTimeFormatter;
-import java.util.Locale;
-
-/**
- * @author David Král
- */
-public class LocalTimeTypeSerializer extends AbstractDateTimeSerializer<LocalTime> {
-
-
- public LocalTimeTypeSerializer(JsonBindingModel model) {
- super(LocalTime.class, model);
- }
-
- @Override
- protected Instant toInstant(LocalTime value) {
- throw new JsonbException(Messages.getMessage(MessageKeys.TIME_TO_EPOCH_MILLIS_ERROR, LocalTime.class.getSimpleName()));
- }
-
- @Override
- protected String formatDefault(LocalTime value, Locale locale) {
- return DateTimeFormatter.ISO_LOCAL_TIME.withLocale(locale).format(value);
- }
-
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/LongArraySerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/LongArraySerializer.java
deleted file mode 100644
index 50a6736..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/LongArraySerializer.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import javax.json.bind.serializer.SerializationContext;
-import javax.json.stream.JsonGenerator;
-
-/**
- * Serializer for arrays of longs.
- * @author Roman Grigoriadi
- */
-public class LongArraySerializer extends AbstractArraySerializer<long[]> {
-
- protected LongArraySerializer(SerializerBuilder builder) {
- super(builder);
- }
-
- @Override
- protected void serializeInternal(long[] arr, JsonGenerator generator, SerializationContext ctx) {
- for (long obj : arr) {
- generator.write(obj);
- }
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/LongTypeDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/LongTypeDeserializer.java
deleted file mode 100644
index 6059aab..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/LongTypeDeserializer.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import java.lang.reflect.Type;
-
-/**
- * @author David Král
- */
-public class LongTypeDeserializer extends AbstractNumberDeserializer<Long> {
-
- public LongTypeDeserializer(JsonBindingModel model) {
- super(Long.class, model);
- }
-
-
- @Override
- protected Long deserialize(String jsonValue, Unmarshaller unmarshaller, Type rtType) {
- return deserializeForamtted(jsonValue, true, unmarshaller.getJsonbContext()).map(num->Long.parseLong(num.toString()))
- .orElseGet(()->Long.parseLong(jsonValue));
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/LongTypeSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/LongTypeSerializer.java
deleted file mode 100644
index b0e33f7..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/LongTypeSerializer.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.stream.JsonGenerator;
-
-/**
- * @author David Král
- */
-public class LongTypeSerializer extends AbstractNumberSerializer<Long> {
-
- public LongTypeSerializer(JsonBindingModel model) {
- super(Long.class, model);
- }
-
- @Override
- protected void serializeNonFormatted(Long obj, JsonGenerator generator, String key) {
- generator.write(key, obj);
- }
-
- @Override
- protected void serializeNonFormatted(Long obj, JsonGenerator generator) {
- generator.write(obj);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/MapSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/MapSerializer.java
deleted file mode 100644
index 09b3313..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/MapSerializer.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.AbstractContainerSerializer;
-import org.eclipse.persistence.json.bind.internal.Marshaller;
-import org.eclipse.persistence.json.bind.internal.ReflectionUtils;
-import org.eclipse.persistence.json.bind.internal.unmarshaller.ContainerModel;
-import org.eclipse.persistence.json.bind.internal.unmarshaller.EmbeddedItem;
-import org.eclipse.persistence.json.bind.model.JsonContext;
-
-import javax.json.bind.serializer.JsonbSerializer;
-import javax.json.bind.serializer.SerializationContext;
-import javax.json.stream.JsonGenerator;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.util.Map;
-
-/**
- * Serializer for maps.
- * @author Roman Grigoriadi
- */
-public class MapSerializer<T extends Map> extends AbstractContainerSerializer<T> implements EmbeddedItem {
-
- private Type mapValueRuntimeType;
-
- protected MapSerializer(SerializerBuilder builder) {
- super(builder);
- mapValueRuntimeType = getRuntimeType() instanceof ParameterizedType ?
- ReflectionUtils.resolveType(this, ((ParameterizedType) getRuntimeType()).getActualTypeArguments()[1])
- : Object.class;
- }
-
- @Override
- protected void serializeInternal(T obj, JsonGenerator generator, SerializationContext ctx) {
- final Marshaller marshaller = (Marshaller) ctx;
- obj.keySet().stream().forEach((key) -> {
- final String keysString = String.valueOf(key);
- final Object value = obj.get(key);
- if (value == null) {
- generator.writeNull(keysString);
- return;
- }
- final JsonbSerializer<?> serializer = new SerializerBuilder(marshaller.getJsonbContext()).withObjectClass(value.getClass())
- .withModel(new ContainerModel(mapValueRuntimeType,
- resolveContainerModelCustomization(mapValueRuntimeType, marshaller.getJsonbContext()), JsonContext.JSON_OBJECT, keysString)).build();
- serializerCaptor(serializer, value, generator, ctx);
- });
- }
-
- @Override
- protected void writeStart(JsonGenerator generator) {
- generator.writeStartObject();
- }
-
- @Override
- protected void writeStart(String key, JsonGenerator generator) {
- generator.writeStartObject(key);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/NumberTypeDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/NumberTypeDeserializer.java
deleted file mode 100644
index 1addffa..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/NumberTypeDeserializer.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import java.lang.reflect.Type;
-import java.math.BigDecimal;
-
-/**
- * @author David Král
- */
-public class NumberTypeDeserializer extends AbstractValueTypeDeserializer<Number> {
-
- public NumberTypeDeserializer(JsonBindingModel model) {
- super(Number.class, model);
- }
-
- @Override
- protected Number deserialize(String jsonValue, Unmarshaller unmarshaller, Type rtType) {
- return new BigDecimal(jsonValue);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/NumberTypeSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/NumberTypeSerializer.java
deleted file mode 100644
index 0bf0f21..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/NumberTypeSerializer.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.Marshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.stream.JsonGenerator;
-
-/**
- * @author David Král
- */
-public class NumberTypeSerializer extends AbstractValueTypeSerializer<Number> {
-
- public NumberTypeSerializer(JsonBindingModel model) {
- super(model);
- }
-
-
- @Override
- protected void serialize(Number obj, JsonGenerator generator, String key, Marshaller marshaller) {
- generator.write(key, obj.doubleValue());
- }
-
- @Override
- protected void serialize(Number obj, JsonGenerator generator, Marshaller marshaller) {
- generator.write(obj.doubleValue());
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ObjectArraySerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ObjectArraySerializer.java
deleted file mode 100644
index 7f3d261..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ObjectArraySerializer.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.Marshaller;
-
-import javax.json.bind.serializer.JsonbSerializer;
-import javax.json.bind.serializer.SerializationContext;
-import javax.json.stream.JsonGenerator;
-import java.util.Optional;
-
-/**
- * Serializer for arrays of arbitrary objects.
- * @author Roman Grigoriadi
- */
-public class ObjectArraySerializer<T> extends AbstractArraySerializer<T[]> {
-
- protected ObjectArraySerializer(SerializerBuilder builder) {
- super(builder);
- }
-
- @Override
- protected void serializeInternal(T[] arr, JsonGenerator generator, SerializationContext ctx) {
- for (T obj : arr) {
- if (obj == null) {
- generator.writeNull();
- continue;
- }
- final JsonbSerializer<?> serializer = new SerializerBuilder(((Marshaller) ctx).getJsonbContext()).withObjectClass(obj.getClass()).withWrapper(this).withModel(containerModel).build();
- serializerCaptor(serializer, obj, generator, ctx);
- }
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ObjectSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ObjectSerializer.java
deleted file mode 100644
index 3953e75..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ObjectSerializer.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.AbstractContainerSerializer;
-import org.eclipse.persistence.json.bind.internal.Marshaller;
-import org.eclipse.persistence.json.bind.internal.ReflectionUtils;
-import org.eclipse.persistence.json.bind.internal.unmarshaller.CurrentItem;
-import org.eclipse.persistence.json.bind.model.ClassModel;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-import org.eclipse.persistence.json.bind.model.PropertyModel;
-
-import javax.json.bind.serializer.JsonbSerializer;
-import javax.json.bind.serializer.SerializationContext;
-import javax.json.stream.JsonGenerator;
-import java.lang.reflect.Type;
-
-/**
- * Serializes arbitrary object by reading its properties.
- *
- * @author Roman Grigoriadi
- */
-public class ObjectSerializer<T> extends AbstractContainerSerializer<T> {
-
-
- public ObjectSerializer(SerializerBuilder builder) {
- super(builder);
- }
-
- public ObjectSerializer(CurrentItem<?> wrapper, Type runtimeType, ClassModel classModel, JsonBindingModel wrapperModel) {
- super(wrapper, runtimeType, classModel, wrapperModel);
- }
-
- @Override
- protected void serializeInternal(T object, JsonGenerator generator, SerializationContext ctx) {
- final PropertyModel[] allProperties = ((Marshaller) ctx).getMappingContext().getOrCreateClassModel(object.getClass()).getSortedProperties();
- for (PropertyModel model : allProperties) {
- marshallProperty(object, generator, ctx, model);
- }
- }
-
- @Override
- protected void writeStart(JsonGenerator generator) {
- generator.writeStartObject();
- }
-
- @Override
- protected void writeStart(String key, JsonGenerator generator) {
- generator.writeStartObject(key);
- }
-
- @SuppressWarnings("unchecked")
- private void marshallProperty(T object, JsonGenerator generator, SerializationContext ctx, PropertyModel propertyModel) {
- Marshaller marshaller = (Marshaller) ctx;
- final Object propertyValue = propertyModel.getValue(object);
- if (propertyValue == null) {
- if (propertyModel.getCustomization().isNillable()) {
- generator.writeNull(propertyModel.getWriteName());
- }
- return;
- }
- final JsonbSerializer<?> propertyCachedSerializer = propertyModel.getPropertySerializer();
- if (propertyCachedSerializer != null) {
- serializerCaptor(propertyCachedSerializer, propertyValue, generator, ctx);
- return;
- }
- Type genericType = ReflectionUtils.resolveType(this, propertyModel.getType());
- final JsonbSerializer<?> serializer = new SerializerBuilder(marshaller.getJsonbContext()).withWrapper(this)
- .withObjectClass(propertyValue.getClass()).withModel(propertyModel)
- .withType(genericType).build();
- serializerCaptor(serializer, propertyValue, generator, ctx);
- }
-
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ObjectSerializerProvider.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ObjectSerializerProvider.java
deleted file mode 100644
index 95583a0..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ObjectSerializerProvider.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.unmarshaller.CurrentItem;
-import org.eclipse.persistence.json.bind.model.ClassModel;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.bind.serializer.JsonbSerializer;
-import java.lang.reflect.Type;
-
-/**
- * @author Roman Grigoriadi
- */
-public class ObjectSerializerProvider implements ContainerSerializerProvider {
-
- @Override
- public JsonbSerializer<?> provideSerializer(CurrentItem<?> wrapper, Type runtimeType, ClassModel classModel, JsonBindingModel wrapperModel) {
- return new ObjectSerializer<>(wrapper, runtimeType, classModel, wrapperModel);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/OffsetDateTimeTypeDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/OffsetDateTimeTypeDeserializer.java
deleted file mode 100644
index abb1448..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/OffsetDateTimeTypeDeserializer.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.properties.MessageKeys;
-import org.eclipse.persistence.json.bind.internal.properties.Messages;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import java.time.Instant;
-import java.time.OffsetDateTime;
-import java.time.ZoneId;
-import java.time.format.DateTimeFormatter;
-import java.util.Locale;
-import java.util.logging.Logger;
-
-/**
- * @author David Král
- */
-public class OffsetDateTimeTypeDeserializer extends AbstractDateTimeDeserializer<OffsetDateTime> {
-
- private static final Logger log = Logger.getLogger(OffsetDateTimeTypeDeserializer.class.getName());
-
-
- public OffsetDateTimeTypeDeserializer(JsonBindingModel model) {
- super(OffsetDateTime.class, model);
- }
-
- /**
- * fromInstant is called only in case {@link javax.json.bind.annotation.JsonbDateFormat} is TIME_IN_MILLIS,
- * which doesn't make much sense for usage with OffsetDateTime.
- */
- @Override
- protected OffsetDateTime fromInstant(Instant instant) {
- final ZoneId zone = ZoneId.systemDefault();
- log.warning(Messages.getMessage(MessageKeys.OFFSET_DATE_TIME_FROM_MILLIS, OffsetDateTime.class.getSimpleName(), zone));
- return OffsetDateTime.ofInstant(instant, zone);
- }
-
- @Override
- protected OffsetDateTime parseDefault(String jsonValue, Locale locale) {
- return OffsetDateTime.parse(jsonValue, DateTimeFormatter.ISO_OFFSET_DATE_TIME.withLocale(locale));
- }
-
- @Override
- protected OffsetDateTime parseWithFormatter(String jsonValue, DateTimeFormatter formatter) {
- return OffsetDateTime.parse(jsonValue, formatter);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/OffsetDateTimeTypeSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/OffsetDateTimeTypeSerializer.java
deleted file mode 100644
index 4488719..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/OffsetDateTimeTypeSerializer.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import java.time.Instant;
-import java.time.OffsetDateTime;
-import java.time.format.DateTimeFormatter;
-import java.util.Locale;
-import java.util.logging.Logger;
-
-/**
- * @author David Král
- */
-public class OffsetDateTimeTypeSerializer extends AbstractDateTimeSerializer<OffsetDateTime> {
-
- private static final Logger log = Logger.getLogger(OffsetDateTimeTypeSerializer.class.getName());
-
-
- public OffsetDateTimeTypeSerializer(JsonBindingModel model) {
- super(OffsetDateTime.class, model);
- }
-
- @Override
- protected Instant toInstant(OffsetDateTime value) {
- return value.toInstant();
- }
-
- @Override
- protected String formatDefault(OffsetDateTime value, Locale locale) {
- return DateTimeFormatter.ISO_OFFSET_DATE_TIME.withLocale(locale).format(value);
- }
-
-}
\ No newline at end of file
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/OffsetTimeTypeDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/OffsetTimeTypeDeserializer.java
deleted file mode 100644
index e3f2a9e..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/OffsetTimeTypeDeserializer.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.properties.MessageKeys;
-import org.eclipse.persistence.json.bind.internal.properties.Messages;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.bind.JsonbException;
-import java.time.Instant;
-import java.time.OffsetTime;
-import java.time.format.DateTimeFormatter;
-import java.util.Locale;
-
-/**
- * @author David Král
- */
-public class OffsetTimeTypeDeserializer extends AbstractDateTimeDeserializer<OffsetTime> {
-
- public OffsetTimeTypeDeserializer(JsonBindingModel model) {
- super(OffsetTime.class, model);
- }
-
- @Override
- protected OffsetTime fromInstant(Instant instant) {
- throw new JsonbException(Messages.getMessage(MessageKeys.TIME_TO_EPOCH_MILLIS_ERROR, OffsetTime.class.getSimpleName()));
- }
-
- @Override
- protected OffsetTime parseDefault(String jsonValue, Locale locale) {
- return OffsetTime.parse(jsonValue, DateTimeFormatter.ISO_OFFSET_TIME.withLocale(locale));
- }
-
- @Override
- protected OffsetTime parseWithFormatter(String jsonValue, DateTimeFormatter formatter) {
- return OffsetTime.parse(jsonValue, formatter);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/OffsetTimeTypeSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/OffsetTimeTypeSerializer.java
deleted file mode 100644
index 4705893..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/OffsetTimeTypeSerializer.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.properties.MessageKeys;
-import org.eclipse.persistence.json.bind.internal.properties.Messages;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.bind.JsonbException;
-import java.time.Instant;
-import java.time.OffsetTime;
-import java.time.format.DateTimeFormatter;
-import java.util.Locale;
-
-/**
- * Serialize OffsetTime.
- *
- * @author David Král
- * @author Roman Grigoriadi
- */
-public class OffsetTimeTypeSerializer extends AbstractDateTimeSerializer<OffsetTime> {
-
- /**
- * Construct serializer.
- */
- public OffsetTimeTypeSerializer(JsonBindingModel model) {
- super(OffsetTime.class, model);
- }
-
- @Override
- protected Instant toInstant(OffsetTime value) {
- throw new JsonbException(Messages.getMessage(MessageKeys.TIME_TO_EPOCH_MILLIS_ERROR, OffsetTime.class.getSimpleName()));
- }
-
- @Override
- protected String formatDefault(OffsetTime value, Locale locale) {
- return DateTimeFormatter.ISO_OFFSET_TIME.withLocale(locale).format(value);
- }
-
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/OptionalDoubleTypeDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/OptionalDoubleTypeDeserializer.java
deleted file mode 100644
index 1c3cf14..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/OptionalDoubleTypeDeserializer.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.JsonbParser;
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.bind.serializer.DeserializationContext;
-import javax.json.stream.JsonParser;
-import java.lang.reflect.Type;
-import java.util.OptionalDouble;
-
-/**
- * @author David Král
- */
-public class OptionalDoubleTypeDeserializer extends AbstractValueTypeDeserializer<OptionalDouble> {
-
- public OptionalDoubleTypeDeserializer(JsonBindingModel model) {
- super(OptionalDouble.class, model);
- }
-
- @Override
- public OptionalDouble deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) {
- final JsonParser.Event next = ((JsonbParser) parser).moveToValue();
- if (next == JsonParser.Event.VALUE_NULL) {
- return OptionalDouble.empty();
- }
- String value = parser.getString();
- return deserialize(value, (Unmarshaller) ctx, rtType);
- }
-
- @Override
- protected OptionalDouble deserialize(String jsonValue, Unmarshaller unmarshaller, Type rtType) {
- return OptionalDouble.of(Double.parseDouble(jsonValue));
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/OptionalDoubleTypeSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/OptionalDoubleTypeSerializer.java
deleted file mode 100644
index a28a67e..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/OptionalDoubleTypeSerializer.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.Marshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.stream.JsonGenerator;
-import java.util.OptionalDouble;
-
-/**
- * @author David Král
- */
-public class OptionalDoubleTypeSerializer extends AbstractValueTypeSerializer<OptionalDouble> {
-
- public OptionalDoubleTypeSerializer(JsonBindingModel model) {
- super(model);
- }
-
- @Override
- protected void serialize(OptionalDouble obj, JsonGenerator generator, String key, Marshaller marshaller) {
- if (obj.isPresent()) {
- generator.write(key, obj.getAsDouble());
- } else if (model.getCustomization().isNillable()) {
- generator.writeNull(key);
- }
- }
-
- @Override
- protected void serialize(OptionalDouble obj, JsonGenerator generator, Marshaller marshaller) {
- if (obj.isPresent()) {
- generator.write(obj.getAsDouble());
- } else if (model.getCustomization().isNillable()) {
- generator.writeNull();
- }
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/OptionalIntTypeDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/OptionalIntTypeDeserializer.java
deleted file mode 100644
index 7829c1e..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/OptionalIntTypeDeserializer.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.JsonbParser;
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.bind.serializer.DeserializationContext;
-import javax.json.stream.JsonParser;
-import java.lang.reflect.Type;
-import java.util.OptionalInt;
-
-/**
- * @author David Král
- */
-public class OptionalIntTypeDeserializer extends AbstractValueTypeDeserializer<OptionalInt> {
-
- public OptionalIntTypeDeserializer(JsonBindingModel model) {
- super(OptionalInt.class, model);
- }
-
- @Override
- public OptionalInt deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) {
- final JsonParser.Event next = ((JsonbParser) parser).moveToValue();
- if (next == JsonParser.Event.VALUE_NULL) {
- return OptionalInt.empty();
- }
- final String value = parser.getString();
- return deserialize(value, (Unmarshaller) ctx, rtType);
- }
-
- @Override
- protected OptionalInt deserialize(String jsonValue, Unmarshaller unmarshaller, Type rtType) {
- return OptionalInt.of(Integer.parseInt(jsonValue));
- }
-
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/OptionalIntTypeSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/OptionalIntTypeSerializer.java
deleted file mode 100644
index 6e54f1d..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/OptionalIntTypeSerializer.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.Marshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.stream.JsonGenerator;
-import java.util.OptionalInt;
-
-/**
- * @author David Král
- */
-public class OptionalIntTypeSerializer extends AbstractValueTypeSerializer<OptionalInt> {
-
- public OptionalIntTypeSerializer(JsonBindingModel model) {
- super(model);
- }
-
- @Override
- protected void serialize(OptionalInt obj, JsonGenerator generator, String key, Marshaller marshaller) {
- if (obj.isPresent()) {
- generator.write(key, obj.getAsInt());
- } else if (model.getCustomization().isNillable()) {
- generator.writeNull(key);
- }
- }
-
- @Override
- protected void serialize(OptionalInt obj, JsonGenerator generator, Marshaller marshaller) {
- if (obj.isPresent()) {
- generator.write(obj.getAsInt());
- } else if (model.getCustomization().isNillable()) {
- generator.writeNull();
- }
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/OptionalLongTypeDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/OptionalLongTypeDeserializer.java
deleted file mode 100644
index 830e861..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/OptionalLongTypeDeserializer.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.JsonbParser;
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.bind.serializer.DeserializationContext;
-import javax.json.stream.JsonParser;
-import java.lang.reflect.Type;
-import java.util.OptionalLong;
-
-/**
- * @author David Král
- */
-public class OptionalLongTypeDeserializer extends AbstractValueTypeDeserializer<OptionalLong> {
-
- public OptionalLongTypeDeserializer(JsonBindingModel model) {
- super(OptionalLong.class, model);
- }
-
- @Override
- public OptionalLong deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) {
- final JsonParser.Event next = ((JsonbParser) parser).moveToValue();
- if (next == JsonParser.Event.VALUE_NULL) {
- return OptionalLong.empty();
- }
- return deserialize(parser.getString(), (Unmarshaller) ctx, rtType);
- }
-
- @Override
- protected OptionalLong deserialize(String jsonValue, Unmarshaller unmarshaller, Type rtType) {
- return OptionalLong.of(Long.parseLong(jsonValue));
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/OptionalLongTypeSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/OptionalLongTypeSerializer.java
deleted file mode 100644
index 606b99b..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/OptionalLongTypeSerializer.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.Marshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.stream.JsonGenerator;
-import java.util.OptionalLong;
-
-/**
- * @author David Král
- */
-public class OptionalLongTypeSerializer extends AbstractValueTypeSerializer<OptionalLong> {
-
- public OptionalLongTypeSerializer(JsonBindingModel model) {
- super(model);
- }
-
- @Override
- protected void serialize(OptionalLong obj, JsonGenerator generator, String key, Marshaller marshaller) {
- if (obj.isPresent()) {
- generator.write(key, obj.getAsLong());
- } else if (model.getCustomization().isNillable()) {
- generator.writeNull(key);
- }
- }
-
- @Override
- protected void serialize(OptionalLong obj, JsonGenerator generator, Marshaller marshaller) {
- if (obj.isPresent()) {
- generator.write(obj.getAsLong());
- } else if (model.getCustomization().isNillable()) {
- generator.writeNull();
- }
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/OptionalObjectSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/OptionalObjectSerializer.java
deleted file mode 100644
index b57e646..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/OptionalObjectSerializer.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.JsonbContext;
-import org.eclipse.persistence.json.bind.internal.ProcessingContext;
-import org.eclipse.persistence.json.bind.internal.unmarshaller.CurrentItem;
-import org.eclipse.persistence.json.bind.model.ClassModel;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-import org.eclipse.persistence.json.bind.model.JsonContext;
-
-import javax.json.bind.serializer.JsonbSerializer;
-import javax.json.bind.serializer.SerializationContext;
-import javax.json.stream.JsonGenerator;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.util.Optional;
-
-/**
- * Common serializer logic for java Optionals.
- *
- * @author Roman Grigoriadi
- */
-public class OptionalObjectSerializer<T extends Optional<?>> implements CurrentItem<T>, JsonbSerializer<T> {
-
-
- private final JsonBindingModel wrapperModel;
-
- private final CurrentItem<?> wrapper;
-
- private final Type optionalValueType;
-
- public OptionalObjectSerializer(SerializerBuilder builder) {
- this.wrapper = builder.getWrapper();
- this.wrapperModel = builder.getModel();
- this.optionalValueType = resolveOptionalType(builder.getRuntimeType());
- }
-
- private Type resolveOptionalType(Type runtimeType) {
- if (runtimeType instanceof ParameterizedType) {
- return ((ParameterizedType) runtimeType).getActualTypeArguments()[0];
- }
- return Object.class;
- }
-
- @Override
- public ClassModel getClassModel() {
- return null;
- }
-
- @Override
- public CurrentItem<?> getWrapper() {
- return wrapper;
- }
-
- @Override
- public Type getRuntimeType() {
- return optionalValueType;
- }
-
- @Override
- public JsonBindingModel getWrapperModel() {
- return wrapperModel;
- }
-
- @Override
- public void serialize(T obj, JsonGenerator generator, SerializationContext ctx) {
- JsonbContext jsonbContext = ((ProcessingContext) ctx).getJsonbContext();
- if (obj == null || !obj.isPresent()) {
- if (!wrapperModel.getCustomization().isNillable()) {
- return;
- }
- if (wrapperModel.getContext() == JsonContext.JSON_OBJECT) {
- generator.writeNull(wrapperModel.getWriteName());
- } else {
- generator.writeNull();
- }
- return;
- }
- Object optionalValue = obj.get();
- final JsonbSerializer<?> serializer = new SerializerBuilder(jsonbContext).withObjectClass(optionalValue.getClass())
- .withType(optionalValueType).withWrapper(wrapper).withModel(wrapperModel).build();
- serialCaptor(serializer, optionalValue, generator, ctx);
- }
-
- private <T> void serialCaptor(JsonbSerializer<?> serializer, T object, JsonGenerator generator, SerializationContext context) {
- ((JsonbSerializer<T>) serializer).serialize(object, generator, context);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/PeriodTypeDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/PeriodTypeDeserializer.java
deleted file mode 100644
index 0a8535c..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/PeriodTypeDeserializer.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import java.lang.reflect.Type;
-import java.time.Period;
-
-/**
- * @author David Král
- */
-public class PeriodTypeDeserializer extends AbstractValueTypeDeserializer<Period> {
-
- public PeriodTypeDeserializer(JsonBindingModel model) {
- super(Period.class, model);
- }
-
- @Override
- protected Period deserialize(String jsonValue, Unmarshaller unmarshaller, Type rtType) {
- return Period.parse(jsonValue);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/PeriodTypeSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/PeriodTypeSerializer.java
deleted file mode 100644
index 64b670d..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/PeriodTypeSerializer.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.Marshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.stream.JsonGenerator;
-import java.time.Period;
-
-/**
- * @author David Král
- */
-public class PeriodTypeSerializer extends AbstractValueTypeSerializer<Period> {
-
- public PeriodTypeSerializer(JsonBindingModel model) {
- super(model);
- }
-
- @Override
- protected void serialize(Period obj, JsonGenerator generator, String key, Marshaller marshaller) {
- generator.write(key, obj.toString());
- }
-
- @Override
- protected void serialize(Period obj, JsonGenerator generator, Marshaller marshaller) {
- generator.write(obj.toString());
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/SerializerBuilder.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/SerializerBuilder.java
deleted file mode 100644
index 003ebfd..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/SerializerBuilder.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.AbstractSerializerBuilder;
-import org.eclipse.persistence.json.bind.internal.ComponentMatcher;
-import org.eclipse.persistence.json.bind.internal.JsonbContext;
-import org.eclipse.persistence.json.bind.internal.ReflectionUtils;
-import org.eclipse.persistence.json.bind.internal.adapter.AdapterBinding;
-import org.eclipse.persistence.json.bind.internal.adapter.SerializerBinding;
-
-import javax.json.JsonObject;
-import javax.json.JsonValue;
-import javax.json.bind.config.BinaryDataStrategy;
-import javax.json.bind.serializer.JsonbSerializer;
-import java.lang.reflect.GenericArrayType;
-import java.lang.reflect.Type;
-import java.util.Collection;
-import java.util.Map;
-import java.util.Optional;
-
-/**
- * Builder for serialziers.
- *
- * @author Roman Grigoriadi
- */
-public class SerializerBuilder extends AbstractSerializerBuilder<SerializerBuilder> {
-
- private Class<?> objectClass;
-
- public SerializerBuilder(JsonbContext jsonbContext) {
- super(jsonbContext);
- }
-
- public SerializerBuilder withObjectClass(Class<?> objectClass) {
- this.objectClass = objectClass;
- return this;
- }
-
- public JsonbSerializer<?> build() {
- runtimeType = resolveRuntimeType();
-
- //First check if user deserializer is registered for such type
- final ComponentMatcher componentMatcher = jsonbContext.getComponentMatcher();
- Optional<SerializerBinding<?>> userSerializer = componentMatcher.getSerialzierBinding(getRuntimeType(), getModel());
- if (userSerializer.isPresent() &&
- !(wrapper instanceof UserSerializerSerializer && ReflectionUtils.getRawType(wrapper.getRuntimeType()).isAssignableFrom(objectClass))) {
- return new UserSerializerSerializer<>(model, userSerializer.get().getJsonbSerializer());
- }
-
- //Second user adapter is registered.
- final Optional<AdapterBinding> adapterInfoOptional = componentMatcher.getAdapterBinding(getRuntimeType(), getModel());
- if (adapterInfoOptional.isPresent()) {
- return new AdaptedObjectSerializer<>(getModel(), adapterInfoOptional.get());
- }
-
- final Optional<AbstractValueTypeSerializer<?>> supportedTypeSerializer = getSupportedTypeSerializer(objectClass);
- if (supportedTypeSerializer.isPresent()) {
- return supportedTypeSerializer.get();
- }
-
- if (Collection.class.isAssignableFrom(objectClass)) {
- return new CollectionSerializer<>(this);
- } else if (Map.class.isAssignableFrom(objectClass)) {
- return new MapSerializer<>(this);
- } else if (isByteArray(objectClass)) {
- String strategy = jsonbContext.getBinaryDataStrategy();
- switch (strategy) {
- case BinaryDataStrategy.BYTE:
- return new ByteArraySerializer(this);
- default:
- return new ByteArrayBase64Serializer(byte[].class, getModel());
- }
- } else if (objectClass.isArray() || getRuntimeType() instanceof GenericArrayType) {
- return createArrayItem(objectClass.getComponentType());
-
- } else if (JsonValue.class.isAssignableFrom(objectClass)) {
- if(JsonObject.class.isAssignableFrom(objectClass)) {
- return new JsonObjectSerialzier(this);
- } else {
- return new JsonArraySerialzier(this);
- }
- } else if (Optional.class.isAssignableFrom(objectClass)) {
- return new OptionalObjectSerializer<>(this);
- } else {
- jsonbContext.getMappingContext().addSerializerProvider(objectClass, new ObjectSerializerProvider());
- return new ObjectSerializer<>(this);
- }
-
- }
-
- private boolean isByteArray(Class<?> rawType) {
- return rawType.isArray() && rawType.getComponentType() == Byte.TYPE;
- }
-
- /**
- * Instance is not created in case of array items, because, we don't know how long it should be
- * till parser ends parsing.
- */
- private JsonbSerializer<?> createArrayItem(Class<?> componentType) {
- if (componentType == byte.class) {
- return new ByteArraySerializer(this);
- } else if (componentType == short.class) {
- return new ShortArraySerializer(this);
- } else if (componentType == int.class) {
- return new IntArraySerializer(this);
- } else if (componentType == long.class) {
- return new LongArraySerializer(this);
- } else if (componentType == float.class) {
- return new FloatArraySerializer(this);
- } else if (componentType == double.class) {
- return new DoubleArraySerializer(this);
- } else {
- return new ObjectArraySerializer(this);
- }
- }
-
- private Optional<AbstractValueTypeSerializer<?>> getSupportedTypeSerializer(Class<?> rawType) {
- final Optional<? extends SerializerProviderWrapper> supportedTypeSerializerOptional = DefaultSerializers.getInstance().findValueSerializerProvider(rawType);
- if (supportedTypeSerializerOptional.isPresent()) {
- return Optional.of(supportedTypeSerializerOptional.get().getSerializerProvider().provideSerializer(getModel()));
- }
- return Optional.empty();
- }
-
- private Type resolveRuntimeType() {
- if (genericType != null) {
- return genericType;
- }
- if (getModel() != null) {
- return getModel().getType();
- }
- return objectClass;
- }
-
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/SerializerProviderWrapper.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/SerializerProviderWrapper.java
deleted file mode 100644
index 1e0d892..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/SerializerProviderWrapper.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-/**
- * Wraps serializer and deserializer providers.
- *
- * @author Roman Grigoriadi
- */
-public class SerializerProviderWrapper {
-
- private ISerializerProvider serializerProvider;
- private IDeserializerProvider deserializerProvider;
-
- public SerializerProviderWrapper(ISerializerProvider serializerProvider, IDeserializerProvider deserializerProvider) {
- this.serializerProvider = serializerProvider;
- this.deserializerProvider = deserializerProvider;
- }
-
- public ISerializerProvider getSerializerProvider() {
- return serializerProvider;
- }
-
- public IDeserializerProvider getDeserializerProvider() {
- return deserializerProvider;
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ShortArraySerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ShortArraySerializer.java
deleted file mode 100644
index 42293ab..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ShortArraySerializer.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import javax.json.bind.serializer.SerializationContext;
-import javax.json.stream.JsonGenerator;
-
-/**
- * Serializer for arrays of shorts.
- * @author Roman Grigoriadi
- */
-public class ShortArraySerializer extends AbstractArraySerializer<short[]> {
-
- protected ShortArraySerializer(SerializerBuilder builder) {
- super(builder);
- }
-
- @Override
- protected void serializeInternal(short[] arr, JsonGenerator generator, SerializationContext ctx) {
- for (short obj : arr) {
- generator.write(obj);
- }
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ShortTypeDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ShortTypeDeserializer.java
deleted file mode 100644
index 4d19088..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ShortTypeDeserializer.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import java.lang.reflect.Type;
-
-/**
- * @author David Král
- */
-public class ShortTypeDeserializer extends AbstractNumberDeserializer<Short> {
-
- public ShortTypeDeserializer(JsonBindingModel model) {
- super(Short.class, model);
- }
-
- @Override
- protected Short deserialize(String jsonValue, Unmarshaller unmarshaller, Type rtType) {
- return deserializeForamtted(jsonValue, true, unmarshaller.getJsonbContext()).map(num -> Short.parseShort(num.toString()))
- .orElseGet(() -> Short.parseShort(jsonValue));
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ShortTypeSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ShortTypeSerializer.java
deleted file mode 100644
index ee08364..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ShortTypeSerializer.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.stream.JsonGenerator;
-
-/**
- * @author David Král
- */
-public class ShortTypeSerializer extends AbstractNumberSerializer<Short> {
-
- public ShortTypeSerializer(JsonBindingModel model) {
- super(Short.class, model);
- }
-
- @Override
- protected void serializeNonFormatted(Short obj, JsonGenerator generator, String key) {
- generator.write(key, obj);
- }
-
- @Override
- protected void serializeNonFormatted(Short obj, JsonGenerator generator) {
- generator.write(obj);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/StringTypeDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/StringTypeDeserializer.java
deleted file mode 100644
index 2c90789..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/StringTypeDeserializer.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.ProcessingContext;
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-import org.eclipse.persistence.json.bind.internal.properties.MessageKeys;
-import org.eclipse.persistence.json.bind.internal.properties.Messages;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.bind.JsonbConfig;
-import javax.json.bind.JsonbException;
-import java.io.UnsupportedEncodingException;
-import java.lang.reflect.Type;
-
-/**
- * @author Roman Grigoriadi
- */
-public class StringTypeDeserializer extends AbstractValueTypeDeserializer<String> {
-
- public StringTypeDeserializer(JsonBindingModel model) {
- super(String.class, model);
- }
-
- @Override
- protected String deserialize(String jsonValue, Unmarshaller unmarshaller, Type rtType) {
- if ((boolean) unmarshaller.getJsonbContext().getConfig().getProperty(JsonbConfig.STRICT_IJSON).orElse(false)) {
- try {
- String newString = new String(jsonValue.getBytes("UTF-8"), "UTF-8");
- if (!newString.equals(jsonValue)) {
- throw new JsonbException(Messages.getMessage(MessageKeys.UNPAIRED_SURROGATE));
- }
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- }
- return jsonValue;
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/StringTypeSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/StringTypeSerializer.java
deleted file mode 100644
index 929c8af..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/StringTypeSerializer.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.JsonbContext;
-import org.eclipse.persistence.json.bind.internal.Marshaller;
-import org.eclipse.persistence.json.bind.internal.properties.MessageKeys;
-import org.eclipse.persistence.json.bind.internal.properties.Messages;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.bind.JsonbConfig;
-import javax.json.bind.JsonbException;
-import javax.json.stream.JsonGenerator;
-import java.io.UnsupportedEncodingException;
-
-/**
- * @author Roman Grigoriadi
- */
-public class StringTypeSerializer extends AbstractValueTypeSerializer<String> {
-
- public StringTypeSerializer(JsonBindingModel model) {
- super(model);
- }
-
- private String toJson(String object, JsonbContext jsonbContext) {
- if ((boolean) jsonbContext.getConfig().getProperty(JsonbConfig.STRICT_IJSON).orElse(false)) {
- try {
- String newString = new String(object.getBytes("UTF-8"), "UTF-8");
- if (!newString.equals(object)) {
- throw new JsonbException(Messages.getMessage(MessageKeys.UNPAIRED_SURROGATE));
- }
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- }
- return object;
- }
-
- @Override
- protected void serialize(String obj, JsonGenerator generator, String key, Marshaller marshaller) {
- generator.write(key, toJson(obj, marshaller.getJsonbContext()));
- }
-
- @Override
- protected void serialize(String obj, JsonGenerator generator, Marshaller marshaller) {
- generator.write(toJson(obj, marshaller.getJsonbContext()));
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/TimeZoneTypeDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/TimeZoneTypeDeserializer.java
deleted file mode 100644
index 85b96ce..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/TimeZoneTypeDeserializer.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.bind.JsonbException;
-import java.lang.reflect.Type;
-import java.util.TimeZone;
-
-/**
- * @author David Král
- */
-public class TimeZoneTypeDeserializer extends AbstractValueTypeDeserializer<TimeZone> {
-
- public TimeZoneTypeDeserializer(JsonBindingModel model) {
- super(TimeZone.class, model);
- }
-
- @Override
- protected TimeZone deserialize(String jsonValue, Unmarshaller unmarshaller, Type rtType) {
- //Use of three-letter time zone ID has been already deprecated and is not supported.
- if (jsonValue.length() == 3) {
- throw new JsonbException("Unsupported TimeZone: " + jsonValue);
- }
- return TimeZone.getTimeZone(jsonValue);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/TimeZoneTypeSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/TimeZoneTypeSerializer.java
deleted file mode 100644
index 31f75df..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/TimeZoneTypeSerializer.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.Marshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.stream.JsonGenerator;
-import java.util.TimeZone;
-
-/**
- * @author David Král
- */
-public class TimeZoneTypeSerializer extends AbstractValueTypeSerializer<TimeZone> {
-
- public TimeZoneTypeSerializer(JsonBindingModel model) {
- super(model);
- }
-
- @Override
- protected void serialize(TimeZone obj, JsonGenerator generator, String key, Marshaller marshaller) {
- generator.write(key, obj.getID());
- }
-
- @Override
- protected void serialize(TimeZone obj, JsonGenerator generator, Marshaller marshaller) {
- generator.write(obj.getID());
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/URITypeDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/URITypeDeserializer.java
deleted file mode 100644
index 9f8fa43..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/URITypeDeserializer.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import java.lang.reflect.Type;
-import java.net.URI;
-
-/**
- * @author David Král
- */
-public class URITypeDeserializer extends AbstractValueTypeDeserializer<URI> {
-
- public URITypeDeserializer(JsonBindingModel model) {
- super(URI.class, model);
- }
-
- @Override
- protected URI deserialize(String jsonValue, Unmarshaller unmarshaller, Type rtType) {
- return URI.create(jsonValue);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/URITypeSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/URITypeSerializer.java
deleted file mode 100644
index c0b7601..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/URITypeSerializer.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-
-import org.eclipse.persistence.json.bind.internal.Marshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.stream.JsonGenerator;
-import java.net.URI;
-
-/**
- * @author David Král
- */
-public class URITypeSerializer extends AbstractValueTypeSerializer<URI> {
-
- public URITypeSerializer(JsonBindingModel model) {
- super(model);
- }
-
- @Override
- protected void serialize(URI obj, JsonGenerator generator, String key, Marshaller marshaller) {
- generator.write(key, obj.toString());
- }
-
- @Override
- protected void serialize(URI obj, JsonGenerator generator, Marshaller marshaller) {
- generator.write(obj.toString());
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/URLTypeDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/URLTypeDeserializer.java
deleted file mode 100644
index 87132d4..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/URLTypeDeserializer.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import java.lang.reflect.Type;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-/**
- * @author David Král
- */
-public class URLTypeDeserializer extends AbstractValueTypeDeserializer<URL> {
-
- public URLTypeDeserializer(JsonBindingModel model) {
- super(URL.class, model);
- }
-
- @Override
- protected URL deserialize(String jsonValue, Unmarshaller unmarshaller, Type rtType) {
- URL url = null;
- try {
- url = new URL(jsonValue);
- } catch (MalformedURLException e) {
- e.printStackTrace();
- }
- return url;
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/URLTypeSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/URLTypeSerializer.java
deleted file mode 100644
index b9f4f50..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/URLTypeSerializer.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-
-import org.eclipse.persistence.json.bind.internal.Marshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.stream.JsonGenerator;
-import java.net.URL;
-
-/**
- * @author David Král
- */
-public class URLTypeSerializer extends AbstractValueTypeSerializer<URL> {
-
- public URLTypeSerializer(JsonBindingModel model) {
- super(model);
- }
-
- @Override
- protected void serialize(URL obj, JsonGenerator generator, String key, Marshaller marshaller) {
- generator.write(key, obj.toString());
- }
-
- @Override
- protected void serialize(URL obj, JsonGenerator generator, Marshaller marshaller) {
- generator.write(obj.toString());
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/UserSerializerSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/UserSerializerSerializer.java
deleted file mode 100644
index 5485c1d..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/UserSerializerSerializer.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-import org.eclipse.persistence.json.bind.model.JsonContext;
-
-import javax.json.bind.serializer.JsonbSerializer;
-import javax.json.bind.serializer.SerializationContext;
-import javax.json.stream.JsonGenerator;
-
-/**
- * Serializes an object with user defined serializer.
- *
- * @author Roman Grigoriadi
- */
-public class UserSerializerSerializer<T> implements JsonbSerializer<T> {
-
- private final JsonbSerializer<T> userSerializer;
-
- private JsonBindingModel model;
-
- /**
- * Create instance of current item with its builder.
- *
- * @param model model
- * @param userSerializer user serializer
- */
- public UserSerializerSerializer(JsonBindingModel model, JsonbSerializer<T> userSerializer) {
- this.model = model;
- this.userSerializer = userSerializer;
- }
-
-
- @Override
- public void serialize(T obj, JsonGenerator generator, SerializationContext ctx) {
- if (model.getContext() == JsonContext.JSON_OBJECT) {
- generator.writeKey(model.getWriteName());
- }
- userSerializer.serialize(obj, generator, ctx);
- }
-
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ZoneIdTypeDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ZoneIdTypeDeserializer.java
deleted file mode 100644
index 6886e67..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ZoneIdTypeDeserializer.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import java.lang.reflect.Type;
-import java.time.ZoneId;
-
-/**
- * @author David Král
- */
-public class ZoneIdTypeDeserializer extends AbstractValueTypeDeserializer<ZoneId> {
-
- public ZoneIdTypeDeserializer(JsonBindingModel model) {
- super(ZoneId.class, model);
- }
-
- @Override
- protected ZoneId deserialize(String jsonValue, Unmarshaller unmarshaller, Type rtType) {
- return ZoneId.of(jsonValue);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ZoneIdTypeSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ZoneIdTypeSerializer.java
deleted file mode 100644
index 0b728e0..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ZoneIdTypeSerializer.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.Marshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.stream.JsonGenerator;
-import java.time.ZoneId;
-
-/**
- * @author David Král
- */
-public class ZoneIdTypeSerializer extends AbstractValueTypeSerializer<ZoneId> {
-
- public ZoneIdTypeSerializer(JsonBindingModel model) {
- super(model);
- }
-
- @Override
- protected void serialize(ZoneId obj, JsonGenerator generator, String key, Marshaller marshaller) {
- generator.write(key, obj.getId());
- }
-
- @Override
- protected void serialize(ZoneId obj, JsonGenerator generator, Marshaller marshaller) {
- generator.write(obj.getId());
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ZoneOffsetTypeDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ZoneOffsetTypeDeserializer.java
deleted file mode 100644
index bf7ea5e..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ZoneOffsetTypeDeserializer.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import java.lang.reflect.Type;
-import java.time.ZoneOffset;
-
-/**
- * @author David Král
- */
-public class ZoneOffsetTypeDeserializer extends AbstractValueTypeDeserializer<ZoneOffset> {
-
- public ZoneOffsetTypeDeserializer(JsonBindingModel model) {
- super(ZoneOffset.class, model);
- }
-
- @Override
- protected ZoneOffset deserialize(String jsonValue, Unmarshaller unmarshaller, Type rtType) {
- return ZoneOffset.of(jsonValue);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ZoneOffsetTypeSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ZoneOffsetTypeSerializer.java
deleted file mode 100644
index d7fed32..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ZoneOffsetTypeSerializer.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.Marshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.stream.JsonGenerator;
-import java.time.ZoneOffset;
-
-/**
- * @author David Král
- */
-public class ZoneOffsetTypeSerializer extends AbstractValueTypeSerializer<ZoneOffset> {
-
- public ZoneOffsetTypeSerializer(JsonBindingModel model) {
- super(model);
- }
-
- @Override
- protected void serialize(ZoneOffset obj, JsonGenerator generator, String key, Marshaller marshaller) {
- generator.write(key, obj.getId());
- }
-
- @Override
- protected void serialize(ZoneOffset obj, JsonGenerator generator, Marshaller marshaller) {
- generator.write(obj.getId());
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ZonedDateTimeTypeDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ZonedDateTimeTypeDeserializer.java
deleted file mode 100644
index 5515b8a..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ZonedDateTimeTypeDeserializer.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.internal.properties.MessageKeys;
-import org.eclipse.persistence.json.bind.internal.properties.Messages;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import java.time.Instant;
-import java.time.ZoneId;
-import java.time.ZonedDateTime;
-import java.time.format.DateTimeFormatter;
-import java.util.Locale;
-import java.util.logging.Logger;
-
-/**
- * @author David Král
- */
-public class ZonedDateTimeTypeDeserializer extends AbstractDateTimeDeserializer<ZonedDateTime> {
-
- private static final Logger log = Logger.getLogger(ZonedDateTimeTypeDeserializer.class.getName());
-
-
- public ZonedDateTimeTypeDeserializer(JsonBindingModel model) {
- super(ZonedDateTime.class, model);
- }
-
- /**
- * fromInstant is called only in case {@link javax.json.bind.annotation.JsonbDateFormat} is TIME_IN_MILLIS,
- * which doesn't make much sense for usage with ZonedDateTime.
- */
- @Override
- protected ZonedDateTime fromInstant(Instant instant) {
- final ZoneId zone = ZoneId.systemDefault();
- log.warning(Messages.getMessage(MessageKeys.OFFSET_DATE_TIME_FROM_MILLIS, ZonedDateTime.class.getSimpleName(), zone));
- return ZonedDateTime.ofInstant(instant, zone);
- }
-
- @Override
- protected ZonedDateTime parseDefault(String jsonValue, Locale locale) {
- return ZonedDateTime.parse(jsonValue, DateTimeFormatter.ISO_ZONED_DATE_TIME.withLocale(locale));
- }
-
- @Override
- protected ZonedDateTime parseWithFormatter(String jsonValue, DateTimeFormatter formatter) {
- return ZonedDateTime.parse(jsonValue, formatter);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ZonedDateTimeTypeSerializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ZonedDateTimeTypeSerializer.java
deleted file mode 100644
index 3ae6450..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/serializer/ZonedDateTimeTypeSerializer.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.serializer;
-
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import java.time.Instant;
-import java.time.ZonedDateTime;
-import java.time.format.DateTimeFormatter;
-import java.util.Locale;
-import java.util.logging.Logger;
-
-/**
- * @author David Král
- */
-public class ZonedDateTimeTypeSerializer extends AbstractDateTimeSerializer<ZonedDateTime> {
-
- private static final Logger log = Logger.getLogger(ZonedDateTimeTypeSerializer.class.getName());
-
-
- public ZonedDateTimeTypeSerializer(JsonBindingModel model) {
- super(ZonedDateTime.class, model);
- }
-
- @Override
- protected Instant toInstant(ZonedDateTime value) {
- return value.toInstant();
- }
-
-
- @Override
- protected String formatDefault(ZonedDateTime value, Locale locale) {
- return DateTimeFormatter.ISO_ZONED_DATE_TIME.withLocale(locale).format(value);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/AbstractArrayDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/AbstractArrayDeserializer.java
deleted file mode 100644
index 22150a6..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/AbstractArrayDeserializer.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.unmarshaller;
-
-import org.eclipse.persistence.json.bind.internal.JsonbParser;
-import org.eclipse.persistence.json.bind.internal.JsonbRiParser;
-import org.eclipse.persistence.json.bind.internal.ReflectionUtils;
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.bind.serializer.JsonbDeserializer;
-import javax.json.stream.JsonParser;
-import java.lang.reflect.GenericArrayType;
-import java.util.List;
-
-/**
- * Common array unmarshalling item implementation.
- *
- * @author Roman Grigoriadi
- */
-public abstract class AbstractArrayDeserializer<T> extends AbstractContainerDeserializer<T> implements EmbeddedItem {
-
- /**
- * Runtime type class of an array.
- */
- protected final Class<?> componentClass;
-
- private final JsonBindingModel model;
-
- protected AbstractArrayDeserializer(DeserializerBuilder builder) {
- super(builder);
- if (getRuntimeType() instanceof GenericArrayType) {
- componentClass = ReflectionUtils.resolveRawType(this, ((GenericArrayType) getRuntimeType()).getGenericComponentType());
- } else {
- componentClass = ReflectionUtils.getRawType(getRuntimeType()).getComponentType();
- }
- this.model = new ContainerModel(componentClass, resolveContainerModelCustomization(componentClass, builder.getJsonbContext()));
- }
-
- /**
- * Binding model for current deserializer.
- *
- * @return model
- */
- @Override
- protected JsonBindingModel getModel() {
- return model;
- }
-
- @Override
- public void appendResult(Object result) {
- appendCaptor(result);
- }
-
- @SuppressWarnings("unchecked")
- private <X> void appendCaptor(X value) {
- ((List<X>) getItems()).add(value);
- }
-
- @Override
- protected void deserializeNext(JsonParser parser, Unmarshaller context) {
- final JsonbDeserializer<?> deserializer = newUnmarshallerItemBuilder(context.getJsonbContext()).withType(componentClass)
- .withModel(model).build();
- appendResult(deserializer.deserialize(parser, context, componentClass));
- }
-
- protected abstract List<?> getItems();
-
- @Override
- protected JsonbRiParser.LevelContext moveToFirst(JsonbParser parser) {
- parser.moveTo(JsonParser.Event.START_ARRAY);
- return parser.getCurrentLevel();
- }
-}
\ No newline at end of file
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/AbstractContainerDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/AbstractContainerDeserializer.java
deleted file mode 100644
index 215a7a1..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/AbstractContainerDeserializer.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- * <p>
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.unmarshaller;
-
-import org.eclipse.persistence.json.bind.internal.JsonbContext;
-import org.eclipse.persistence.json.bind.internal.JsonbParser;
-import org.eclipse.persistence.json.bind.internal.JsonbRiParser;
-import org.eclipse.persistence.json.bind.internal.ReflectionUtils;
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-import org.eclipse.persistence.json.bind.internal.properties.MessageKeys;
-import org.eclipse.persistence.json.bind.internal.properties.Messages;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.bind.JsonbException;
-import javax.json.bind.serializer.DeserializationContext;
-import javax.json.bind.serializer.JsonbDeserializer;
-import javax.json.stream.JsonParser;
-import java.lang.reflect.Type;
-
-/**
- * @author Roman Grigoriadi
- */
-public abstract class AbstractContainerDeserializer<T> extends AbstractItem<T> implements JsonbDeserializer<T> {
-
- protected JsonbRiParser.LevelContext parserContext;
-
- /**
- * Create instance of current item with its builder.
- *
- * @param builder
- */
- protected AbstractContainerDeserializer(DeserializerBuilder builder) {
- super(builder);
- }
-
- /**
- * Drives JSONP {@link JsonParser} to deserialize json document.
- *
- * @return instance of a type for this item
- */
- @Override
- public final T deserialize(JsonParser parser, DeserializationContext context, Type rtType) {
- Unmarshaller ctx = (Unmarshaller) context;
- ctx.setCurrent(this);
- deserializeInternal((JsonbParser) parser, ctx);
- ctx.setCurrent(getWrapper());
- return getInstance((Unmarshaller) context);
- }
-
- protected abstract T getInstance(Unmarshaller unmarshaller);
-
-
- protected void deserializeInternal(JsonbParser parser, Unmarshaller context) {
- parserContext = moveToFirst(parser);
- while (parser.hasNext()) {
- final JsonParser.Event event = parser.next();
- switch (event) {
- case START_OBJECT:
- case START_ARRAY:
- case VALUE_STRING:
- case VALUE_NUMBER:
- case VALUE_FALSE:
- case VALUE_TRUE:
- deserializeNext(parser, context);
- break;
- case KEY_NAME:
- break;
- case VALUE_NULL:
- appendResult(null);
- break;
- case END_OBJECT:
- case END_ARRAY:
- return;
- default:
- throw new JsonbException(Messages.getMessage(MessageKeys.NOT_VALUE_TYPE, event));
- }
- }
- }
-
- /**
- * Determine class mappings and create an instance of a new deserializer.
- * Currently processed deserializer is pushed to stack, for waiting till new object is finished.
- */
- protected abstract void deserializeNext(JsonParser parser, Unmarshaller context);
-
- /**
- * Move to first event for current deserializer structure.
- * @param parser parser
- * @return first event
- */
- protected abstract JsonbRiParser.LevelContext moveToFirst(JsonbParser parser);
-
- /**
- * Binding model for current deserializer.
- * @return model
- */
- protected abstract JsonBindingModel getModel();
-
-
- protected DeserializerBuilder newUnmarshallerItemBuilder(JsonbContext ctx) {
- return new DeserializerBuilder(ctx).withWrapper(this).withJsonValueType(JsonValueType.of(parserContext.getLastEvent()));
- }
-
- protected JsonbDeserializer<?> newCollectionOrMapItem(Type valueType, JsonbContext ctx) {
- Type actualValueType = ReflectionUtils.resolveType(this, valueType);
- return newUnmarshallerItemBuilder(ctx).withType(actualValueType).withModel(getModel()).build();
- }
-
- /**
- * After object is transitively deserialized from JSON, "append" it to its wrapper.
- * In case of a field set value to field, in case of collections
- * or other embedded objects use methods provided.
- * @param result instance result of an item
- */
- public abstract void appendResult(Object result);
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/AbstractItem.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/AbstractItem.java
deleted file mode 100644
index 2504f03..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/AbstractItem.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-package org.eclipse.persistence.json.bind.internal.unmarshaller;
-
-import org.eclipse.persistence.json.bind.internal.AbstractSerializerBuilder;
-import org.eclipse.persistence.json.bind.internal.JsonbContext;
-import org.eclipse.persistence.json.bind.internal.ProcessingContext;
-import org.eclipse.persistence.json.bind.internal.ReflectionUtils;
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-import org.eclipse.persistence.json.bind.model.ClassModel;
-import org.eclipse.persistence.json.bind.model.ContainerCustomization;
-import org.eclipse.persistence.json.bind.model.Customization;
-import org.eclipse.persistence.json.bind.model.CustomizationBuilder;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import java.lang.reflect.Type;
-
-/**
- * Metadata wrapper for currently processed object.
- * References mapping models of an unmarshalled item,
- * creates instances of it, sets finished unmarshalled objects into object tree.
- *
- * @param <T> Instantiated object type
- * @author Roman Grigoriadi
- */
-public abstract class AbstractItem<T> implements CurrentItem<T> {
-
- /**
- * Item containing instance of wrapping object and its metadata.
- * Null in case of a root object.
- */
- private final CurrentItem<?> wrapper;
-
- private final Type runtimeType;
-
- /**
- * Cached reference to mapping model of an item.
- */
- private final ClassModel classModel;
-
- /**
- * Cached reference of a model of this item in wrapper class (if any).
- */
- private final JsonBindingModel wrapperModel;
-
- /**
- * Create instance of current item with its builder.
- */
- protected AbstractItem(AbstractSerializerBuilder builder) {
- this.wrapper = builder.getWrapper();
- this.wrapperModel = builder.getModel();
- this.classModel = builder.getClassModel();
- this.runtimeType = builder.getRuntimeType();
- }
-
- public AbstractItem(CurrentItem<?> wrapper, Type runtimeType, ClassModel classModel, JsonBindingModel wrapperModel) {
- this.wrapper = wrapper;
- this.runtimeType = runtimeType;
- this.classModel = classModel;
- this.wrapperModel = wrapperModel;
- }
-
- @Override
- public ClassModel getClassModel() {
- return classModel;
- }
-
- @Override
- public CurrentItem<?> getWrapper() {
- return wrapper;
- }
-
- /**
- * A wrapper model for this item. May represent a JavaBean property or a container like collection.
- *
- * @return wrapper model.
- */
- @Override
- public JsonBindingModel getWrapperModel() {
- return wrapperModel;
- }
-
- @Override
- public Type getRuntimeType() {
- return runtimeType;
- }
-
- protected Customization resolveContainerModelCustomization(Type componentType, JsonbContext jsonbContext) {
- Class<?> valueRawType = ReflectionUtils.resolveRawType(this, componentType);
- ClassModel classModel = jsonbContext.getMappingContext().getClassModel(valueRawType);
- if (classModel != null) {
- return new ContainerCustomization(classModel.getCustomization());
- }
- // TODO deal with DefaultCustomization
- return new ContainerCustomization(new CustomizationBuilder());
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/AbstractJsonpDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/AbstractJsonpDeserializer.java
deleted file mode 100644
index 6a5ff72..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/AbstractJsonpDeserializer.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.unmarshaller;
-
-import org.eclipse.persistence.json.bind.internal.JsonbParser;
-import org.eclipse.persistence.json.bind.internal.JsonbRiParser;
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-import org.eclipse.persistence.json.bind.internal.properties.MessageKeys;
-import org.eclipse.persistence.json.bind.internal.properties.Messages;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.JsonArray;
-import javax.json.JsonObject;
-import javax.json.JsonValue;
-import javax.json.bind.JsonbException;
-import javax.json.bind.serializer.JsonbDeserializer;
-import javax.json.stream.JsonParser;
-import java.math.BigDecimal;
-
-/**
- * Common implementation for JSONP Object and Array.
- *
- * TODO JSONP 1.1
- * This is subject to change after JSONP 1.1 release,
- * which will have support for getting JsonObject and JsonArray directly from JsonParser.
- *
- * @author Roman Grigoriadi
- */
-public abstract class AbstractJsonpDeserializer<T extends JsonValue> extends AbstractContainerDeserializer<T> {
-
- /**
- * Create instance of current item with its builder.
- *
- * @param builder
- */
- protected AbstractJsonpDeserializer(DeserializerBuilder builder) {
- super(builder);
- }
-
- @Override
- protected void deserializeInternal(JsonbParser parser, Unmarshaller context) {
- this.parserContext = moveToFirst(parser);
- while (parser.hasNext()) {
- final JsonParser.Event event = parser.next();
- final String lastKey = parserContext.getLastKeyName();
- switch (event) {
- case START_OBJECT:
- case START_ARRAY:
- deserializeNext(parser, context);
- break;
- case VALUE_STRING:
- appendString(lastKey, parser.getString());
- break;
- case VALUE_NUMBER:
- appendNumber(lastKey, parser.getBigDecimal());
- break;
- case VALUE_NULL:
- appendNull(lastKey);
- break;
- case VALUE_FALSE:
- appendBoolean(lastKey, Boolean.FALSE);
- break;
- case VALUE_TRUE:
- appendBoolean(lastKey, Boolean.TRUE);
- break;
- case END_OBJECT:
- case END_ARRAY:
- return;
- case KEY_NAME:
- break;
- default:
- throw new JsonbException(Messages.getMessage(MessageKeys.NOT_VALUE_TYPE, event));
- }
- }
- }
-
- @Override
- protected JsonBindingModel getModel() {
- return getWrapperModel();
-
- }
-
- @Override
- protected JsonbRiParser.LevelContext moveToFirst(JsonbParser parser) {
- parser.moveToStartStructure();
- return parser.getCurrentLevel();
- }
-
- /**
- * Determine class mappings and create an instance of a new deserializer.
- * Currently processed deserializer is pushed to stack, for waiting till new object is finished.
- *
- * @param parser
- * @param context
- */
- @Override
- protected void deserializeNext(JsonParser parser, Unmarshaller context) {
- Class<?> type = parserContext.getLastEvent() == JsonParser.Event.START_OBJECT ? JsonObject.class : JsonArray.class;
- final JsonbDeserializer<?> deserializer = newUnmarshallerItemBuilder(context.getJsonbContext()).withType(type).build();
- appendResult(deserializer.deserialize(parser, context, type));
- }
-
- protected abstract void appendString(String key, String value);
- protected abstract void appendNumber(String key, BigDecimal value);
- protected abstract void appendBoolean(String key, Boolean value);
- protected abstract void appendNull(String key);
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/AdaptedObjectDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/AdaptedObjectDeserializer.java
deleted file mode 100644
index 8c2cf23..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/AdaptedObjectDeserializer.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.unmarshaller;
-
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-import org.eclipse.persistence.json.bind.internal.adapter.AdapterBinding;
-import org.eclipse.persistence.json.bind.internal.properties.MessageKeys;
-import org.eclipse.persistence.json.bind.internal.properties.Messages;
-import org.eclipse.persistence.json.bind.model.ClassModel;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.bind.JsonbException;
-import javax.json.bind.adapter.JsonbAdapter;
-import javax.json.bind.serializer.DeserializationContext;
-import javax.json.bind.serializer.JsonbDeserializer;
-import javax.json.stream.JsonParser;
-import java.lang.reflect.Type;
-
-/**
- * Decorator for an item which builds adapted type instance by a {@link JsonbAdapter}.
- * After adapted item is finished building its instance is converted to field type object by calling adapter.
- *
- * @param <A> adapted type, type to unmarshall JSOn into
- * @param <T> required type, typically type of the field, which is adapted to another type
- */
-public class AdaptedObjectDeserializer<A, T> implements CurrentItem<T>, JsonbDeserializer<T> {
-
- private JsonbDeserializer<A> adaptedItem;
-
- private final AdapterBinding adapterInfo;
-
- private final AbstractContainerDeserializer<?> wrapperItem;
-
- /**
- * Creates decoration instance wrapping real adapted object item.
- * @param adapterInfo adapter type info
- * @param wrapperItem wrapper item to get instance from
- */
- public AdaptedObjectDeserializer(AdapterBinding adapterInfo, AbstractContainerDeserializer<?> wrapperItem) {
- this.adapterInfo = adapterInfo;
- this.wrapperItem = wrapperItem;
- }
-
- @Override
- public ClassModel getClassModel() {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public CurrentItem<?> getWrapper() {
- return wrapperItem;
- }
-
- @Override
- public JsonBindingModel getWrapperModel() {
- return ((AbstractContainerDeserializer) adaptedItem).getWrapperModel();
- }
-
- @Override
- public Type getRuntimeType() {
- if (adaptedItem instanceof AbstractContainerDeserializer) {
- return ((AbstractContainerDeserializer) adaptedItem).getRuntimeType();
- }
- throw new JsonbException(Messages.getMessage(MessageKeys.INTERNAL_ERROR, "Deserialization propagation is not allowed for:" + adaptedItem));
- }
-
- public void setAdaptedItem(JsonbDeserializer<A> adaptedItem) {
- this.adaptedItem = adaptedItem;
- }
-
- @Override
- public T deserialize(JsonParser parser, DeserializationContext context, Type rtType) {
- Unmarshaller unmarshaller = (Unmarshaller) context;
- unmarshaller.setCurrent(this);
- try {
- final A result = adaptedItem.deserialize(parser, context, rtType);
- final T adapted = ((JsonbAdapter<T, A>) adapterInfo.getAdapter()).adaptFromJson(result);
- unmarshaller.setCurrent(wrapperItem);
- return adapted;
- } catch (Exception e) {
- throw new JsonbException(Messages.getMessage(MessageKeys.ADAPTER_EXCEPTION, adapterInfo.getBindingType(), adapterInfo.getToType(), adapterInfo.getAdapter().getClass()), e);
- }
- }
-
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/ByteArrayBase64Deserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/ByteArrayBase64Deserializer.java
deleted file mode 100644
index 8cbd008..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/ByteArrayBase64Deserializer.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.unmarshaller;
-
-import org.eclipse.persistence.json.bind.internal.ProcessingContext;
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-import org.eclipse.persistence.json.bind.internal.properties.MessageKeys;
-import org.eclipse.persistence.json.bind.internal.properties.Messages;
-import org.eclipse.persistence.json.bind.internal.serializer.AbstractValueTypeDeserializer;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.bind.JsonbException;
-import javax.json.bind.config.BinaryDataStrategy;
-import java.lang.reflect.Type;
-import java.util.Base64;
-
-/**
- * Deserialize Base64 json string value into byte array.
- *
- * @author Roman Grigoriadi
- */
-public class ByteArrayBase64Deserializer extends AbstractValueTypeDeserializer<byte[]> {
-
- public ByteArrayBase64Deserializer(JsonBindingModel model) {
- super(byte[].class, model);
- }
-
- @Override
- protected byte[] deserialize(String jsonValue, Unmarshaller unmarshaller, Type rtType) {
- return getDecoder(unmarshaller.getJsonbContext().getBinaryDataStrategy()).decode(jsonValue);
- }
-
- private Base64.Decoder getDecoder(String strategy) {
- switch (strategy) {
- case BinaryDataStrategy.BASE_64:
- return Base64.getDecoder();
- case BinaryDataStrategy.BASE_64_URL:
- return Base64.getUrlDecoder();
- default:
- throw new JsonbException(Messages.getMessage(MessageKeys.INTERNAL_ERROR, "Invalid strategy: " + strategy));
- }
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/ByteArrayDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/ByteArrayDeserializer.java
deleted file mode 100644
index b43e768..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/ByteArrayDeserializer.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.unmarshaller;
-
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Array unmarshaller item implementation for small int.
- *
- * @author Roman Grigoriadi
- */
-public class ByteArrayDeserializer extends AbstractArrayDeserializer<byte[]> {
-
- private final List<Byte> items = new ArrayList<>();
-
- protected ByteArrayDeserializer(DeserializerBuilder builder) {
- super(builder);
- }
-
- @Override
- protected List<?> getItems() {
- return items;
- }
-
- @Override
- public byte[] getInstance(Unmarshaller unmarshaller) {
- final int size = items.size();
- final byte[] byteArray = new byte[size];
- for(int i=0; i<size; i++) {
- byteArray[i] = items.get(i);
- }
- return byteArray;
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/CollectionDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/CollectionDeserializer.java
deleted file mode 100644
index 9c9e24a..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/CollectionDeserializer.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-package org.eclipse.persistence.json.bind.internal.unmarshaller;
-
-import org.eclipse.persistence.json.bind.internal.JsonbParser;
-import org.eclipse.persistence.json.bind.internal.JsonbRiParser;
-import org.eclipse.persistence.json.bind.internal.ReflectionUtils;
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.bind.serializer.JsonbDeserializer;
-import javax.json.stream.JsonParser;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.util.ArrayDeque;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Queue;
-import java.util.Set;
-
-/**
- * Item implementation for {@link java.util.List} fields
- *
- * @author Roman Grigoriadi
- */
-class CollectionDeserializer<T extends Collection<?>> extends AbstractContainerDeserializer<T> implements EmbeddedItem {
-
-
- private final ContainerModel containerModel;
-
- /**
- * Generic bound parameter of List.
- */
- private final Type collectionValueType;
-
- private T instance;
-
- /**
- * @param builder
- */
- protected CollectionDeserializer(DeserializerBuilder builder) {
- super(builder);
- collectionValueType = getRuntimeType() instanceof ParameterizedType ?
- ReflectionUtils.resolveType(this, ((ParameterizedType) getRuntimeType()).getActualTypeArguments()[0])
- : Object.class;
-
- instance = createInstance();
- this.containerModel = new ContainerModel(collectionValueType, resolveContainerModelCustomization(collectionValueType, builder.getJsonbContext()));
- }
-
- @Override
- protected JsonBindingModel getModel() {
- return containerModel;
- }
-
- @SuppressWarnings("unchecked")
- private T createInstance() {
- Class<T> rawType = (Class<T>) ReflectionUtils.getRawType(getRuntimeType());
- assert Collection.class.isAssignableFrom(rawType);
-
- if (rawType.isInterface()) {
- if (List.class.isAssignableFrom(rawType)) {
- return (T) new ArrayList<>();
- }
- if (Set.class.isAssignableFrom(rawType)) {
- return (T) new HashSet<>();
- }
- if (Queue.class.isAssignableFrom(rawType)) {
- return (T) new ArrayDeque<>();
- }
- }
- return ReflectionUtils.createNoArgConstructorInstance(rawType);
- }
-
- /**
- * Instance of an item. Unmarshalling sets values to such instance.
- *
- * @return instance
- * @param unmarshaller
- */
- @Override
- public T getInstance(Unmarshaller unmarshaller) {
- return instance;
- }
-
- @Override
- public void appendResult(Object result) {
- appendCaptor(result);
- }
-
- @SuppressWarnings("unchecked")
- private <T> void appendCaptor(T object) {
- ((Collection<T>) instance).add(object);
- }
-
-
- /**
- * Determine class mappings and create an instance of a new deserializer.
- * Currently processed deserializer is pushed to stack, for waiting till new object is finished.
- *
- * @param parser
- * @param context
- */
- @Override
- protected void deserializeNext(JsonParser parser, Unmarshaller context) {
- final JsonbDeserializer<?> deserializer = newCollectionOrMapItem(collectionValueType, context.getJsonbContext());
- appendResult(deserializer.deserialize(parser, context, collectionValueType));
- }
-
- @Override
- protected JsonbRiParser.LevelContext moveToFirst(JsonbParser parser) {
- parser.moveTo(JsonParser.Event.START_ARRAY);
- return parser.getCurrentLevel();
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/ContainerModel.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/ContainerModel.java
deleted file mode 100644
index 1637277..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/ContainerModel.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.unmarshaller;
-
-import org.eclipse.persistence.json.bind.model.Customization;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-import org.eclipse.persistence.json.bind.model.JsonContext;
-
-import java.lang.reflect.Type;
-
-/**
- * Binding model for collection like types.
- * Model provides a value type of a collection and its customization. If for example this model
- * is instantiated for {@code List<MyPojo>}, it will contain {@code MyPojo} value type and customization parsed
- * from annotations of {@code MyPojo} class.
- *
- * @author Roman Grigoriadi
- */
-public class ContainerModel implements JsonBindingModel {
-
- private final JsonContext context;
-
- private final String writeName;
-
- private final Type valueRuntimeType;
-
- private final Customization customization;
-
- /**
- * Construct model.
- *
- * @param valueRuntimeType collection or map value type
- * @param customization customization parsed from value type
- * @param context Object context used for serialization
- * @param writeName write name used for serialization
- */
- public ContainerModel(Type valueRuntimeType, Customization customization, JsonContext context, String writeName) {
- this.valueRuntimeType = valueRuntimeType;
- this.customization = customization;
- this.context = context;
- this.writeName = writeName;
- }
- /**
- * Construct model.
- *
- * @param valueRuntimeType collection or map value type
- * @param customization customization parsed from value type
- * @param context Object context used for serialization
- */
- public ContainerModel(Type valueRuntimeType, Customization customization, JsonContext context) {
- this.valueRuntimeType = valueRuntimeType;
- this.customization = customization;
- this.context = context;
- this.writeName = null;
- }
-
- /**
- * Minimal constructor.
- *
- * @param valueRuntimeType collection or map value type
- * @param customization customization parsed from value type
- */
- public ContainerModel(Type valueRuntimeType, Customization customization) {
- this.valueRuntimeType = valueRuntimeType;
- this.customization = customization;
- this.context = null;
- this.writeName = null;
- }
-
- /**
- * Introspected customization of a property or class.
- *
- * @return immutable property customization
- */
- @Override
- public Customization getCustomization() {
- return customization;
- }
-
- /**
- * Class of a property, either bean property type or collection / array component type.
- *
- * @return class type
- */
- @Override
- public Type getType() {
- return valueRuntimeType;
- }
-
- /**
- * Name of json key that will be written by marshaller.
- *
- * @return
- */
- @Override
- public String getWriteName() {
- return writeName;
- }
-
- /**
- * Current context of json generator.
- *
- * @return context
- */
- @Override
- public JsonContext getContext() {
- return context;
- }
-
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/CurrentItem.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/CurrentItem.java
deleted file mode 100644
index bd56b3b..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/CurrentItem.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.unmarshaller;
-
-import org.eclipse.persistence.json.bind.internal.RuntimeTypeInfo;
-import org.eclipse.persistence.json.bind.model.ClassModel;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-/**
- * @author Roman Grigoriadi
- */
-public interface CurrentItem<T> extends RuntimeTypeInfo {
-
- /**
- * Class model containing property for this item.
- * @return class model
- */
- ClassModel getClassModel();
-
- /**
- * Item wrapper. Null only in case of a root item.
- * @return wrapper item of this item
- */
- CurrentItem<?> getWrapper();
-
- /**
- * Binding model of this item in wrapper. May be JavaBean property or a container like collection.
- * @return wrapper model.
- */
- JsonBindingModel getWrapperModel();
-
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/DeserializerBuilder.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/DeserializerBuilder.java
deleted file mode 100644
index e0272ea..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/DeserializerBuilder.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-package org.eclipse.persistence.json.bind.internal.unmarshaller;
-
-import org.eclipse.persistence.json.bind.internal.AbstractSerializerBuilder;
-import org.eclipse.persistence.json.bind.internal.ComponentMatcher;
-import org.eclipse.persistence.json.bind.internal.JsonbContext;
-import org.eclipse.persistence.json.bind.internal.ProcessingContext;
-import org.eclipse.persistence.json.bind.internal.ReflectionUtils;
-import org.eclipse.persistence.json.bind.internal.adapter.AdapterBinding;
-import org.eclipse.persistence.json.bind.internal.adapter.DeserializerBinding;
-import org.eclipse.persistence.json.bind.internal.properties.MessageKeys;
-import org.eclipse.persistence.json.bind.internal.properties.Messages;
-import org.eclipse.persistence.json.bind.internal.serializer.AbstractValueTypeDeserializer;
-import org.eclipse.persistence.json.bind.internal.serializer.DefaultSerializers;
-import org.eclipse.persistence.json.bind.internal.serializer.SerializerProviderWrapper;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-import org.eclipse.persistence.json.bind.model.PolymorphismAdapter;
-import org.eclipse.persistence.json.bind.model.TypeWrapper;
-
-import javax.json.JsonStructure;
-import javax.json.bind.JsonbException;
-import javax.json.bind.config.BinaryDataStrategy;
-import javax.json.bind.serializer.JsonbDeserializer;
-import java.lang.reflect.GenericArrayType;
-import java.lang.reflect.Type;
-import java.util.Collection;
-import java.util.Map;
-import java.util.Optional;
-
-/**
- * Builder for currently processed items by unmarshaller.
- *
- * @author Roman Grigoriadi
- */
-public class DeserializerBuilder extends AbstractSerializerBuilder<DeserializerBuilder> {
-
- /**
- * Value type of json event.
- */
- private JsonValueType jsonValueType;
-
- public DeserializerBuilder(JsonbContext jsonbContext) {
- super(jsonbContext);
- }
-
- public DeserializerBuilder withJsonValueType(JsonValueType valueType) {
- this.jsonValueType = valueType;
- return this;
- }
-
- /**
- * Build an fully initialized item.
- *
- * @return built item
- */
- @SuppressWarnings("unchecked")
- public JsonbDeserializer<?> build() {
- runtimeType = resolveRuntimeType();
- Class<?> rawType = ReflectionUtils.getRawType(getRuntimeType());
-
- //First check if user deserializer is registered for such type
- final ComponentMatcher componentMatcher = jsonbContext.getComponentMatcher();
- Optional<DeserializerBinding<?>> userDeserializer =
- componentMatcher.getDeserialzierBinding(getRuntimeType(), getModel());
- if (userDeserializer.isPresent() &&
- !(wrapper instanceof UserDeserializerDeserializer && ReflectionUtils.getRawType(wrapper.getRuntimeType()).isAssignableFrom(rawType))) {
- return new UserDeserializerDeserializer<>(this, userDeserializer.get().getJsonbDeserializer());
- }
-
- //Second user adapter is registered.
- final Optional<AdapterBinding> adapterInfoOptional = componentMatcher.getAdapterBinding(getRuntimeType(), getModel());
- Optional<Class> rawTypeOptional = adapterInfoOptional.map(adapterInfo->{
- runtimeType = adapterInfo.getToType();
- wrapper = new AdaptedObjectDeserializer<>(adapterInfoOptional.get(), (AbstractContainerDeserializer<?>) wrapper);
- return ReflectionUtils.getRawType(getRuntimeType());
- });
- rawType = rawTypeOptional.orElse(rawType);
-
- //In case of Base64 json value would be string and recognition by JsonValueType would not work
- if (isByteArray(rawType)) {
- String strategy = jsonbContext.getBinaryDataStrategy();
- switch (strategy) {
- case BinaryDataStrategy.BYTE:
- return new ByteArrayDeserializer(this);
- default:
- return new ByteArrayBase64Deserializer(getModel());
- }
- }
-
- //Third deserializer is a supported value type that serializes to JSON_VALUE
- if (isJsonValueType()) {
- final Optional<AbstractValueTypeDeserializer<?>> supportedTypeDeserializer = getSupportedTypeDeserializer(rawType);
- if (!supportedTypeDeserializer.isPresent()) {
- throw new JsonbException(Messages.getMessage(MessageKeys.DESERIALIZE_VALUE_ERROR, getRuntimeType()));
- }
- return wrapAdapted(adapterInfoOptional, supportedTypeDeserializer.get());
- }
-
- JsonbDeserializer<?> deserializer;
- if (jsonValueType == JsonValueType.ARRAY) {
- if (JsonStructure.class.isAssignableFrom(rawType)) {
- return wrapAdapted(adapterInfoOptional, new JsonArrayDeserializer(this));
- } else if (rawType.isArray() || getRuntimeType() instanceof GenericArrayType) {
- deserializer = createArrayItem(rawType.getComponentType());
- return wrapAdapted(adapterInfoOptional, deserializer);
- } else if (Collection.class.isAssignableFrom(rawType)) {
- deserializer = new CollectionDeserializer<>(this);
- return wrapAdapted(adapterInfoOptional, deserializer);
- } else {
- throw new JsonbException("Can't deserialize JSON array into: " + getRuntimeType());
- }
- } else if(jsonValueType == JsonValueType.OBJECT) {
- if (JsonStructure.class.isAssignableFrom(rawType)) {
- return wrapAdapted(adapterInfoOptional, new JsonObjectDeserializer(this));
- } else if (Map.class.isAssignableFrom(rawType)) {
- final JsonbDeserializer<?> mapDeserializer = new MapDeserializer(this);
- return wrapAdapted(adapterInfoOptional, mapDeserializer);
- } else if (rawType.isInterface()) {
- throw new JsonbException(Messages.getMessage(MessageKeys.INFER_TYPE_FOR_UNMARSHALL, rawType.getName()));
- } else {
- if (adapterInfoOptional.isPresent()) {
- runtimeType = adapterInfoOptional.get().getToType();
- rawType = ReflectionUtils.getRawType(getRuntimeType());
- }
-
- classModel = getClassModel(rawType);
-
- if (TypeWrapper.class.isAssignableFrom(rawType)) {
- return wrapAdapted(adapterInfoOptional, new TypeWrapperDeserializer<>(this,
- ((PolymorphismAdapter<?>) adapterInfoOptional.get().getAdapter()).getAllowedClasses()));
- }
- deserializer = new ObjectDeserializer<>(this);
- return wrapAdapted(adapterInfoOptional, deserializer);
- }
- }
- throw new JsonbException("unresolved type for deserialization: " + getRuntimeType());
- }
-
- private boolean isJsonValueType() {
- switch (jsonValueType) {
- case NULL:
- case BOOLEAN:
- case NUMBER:
- case STRING:
- return true;
- case OBJECT:
- case ARRAY:
- return false;
- default:
- throw new JsonbException("Unknown value type: " + jsonValueType);
- }
- }
-
-
- private Optional<AbstractValueTypeDeserializer<?>> getSupportedTypeDeserializer(Class<?> rawType) {
- final Optional<? extends SerializerProviderWrapper> supportedTypeDeserializerOptional = DefaultSerializers.getInstance().findValueSerializerProvider(rawType);
- if (supportedTypeDeserializerOptional.isPresent()) {
- return Optional.of(supportedTypeDeserializerOptional.get().getDeserializerProvider().provideDeserializer(getModel()));
- }
- return Optional.empty();
- }
-
- private JsonbDeserializer<?> wrapAdapted(Optional<AdapterBinding> adapterInfoOptional, JsonbDeserializer<?> item) {
- final Optional<JsonbDeserializer<?>> adaptedDeserializerOptional = adapterInfoOptional.map(adapterInfo -> {
- setAdaptedItemCaptor((AdaptedObjectDeserializer)wrapper, item);
- return (JsonbDeserializer<?>)wrapper;
- });
- return adaptedDeserializerOptional.orElse(item);
- }
-
- private <T,A> void setAdaptedItemCaptor(AdaptedObjectDeserializer<T,A> decoratorItem, JsonbDeserializer<T> adaptedItem) {
- decoratorItem.setAdaptedItem(adaptedItem);
- }
-
- private Type resolveRuntimeType() {
- Type toResolve = genericType != null ? genericType : getModel().getType();
- //Map Unknown objects to java.util.Map
- if (toResolve == Object.class) {
- return jsonValueType.getConversionType();
- }
- return ReflectionUtils.resolveType(wrapper, toResolve);
- }
-
- /**
- * Instance is not created in case of array items, because, we don't know how long it should be
- * till parser ends parsing.
- */
- private JsonbDeserializer<?> createArrayItem(Class<?> componentType) {
- if (componentType == byte.class) {
- return new ByteArrayDeserializer(this);
- } else if (componentType == short.class) {
- return new ShortArrayDeserializer(this);
- } else if (componentType == int.class) {
- return new IntArrayDeserializer(this);
- } else if (componentType == long.class) {
- return new LongArrayDeserializer(this);
- } else if (componentType == float.class) {
- return new FloatArrayDeserializer(this);
- } else if (componentType == double.class) {
- return new DoubleArrayDeserializer(this);
- } else {
- return new ObjectArrayDeserializer(this);
- }
- }
-
- private boolean isByteArray(Class<?> rawType) {
- return rawType.isArray() && rawType.getComponentType() == Byte.TYPE;
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/DoubleArrayDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/DoubleArrayDeserializer.java
deleted file mode 100644
index a370525..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/DoubleArrayDeserializer.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.unmarshaller;
-
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Array unmarshaller item implementation for small double.
- *
- * @author Roman Grigoriadi
- */
-public class DoubleArrayDeserializer extends AbstractArrayDeserializer<double[]> {
-
- private final List<Double> items = new ArrayList<>();
-
- protected DoubleArrayDeserializer(DeserializerBuilder builder) {
- super(builder);
- }
-
- @Override
- protected List<?> getItems() {
- return items;
- }
-
- @Override
- public double[] getInstance(Unmarshaller unmarshaller) {
- final int size = items.size();
- final double[] doubleArray = new double[size];
- for(int i=0; i<size; i++) {
- doubleArray[i] = items.get(i);
- }
- return doubleArray;
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/EmbeddedItem.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/EmbeddedItem.java
deleted file mode 100644
index d75228b..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/EmbeddedItem.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-package org.eclipse.persistence.json.bind.internal.unmarshaller;
-
-/**
- * Tagging interface for embedded object items, such as List, Maps or Arrays.
- *
- * @author Roman Grigoriadi
- */
-public interface EmbeddedItem {
-
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/FloatArrayDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/FloatArrayDeserializer.java
deleted file mode 100644
index d25e5df..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/FloatArrayDeserializer.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.unmarshaller;
-
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Array unmarshaller item implementation for small float.
- *
- * @author Roman Grigoriadi
- */
-public class FloatArrayDeserializer extends AbstractArrayDeserializer<float[]> {
-
- private final List<Float> items = new ArrayList<>();
-
- protected FloatArrayDeserializer(DeserializerBuilder builder) {
- super(builder);
- }
-
- @Override
- protected List<?> getItems() {
- return items;
- }
-
- @Override
- public float[] getInstance(Unmarshaller unmarshaller) {
- final int size = items.size();
- final float[] floatArray = new float[size];
- for(int i=0; i<size; i++) {
- floatArray[i] = items.get(i);
- }
- return floatArray;
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/IntArrayDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/IntArrayDeserializer.java
deleted file mode 100644
index 1eda88f..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/IntArrayDeserializer.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.unmarshaller;
-
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Array unmarshaller item implementation for small int.
- *
- * @author Roman Grigoriadi
- */
-public class IntArrayDeserializer extends AbstractArrayDeserializer<int[]> {
-
- private final List<Integer> items = new ArrayList<>();
-
- protected IntArrayDeserializer(DeserializerBuilder builder) {
- super(builder);
- }
-
- @Override
- protected List<?> getItems() {
- return items;
- }
-
- @Override
- public int[] getInstance(Unmarshaller unmarshaller) {
- final int size = items.size();
- final int[] intArray = new int[size];
- for(int i=0; i<size; i++) {
- intArray[i] = items.get(i);
- }
- return intArray;
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/JsonArrayDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/JsonArrayDeserializer.java
deleted file mode 100644
index e1614c8..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/JsonArrayDeserializer.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.unmarshaller;
-
-import org.eclipse.persistence.json.bind.internal.ProcessingContext;
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-
-import javax.json.JsonArray;
-import javax.json.JsonArrayBuilder;
-import javax.json.JsonValue;
-import java.math.BigDecimal;
-
-/**
- * Item for JsonArray.
- *
- * @author Roman Grigoriadi
- */
-public class JsonArrayDeserializer extends AbstractJsonpDeserializer<JsonArray> {
-
- private final JsonArrayBuilder arrayBuilder;
-
- @Override
- protected void appendString(String key, String value) {
- arrayBuilder.add(value);
- }
-
- @Override
- protected void appendNumber(String key, BigDecimal value) {
- arrayBuilder.add(value);
- }
-
- @Override
- protected void appendBoolean(String key, Boolean value) {
- arrayBuilder.add(value);
- }
-
- @Override
- protected void appendNull(String key) {
- arrayBuilder.addNull();
- }
-
- /**
- * Create instance.
- */
- protected JsonArrayDeserializer(DeserializerBuilder builder) {
- super(builder);
- arrayBuilder = builder.getJsonbContext().getJsonProvider().createArrayBuilder();
- }
-
- @Override
- public void appendResult(Object result) {
- JsonValue jsonValue = (JsonValue) result;
- arrayBuilder.add(jsonValue);
- }
-
- @Override
- public JsonArray getInstance(Unmarshaller unmarshaller) {
- return arrayBuilder.build();
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/JsonObjectDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/JsonObjectDeserializer.java
deleted file mode 100644
index d7fea9f..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/JsonObjectDeserializer.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.unmarshaller;
-
-import org.eclipse.persistence.json.bind.internal.ProcessingContext;
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-
-import javax.json.JsonObject;
-import javax.json.JsonObjectBuilder;
-import javax.json.JsonValue;
-import java.math.BigDecimal;
-
-/**
- * Item for JsonObject.
- *
- * @author Roman Grigoriadi
- */
-public class JsonObjectDeserializer extends AbstractJsonpDeserializer<JsonObject> {
-
- private JsonObjectBuilder objectBuilder;
-
- /**
- * Create instance of current item with its builder.
- *
- * @param builder
- */
- protected JsonObjectDeserializer(DeserializerBuilder builder) {
- super(builder);
- objectBuilder = builder.getJsonbContext().getJsonProvider().createObjectBuilder();
- }
-
- @Override
- protected void appendString(String key, String value) {
- objectBuilder.add(key, value);
- }
-
- @Override
- protected void appendNumber(String key, BigDecimal value) {
- objectBuilder.add(key, value);
- }
-
- @Override
- protected void appendBoolean(String key, Boolean value) {
- objectBuilder.add(key, value);
- }
-
- @Override
- protected void appendNull(String key) {
- objectBuilder.addNull(key);
- }
-
- @Override
- public void appendResult(Object result) {
- objectBuilder.add(parserContext.getLastKeyName(), (JsonValue) result);
- }
-
- @Override
- public JsonObject getInstance(Unmarshaller unmarshaller) {
- return objectBuilder.build();
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/JsonValueType.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/JsonValueType.java
deleted file mode 100644
index 6f8b14f..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/JsonValueType.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-package org.eclipse.persistence.json.bind.internal.unmarshaller;
-
-import org.eclipse.persistence.json.bind.internal.properties.MessageKeys;
-import org.eclipse.persistence.json.bind.internal.properties.Messages;
-
-import javax.json.bind.JsonbException;
-import javax.json.stream.JsonParser;
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.HashMap;
-
-/**
- * Default types for JSON values when type cannot be inferred by reflection.
- * Fields defined as Object.class types, or raw generic fields are such cases.
- *
- * @author Roman Grigoriadi
- */
-public enum JsonValueType {
- BOOLEAN(Boolean.class),
- NUMBER(BigDecimal.class),
- STRING(String.class),
- ARRAY(ArrayList.class),
- OBJECT(HashMap.class),
- NULL(null);
-
- JsonValueType(Class<?> supportedByType) {
- this.supportedByType = supportedByType;
- }
-
- private final Class<?> supportedByType;
-
- public Class<?> getConversionType() {
- return supportedByType;
- }
-
- public static JsonValueType of(JsonParser.Event event) {
- switch (event) {
- case VALUE_FALSE:
- case VALUE_TRUE:
- return BOOLEAN;
- case VALUE_STRING:
- return STRING;
- case VALUE_NUMBER:
- return NUMBER;
- case VALUE_NULL:
- return NULL;
- case START_ARRAY:
- return ARRAY;
- case START_OBJECT:
- return OBJECT;
- default:
- throw new JsonbException(Messages.getMessage(MessageKeys.NOT_VALUE_TYPE, event.name()));
- }
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/LongArrayDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/LongArrayDeserializer.java
deleted file mode 100644
index e086de2..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/LongArrayDeserializer.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.unmarshaller;
-
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Array unmarshaller item implementation for small long.
- *
- * @author Roman Grigoriadi
- */
-public class LongArrayDeserializer extends AbstractArrayDeserializer<long[]> {
-
- private final List<Long> items = new ArrayList<>();
-
- protected LongArrayDeserializer(DeserializerBuilder builder) {
- super(builder);
- }
-
- @Override
- protected List<?> getItems() {
- return items;
- }
-
- @Override
- public long[] getInstance(Unmarshaller unmarshaller) {
- final int size = items.size();
- final long[] longArray = new long[size];
- for(int i=0; i<size; i++) {
- longArray[i] = items.get(i);
- }
- return longArray;
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/MapDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/MapDeserializer.java
deleted file mode 100644
index 9e643e9..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/MapDeserializer.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-package org.eclipse.persistence.json.bind.internal.unmarshaller;
-
-import org.eclipse.persistence.json.bind.internal.JsonbParser;
-import org.eclipse.persistence.json.bind.internal.JsonbRiParser;
-import org.eclipse.persistence.json.bind.internal.ReflectionUtils;
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-
-import javax.json.bind.serializer.JsonbDeserializer;
-import javax.json.stream.JsonParser;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Item implementation for {@link java.util.Map} fields.
- * According to JSON specification object can have only string keys, given that maps could only be parsed
- * from JSON objects, implementation is bound to String type.
- *
- * @author Roman Grigoriadi
- */
-public class MapDeserializer<T extends Map<?,?>> extends AbstractContainerDeserializer<T> implements EmbeddedItem {
-
- /**
- * Type of value in the map.
- * (Keys must always be Strings, because of JSON spec)
- */
- private final Type mapValueRuntimeType;
-
- private final T instance;
-
- private final JsonBindingModel model;
-
- /**
- * @param builder
- */
- protected MapDeserializer(DeserializerBuilder builder) {
- super(builder);
- mapValueRuntimeType = getRuntimeType() instanceof ParameterizedType ?
- ReflectionUtils.resolveType(this, ((ParameterizedType) getRuntimeType()).getActualTypeArguments()[1])
- : Object.class;
-
- this.instance = createInstance();
- this.model = new ContainerModel(mapValueRuntimeType, resolveContainerModelCustomization(mapValueRuntimeType, builder.getJsonbContext()));
- }
-
- @SuppressWarnings("unchecked")
- private T createInstance() {
- Class<T> rawType = (Class<T>) ReflectionUtils.getRawType(getRuntimeType());
- return rawType.isInterface() ? (T) new HashMap<>() : ReflectionUtils.createNoArgConstructorInstance(rawType);
- }
-
- @Override
- protected JsonBindingModel getModel() {
- return model;
- }
-
- @Override
- public T getInstance(Unmarshaller unmarshaller) {
- return instance;
- }
-
- @Override
- public void appendResult(Object result) {
- appendCaptor(parserContext.getLastKeyName(), result);
- }
-
- @SuppressWarnings("unchecked")
- private <V> void appendCaptor(String key, V value) {
- ((Map<String, V>) getInstance(null)).put(key, value);
- }
-
- @Override
- protected void deserializeNext(JsonParser parser, Unmarshaller context) {
- final JsonbDeserializer<?> deserializer = newCollectionOrMapItem(mapValueRuntimeType, context.getJsonbContext());
- appendResult(deserializer.deserialize(parser, context, mapValueRuntimeType));
- }
-
- @Override
- protected JsonbRiParser.LevelContext moveToFirst(JsonbParser parser) {
- parser.moveTo(JsonParser.Event.START_OBJECT);
- return parser.getCurrentLevel();
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/ObjectArrayDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/ObjectArrayDeserializer.java
deleted file mode 100644
index 28a8c88..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/ObjectArrayDeserializer.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-package org.eclipse.persistence.json.bind.internal.unmarshaller;
-
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-
-import java.lang.reflect.Array;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Item for handling arrays of objects.
- *
- * @author Roman Grigoriadi
- */
-public class ObjectArrayDeserializer<T> extends AbstractArrayDeserializer<T[]> {
-
- private final List<T> items = new ArrayList<>();
-
- private T[] arrayInstance;
-
- protected ObjectArrayDeserializer(DeserializerBuilder builder) {
- super(builder);
- }
-
- @Override
- protected List<?> getItems() {
- return items;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public T[] getInstance(Unmarshaller unmarshaller) {
- if (arrayInstance == null || arrayInstance.length != items.size()) {
- arrayInstance = (T[]) Array.newInstance(componentClass, items.size());
- }
- return items.toArray(arrayInstance);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/ObjectDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/ObjectDeserializer.java
deleted file mode 100644
index 7d256ed..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/ObjectDeserializer.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-package org.eclipse.persistence.json.bind.internal.unmarshaller;
-
-import org.eclipse.persistence.json.bind.internal.JsonbParser;
-import org.eclipse.persistence.json.bind.internal.JsonbRiParser;
-import org.eclipse.persistence.json.bind.internal.ProcessingContext;
-import org.eclipse.persistence.json.bind.internal.ReflectionUtils;
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-import org.eclipse.persistence.json.bind.model.ClassModel;
-import org.eclipse.persistence.json.bind.model.JsonbCreator;
-import org.eclipse.persistence.json.bind.model.PropertyModel;
-
-import javax.json.bind.serializer.JsonbDeserializer;
-import javax.json.stream.JsonParser;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.logging.Logger;
-
-/**
- * Item for handling all types of unknown objects by reflection, parsing their fields, according to json key name.
- *
- * @author Roman Grigoriadi
- */
-class ObjectDeserializer<T> extends AbstractContainerDeserializer<T> {
-
- /**
- * Last property model cache to avoid lookup by jsonKey on every access.
- */
- private static class LastPropertyModel {
-
- private final String jsonKeyName;
- private final PropertyModel propertyModel;
-
- public LastPropertyModel(String jsonKeyName, PropertyModel propertyModel) {
- this.jsonKeyName = jsonKeyName;
- this.propertyModel = propertyModel;
- }
-
- public String getJsonKeyName() {
- return jsonKeyName;
- }
-
- public PropertyModel getPropertyModel() {
- return propertyModel;
- }
- }
-
- private static final Logger log = Logger.getLogger(ObjectDeserializer.class.getName());
-
- private Map<String, Object> values = new HashMap<>();
-
- private T instance;
-
- private LastPropertyModel lastPropertyModel;
-
- /**
- * Creates instance of an item.
- * @param builder builder to build from
- */
- protected ObjectDeserializer(DeserializerBuilder builder) {
- super(builder);
- }
-
- /**
- * Due to support of custom (parametrized) constructors and factory methods, values are held in map,
- * which is transferred into instance values by calling getInstance.
- *
- * @return instance
- * @param unmarshaller
- */
- @Override
- @SuppressWarnings("unchecked")
- public T getInstance(Unmarshaller unmarshaller) {
- if (instance != null) {
- return instance;
- }
- final Class<?> rawType = ReflectionUtils.getRawType(getRuntimeType());
- final JsonbCreator creator = getClassModel().getClassCustomization().getCreator();
- instance = creator != null ? createInstance((Class<T>) rawType, creator)
- : ReflectionUtils.createNoArgConstructorInstance((Class<T>) rawType);
-
- for(Iterator<ClassModel> classModelIterator = unmarshaller.getMappingContext().classModelIterator(rawType); classModelIterator.hasNext();) {
- classModelIterator.next().getProperties().entrySet().stream()
- .filter((entry)->creator == null || !creator.contains(entry.getKey()))
- .forEach((entry)->{
- if (values.containsKey(entry.getKey())) {
- final Object value = values.get(entry.getKey());
- entry.getValue().setValue(instance, value);
- }
- });
- }
- return instance;
- }
-
- /**
- * Creates instance with custom jsonb creator (parameterized constructor or factory method)
- */
- private T createInstance(Class<T> rawType, JsonbCreator creator) {
- final T instance;
- final Object[] paramValues = new Object[creator.getParams().length];
- for(int i=0; i<creator.getParams().length; i++) {
- paramValues[i] = values.get(creator.getParams()[i]);
- }
- instance = creator.call(paramValues, rawType);
- return instance;
- }
-
- /**
- * Set populated instance of current object to its unfinished wrapper values map.
- * @param result
- */
- @Override
- public void appendResult(Object result) {
- values.put(getModel().getPropertyName(), result);
- }
-
- @Override
- protected void deserializeNext(JsonParser parser, Unmarshaller context) {
- //identify field model of currently processed class model
- PropertyModel newPropertyModel = getModel();
- if (newPropertyModel == null) {
- //ignore JSON property, which is missing in class model
- ((JsonbParser) parser).skipJsonStructure();
- return;
- }
-
- //create current item instance of identified object field
- final JsonbDeserializer<?> deserializer = newUnmarshallerItemBuilder(context.getJsonbContext()).
- withModel(newPropertyModel).build();
-
- Object result = deserializer.deserialize(parser, context, newPropertyModel.getPropertyType());
- appendResult(result);
- }
-
- @Override
- protected JsonbRiParser.LevelContext moveToFirst(JsonbParser parser) {
- parser.moveTo(JsonParser.Event.START_OBJECT);
- return parser.getCurrentLevel();
- }
-
- @Override
- protected PropertyModel getModel() {
- final String lastKeyName = parserContext.getLastKeyName();
- if (lastPropertyModel != null && lastPropertyModel.getJsonKeyName().equals(lastKeyName)) {
- return lastPropertyModel.getPropertyModel();
- }
- lastPropertyModel = new LastPropertyModel(lastKeyName, getClassModel().findPropertyModelByJsonReadName(lastKeyName));
- return lastPropertyModel.getPropertyModel();
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/ResolvedParameterizedType.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/ResolvedParameterizedType.java
deleted file mode 100644
index c125de2..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/ResolvedParameterizedType.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.unmarshaller;
-
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.util.Arrays;
-import java.util.Objects;
-
-/**
- * {@link ParameterizedType} implementation containing array of resolved TypeVariable type args.
- *
- * @author Roman Grigoriadi
- */
-public class ResolvedParameterizedType implements ParameterizedType {
-
- /**
- * Original parameterized type.
- */
- private final ParameterizedType original;
-
- /**
- * Resolved args by runtime type.
- */
- private final Type[] resolvedTypeArgs;
-
- public ResolvedParameterizedType(ParameterizedType original, Type[] resolvedTypeArgs) {
- this.original = original;
- this.resolvedTypeArgs = resolvedTypeArgs;
- }
-
- /**
- * Type arguments with resolved TypeVariables
- *
- * @return type args
- */
- @Override
- public Type[] getActualTypeArguments() {
- return resolvedTypeArgs;
- }
-
- @Override
- public Type getRawType() {
- return original.getRawType();
- }
-
- @Override
- public Type getOwnerType() {
- return original.getOwnerType();
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append(original.toString());
- if (resolvedTypeArgs != null && resolvedTypeArgs.length > 0) {
- sb.append(" resolved arguments: [");
- for (Type typeArg : resolvedTypeArgs) {
- sb.append(String.valueOf(typeArg));
- }
- sb.append("]");
- }
- return sb.toString();
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || !(o instanceof ParameterizedType)) return false;
- final ParameterizedType that = (ParameterizedType) o;
- return this.getRawType().equals(that.getRawType())
- && Objects.equals(this.getOwnerType(), that.getOwnerType())
- && Arrays.equals(resolvedTypeArgs, that.getActualTypeArguments());
- }
-
- @Override
- public int hashCode() {
- return Arrays.hashCode(resolvedTypeArgs) ^
- (getOwnerType() == null ? 0 : getOwnerType().hashCode() ) ^
- (getRawType() == null ? 0 : getRawType().hashCode() );
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/ShortArrayDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/ShortArrayDeserializer.java
deleted file mode 100644
index 3306a52..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/ShortArrayDeserializer.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.unmarshaller;
-
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Array unmarshaller item implementation for small short.
- *
- * @author Roman Grigoriadi
- */
-public class ShortArrayDeserializer extends AbstractArrayDeserializer<short[]> {
-
- private final List<Short> items = new ArrayList<>();
-
- protected ShortArrayDeserializer(DeserializerBuilder builder) {
- super(builder);
- }
-
- @Override
- protected List<?> getItems() {
- return items;
- }
-
- @Override
- public short[] getInstance(Unmarshaller unmarshaller) {
- final int size = items.size();
- final short[] shortArray = new short[size];
- for(int i=0; i<size; i++) {
- shortArray[i] = items.get(i);
- }
- return shortArray;
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/TypeWrapperDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/TypeWrapperDeserializer.java
deleted file mode 100644
index 9df1b1c..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/TypeWrapperDeserializer.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.unmarshaller;
-
-import org.eclipse.persistence.json.bind.internal.ReflectionUtils;
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-import org.eclipse.persistence.json.bind.internal.properties.MessageKeys;
-import org.eclipse.persistence.json.bind.internal.properties.Messages;
-import org.eclipse.persistence.json.bind.internal.serializer.StringTypeDeserializer;
-import org.eclipse.persistence.json.bind.model.PropertyModel;
-import org.eclipse.persistence.json.bind.model.TypeWrapper;
-
-import javax.json.bind.JsonbException;
-import javax.json.bind.serializer.JsonbDeserializer;
-import javax.json.stream.JsonParser;
-import java.util.function.Predicate;
-import java.util.stream.Stream;
-
-/**
- * Handler for a {@link TypeWrapper} type.
- * Reads a class property first during deserialization and instantiates correct polymorphic type after.
- *
- * TODO ensuring class property will be first which is not the case for now!
- *
- * @author Roman Grigoriadi
- */
-public class TypeWrapperDeserializer<T> extends ObjectDeserializer<TypeWrapper<T>> {
-
- /**
- * Parsed class from JSON to load by name.
- */
- private Class<?> concreteWrappedClass;
-
- /**
- * Enumeration of allowed classes to be more defensive.
- */
- private String[] allowedClassNames;
-
- /**
- * Creates instance of an item.
- *
- * @param builder builder to build from
- */
- protected TypeWrapperDeserializer(DeserializerBuilder builder, String[] allowedClassNames) {
- super(builder);
- this.allowedClassNames = allowedClassNames;
- }
-
- @Override
- protected void deserializeNext(JsonParser parser, Unmarshaller context) {
- final String lastKeyName = parserContext.getLastKeyName();
-
- if (parserContext.getLastKeyName().equals("className")) {
- PropertyModel newPropertyModel = getClassModel().findPropertyModelByJsonReadName(lastKeyName);
- final JsonbDeserializer<?> deserializer = new StringTypeDeserializer(newPropertyModel);
-
- String className = (String) deserializer.deserialize(parser, context, String.class);
- if (allowedClassNames.length > 0 && !Stream.of(allowedClassNames).anyMatch(Predicate.isEqual(className))) {
- throw new JsonbException(Messages.getMessage(MessageKeys.CLASS_LOAD_NOT_ALLOWED, className));
- }
-
- try {
- concreteWrappedClass = Thread.currentThread().getContextClassLoader().loadClass(className);
- return;
- } catch (ClassNotFoundException e) {
- throw new JsonbException("Cannot load class for ", e);
- }
- } else if (concreteWrappedClass != null && parserContext.getLastKeyName().equals("instance")) {
- deserializeInstance(parser, context);
- }
- }
-
- private void deserializeInstance(JsonParser parser, Unmarshaller context) {
- PropertyModel newPropertyModel = getClassModel().findPropertyModelByJsonReadName("instance");
- final JsonbDeserializer<?> deserializer = newUnmarshallerItemBuilder(context.getJsonbContext())
- .withType(concreteWrappedClass).withModel(newPropertyModel)
- .build();
-
- appendResult(deserializer.deserialize(parser, context, null));
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/UserDeserializerDeserializer.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/UserDeserializerDeserializer.java
deleted file mode 100644
index 7ec77d1..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/internal/unmarshaller/UserDeserializerDeserializer.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.unmarshaller;
-
-import org.eclipse.persistence.json.bind.internal.JsonbParser;
-import org.eclipse.persistence.json.bind.internal.JsonbRiParser;
-import org.eclipse.persistence.json.bind.internal.Unmarshaller;
-import org.eclipse.persistence.json.bind.model.JsonBindingModel;
-import org.eclipse.persistence.json.bind.serializer.UserDeserializerParser;
-
-import javax.json.bind.serializer.JsonbDeserializer;
-import javax.json.stream.JsonParser;
-
-/**
- * Item for processing types, to which deserializer is bound.
- *
- * @author Roman Grigoriadi
- */
-public class UserDeserializerDeserializer<T> extends AbstractContainerDeserializer<T> {
-
- private JsonbDeserializer<?> deserializer;
-
- private T deserializerResult;
-
- /**
- * Create instance of current item with its builder.
- * Contains user provided component for custom deserialization.
- * Decorates calls to JsonParser, with validation logic so user can't left parser cursor
- * in wrong position after returning from deserializer.
- *
- * @param builder
- */
- protected UserDeserializerDeserializer(DeserializerBuilder builder, JsonbDeserializer<?> deserializer) {
- super(builder);
- this.deserializer = deserializer;
- }
-
- @Override
- public void appendResult(Object result) {
- //ignore internal deserialize() call in custom deserializer
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public T getInstance(Unmarshaller unmarshaller) {
- return deserializerResult;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public void deserializeInternal(JsonbParser parser, Unmarshaller context) {
- parserContext = moveToFirst(parser);
- final UserDeserializerParser userDeserializerParser = new UserDeserializerParser(parser);
- deserializerResult = (T) deserializer.deserialize(userDeserializerParser, context, getRuntimeType());
- userDeserializerParser.advanceParserToEnd();
- }
-
- @Override
- protected void deserializeNext(JsonParser parser, Unmarshaller context) {
- throw new UnsupportedOperationException("Not supported for user deserializer");
- }
-
- @Override
- protected JsonbRiParser.LevelContext moveToFirst(JsonbParser parser) {
- parser.moveTo(JsonParser.Event.START_OBJECT);
- return parser.getCurrentLevel();
- }
-
- /**
- * Binding model for current deserializer.
- *
- * @return model
- */
- @Override
- protected JsonBindingModel getModel() {
- return getWrapperModel();
- }
-}
\ No newline at end of file
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/ClassCustomization.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/ClassCustomization.java
deleted file mode 100644
index 5cb2dee..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/ClassCustomization.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.model;
-
-/**
- * Customization, which could be applied on a class or package level.
- *
- * @author Roman Grigoriadi
- */
-public class ClassCustomization extends Customization {
-
- private final JsonbCreator creator;
-
- private String[] propertyOrder;
-
- /**
- * Copies properties from builder an creates immutable instance.
- *
- * @param builder not null
- */
- ClassCustomization(CustomizationBuilder builder) {
- super(builder);
- this.creator = builder.getCreator();
- this.propertyOrder = builder.getPropertyOrder();
- }
-
- /**
- * Copy constructor.
- *
- * @param other other customizaton instance
- */
- public ClassCustomization(ClassCustomization other) {
- super(other);
- this.creator = other.getCreator();
- this.propertyOrder = other.getPropertyOrder();
- }
-
- public JsonbCreator getCreator() {
- return creator;
- }
-
- /**
- * Names of properties to sort with.
- *
- * @return sorted names of properties
- */
- public String[] getPropertyOrder() {
- return propertyOrder;
- }
-
- public void setPropertyOrder(String[] propertyOrder) {
- this.propertyOrder = propertyOrder;
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/ClassModel.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/ClassModel.java
deleted file mode 100644
index bd9244c..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/ClassModel.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- * <p>
- * Contributors:
- * Dmitry Kornilov - initial implementation
- ******************************************************************************/
-package org.eclipse.persistence.json.bind.model;
-
-import org.eclipse.persistence.json.bind.internal.naming.CaseInsensitiveStrategy;
-
-import javax.json.bind.config.PropertyNamingStrategy;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.stream.Collectors;
-
-/**
- * A model for Java class.
- *
- * @author Dmitry Kornilov
- */
-public class ClassModel {
-
- private final Class<?> clazz;
-
- private final ClassCustomization classCustomization;
-
- private final ClassModel parentClassModel;
-
- /**
- * A map of all class properties, including properties from superclasses. Used to access by name.
- */
- private Map<String, PropertyModel> properties;
-
- /**
- * Sorted properties according to sorting strategy. Used for serialization property ordering.
- */
- private PropertyModel[] sortedProperties;
-
- private final PropertyNamingStrategy propertyNamingStrategy;
-
- /**
- * Gets a property model by default (non customized) name
- * @param name a name as parsed from field / getter / setter without annotation customizing
- * @return property model
- */
- public PropertyModel getPropertyModel(String name) {
- return properties.get(name);
- }
-
- /**
- * Create instance of class model.
- * @param clazz class to model onto
- * @param customization customization of the class parsed from annotations
- * @param parentClassModel class model of parent class
- * @param propertyNamingStrategy property naming strategy
- */
- public ClassModel(Class<?> clazz, ClassCustomization customization, ClassModel parentClassModel, PropertyNamingStrategy propertyNamingStrategy) {
- this.clazz = clazz;
- this.classCustomization = customization;
- this.parentClassModel = parentClassModel;
- this.propertyNamingStrategy = propertyNamingStrategy;
- }
-
- /**
- * Search for field in this class model and superclasses of its class.
- * @param jsonReadName name as it appears in JSON during reading.
- * @return PropertyModel if found.
- */
- public PropertyModel findPropertyModelByJsonReadName(String jsonReadName) {
- Objects.requireNonNull(jsonReadName);
- return searchProperty(this, jsonReadName);
- }
-
- private PropertyModel searchProperty(ClassModel classModel, String jsonReadName) {
- //Standard javabean properties without overridden name (most of the cases)
- final PropertyModel result = classModel.getPropertyModel(jsonReadName);
- if (result != null && result.getPropertyName().equals(result.getCustomization().getJsonReadName())) {
- return result;
- }
- //Search for overridden name on setter with @JsonbProperty annotation
- for (PropertyModel propertyModel : properties.values()) {
- if (equalsReadName(jsonReadName, propertyModel)) {
- return propertyModel;
- }
- }
- //property not found
- return null;
- }
-
- /**
- * Check if name is equal according to property strategy. In case of {@link CaseInsensitiveStrategy} ignore case.
- * User can provide own strategy implementation, cast to custom interface is not an option.
- */
- private boolean equalsReadName(String jsonName, PropertyModel propertyModel) {
- final String propertyReadName = propertyModel.getReadName();
- if (propertyNamingStrategy instanceof CaseInsensitiveStrategy) {
- return jsonName.equalsIgnoreCase(propertyReadName);
- }
- return jsonName.equalsIgnoreCase(propertyReadName);
- }
-
- public ClassCustomization getCustomization() {
- return classCustomization;
- }
-
- public Class<?> getType() {
- return clazz;
- }
-
- /**
- * Introspected customization for a class.
- * @return immutable class customization.
- */
- public ClassCustomization getClassCustomization() {
- return classCustomization;
- }
-
- /**
- * Class model of parent class if present.
- * @return class model of a parent
- */
- public ClassModel getParentClassModel() {
- return parentClassModel;
- }
-
- /**
- * Get sorted class properties copy, combination of field and its getter / setter, javabeans alike.
- * @return sorted class properties.
- */
- public PropertyModel[] getSortedProperties() {
- return sortedProperties;
- }
-
- public void setProperties(List<PropertyModel> parsedProperties) {
- sortedProperties = parsedProperties.toArray(new PropertyModel[]{});
- this.properties = parsedProperties.stream().collect(Collectors.toMap(PropertyModel::getPropertyName, (mod) -> mod));
- }
-
- /**
- * Get class properties copy, combination of field and its getter / setter, javabeans alike.
- * @return class properties.
- */
- public Map<String, PropertyModel> getProperties() {
- return Collections.unmodifiableMap(properties);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/ContainerCustomization.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/ContainerCustomization.java
deleted file mode 100644
index ec6571c..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/ContainerCustomization.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package org.eclipse.persistence.json.bind.model;
-
-/**
- * Customization for container like types (Maps, Collections, Arrays).
- *
- * @author Roman Grigoriadi
- */
-public class ContainerCustomization extends ClassCustomization {
-
-
- public ContainerCustomization(CustomizationBuilder builder) {
- super(builder);
- }
-
- public ContainerCustomization(ClassCustomization other) {
- super(other);
- }
-
- /**
- * Containers (types mapped to JsonArray) are always nillable by spec.
- * @return always true
- */
- @Override
- public final boolean isNillable() {
- return true;
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/Customization.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/Customization.java
deleted file mode 100644
index 1058553..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/Customization.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.model;
-
-import org.eclipse.persistence.json.bind.internal.adapter.AdapterBinding;
-import org.eclipse.persistence.json.bind.internal.adapter.DeserializerBinding;
-import org.eclipse.persistence.json.bind.internal.adapter.SerializerBinding;
-import org.eclipse.persistence.json.bind.internal.serializer.JsonbDateFormatter;
-import org.eclipse.persistence.json.bind.internal.serializer.JsonbNumberFormatter;
-
-/**
- * Customization configuration for class or field.
- * Configuration parsed from annotation is put here.
- *
- * @author Roman Grigoriadi
- */
-public abstract class Customization {
-
- private final AdapterBinding adapterBinding;
-
- private final SerializerBinding serializerBinding;
-
- private final DeserializerBinding deserializerBinding;
-
- private final boolean nillable;
-
- private final boolean jsonbTransient;
-
- private final JsonbDateFormatter dateTimeFormatter;
-
- private final JsonbNumberFormatter numberFormat;
-
-
- /**
- * Copies properties from builder an creates immutable instance.
- * @param builder not null
- */
- public Customization(CustomizationBuilder builder) {
- this.nillable = builder.isNillable();
- this.jsonbTransient = builder.isJsonbTransient();
- this.dateTimeFormatter = builder.getDateFormatter();
- this.numberFormat = builder.getNumberFormat();
- this.adapterBinding = builder.getAdapterInfo();
- this.serializerBinding = builder.getSerializerBinding();
- this.deserializerBinding = builder.getDeserializerBinding();
- }
-
- /**
- * Copy constructor.
- *
- * @param other other customizaton instance
- */
- public Customization(Customization other) {
- this.nillable = other.isNillable();
- this.jsonbTransient = other.isJsonbTransient();
- this.dateTimeFormatter = other.getDateTimeFormatter();
- this.numberFormat = other.getNumberFormat();
- this.adapterBinding = other.getAdapterBinding();
- this.serializerBinding = other.getSerializerBinding();
- this.deserializerBinding = other.getDeserializerBinding();
- }
-
- /**
- * Marshall null values to JSON.
- *
- * @return if true marshalling null values is active
- */
- public boolean isNillable() {
- return nillable;
- }
-
- /**
- * Skip marshalling / unmarshalling for this customization.
- * Works as java "transient" keyword.
- */
- public boolean isJsonbTransient() {
-
- return jsonbTransient;
- }
-
- /**
- * Date formatter for formatting dates.
- * If not set defaulted to javax.json.bind.annotation.JsonbDateFormat.DEFAULT_FORMAT.
- * @return date format
- */
- public JsonbDateFormatter getDateTimeFormatter() {
- return dateTimeFormatter;
- }
-
- /**
- * Number format for formatting numbers.
- * @return number format
- */
- public JsonbNumberFormatter getNumberFormat() {
- return numberFormat;
- }
-
-
- /**
- * Adapter wrapper class with resolved generic information.
- *
- * @return adapter wrapper
- */
- public AdapterBinding getAdapterBinding() {
- return adapterBinding;
- }
-
- /**
- * Serializer wrapper with resolved generic info.
- *
- * @return serialzier wrapper
- */
- public SerializerBinding getSerializerBinding() {
- return serializerBinding;
- }
-
- /**
- * Deserializer wrapper with resolved generic info.
- *
- * @return deserialzier wrapper
- */
- public DeserializerBinding getDeserializerBinding() {
- return deserializerBinding;
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/CustomizationBuilder.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/CustomizationBuilder.java
deleted file mode 100644
index 6b0f73c..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/CustomizationBuilder.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.model;
-
-import org.eclipse.persistence.json.bind.internal.adapter.AdapterBinding;
-import org.eclipse.persistence.json.bind.internal.adapter.DeserializerBinding;
-import org.eclipse.persistence.json.bind.internal.adapter.SerializerBinding;
-import org.eclipse.persistence.json.bind.internal.serializer.JsonbDateFormatter;
-import org.eclipse.persistence.json.bind.internal.serializer.JsonbNumberFormatter;
-
-/**
- * Builder for ensuring immutable state of {@link Customization} objects.
- *
- * @author Roman Grigoriadi
- */
-public class CustomizationBuilder {
-
- private boolean nillable;
-
- private boolean jsonbTransient;
-
- private String jsonReadName;
-
- private String jsonWriteName;
-
- private AdapterBinding adapterInfo;
-
- private SerializerBinding serializerBinding;
-
- private DeserializerBinding deserializerBinding;
-
- private JsonbDateFormatter dateFormatter;
-
- private JsonbNumberFormatter numberFormat;
-
- private JsonbCreator creator;
-
- private String[] propertyOrder;
-
- /**
- * Creates customization for class properties.
- * @return class property customization
- */
- public PropertyCustomization buildPropertyCustomization() {
- return new PropertyCustomization(this);
- }
-
- /**
- * Creates customization for class.
- * @return class customization
- */
- public ClassCustomization buildClassCustomization() {
- return new ClassCustomization(this);
- }
-
- /**
- * Marshall null values to JSON.
- * @return if true marshalling null values is active
- */
- public boolean isNillable() {
- return nillable;
- }
-
- /**
- * Marshall null values to JSON.
- */
- public void setNillable(boolean nillable) {
- this.nillable = nillable;
- }
-
- /**
- * Skip marshalling / unmarshalling for this customization.
- * Works as java "transient" keyword.
- */
- public boolean isJsonbTransient() {
- return jsonbTransient;
- }
-
- /**
- * Skip marshalling / unmarshalling for this customization.
- * Works as java "transient" keyword.
- */
- public void setJsonbTransient(boolean jsonbTransient) {
- this.jsonbTransient = jsonbTransient;
- }
-
- /**
- * Name as appears in JSON for reading property.
- */
- public String getJsonReadName() {
- return jsonReadName;
- }
-
- /**
- * Name as appears in JSON for reading property.
- */
- public void setJsonReadName(String jsonReadName) {
- this.jsonReadName = jsonReadName;
- }
-
- /**
- * Name as should be written to JSON for marshalling.
- */
- public String getJsonWriteName() {
- return jsonWriteName;
- }
-
- /**
- * Name as should be written to JSON for marshalling.
- */
- public void setJsonWriteName(String jsonWriteName) {
- this.jsonWriteName = jsonWriteName;
- }
-
- /**
- * Adapter a class or a property of a class.
- * @return adapter
- */
- public AdapterBinding getAdapterInfo() {
- return adapterInfo;
- }
-
- /**
- * Adapter a class or a property of a class.
- * @param adapterInfo adapter info
- */
- public void setAdapterInfo(AdapterBinding adapterInfo) {
- this.adapterInfo = adapterInfo;
- }
-
- /**
- * Meta info for user serializers.
- * @return serializer info
- */
- public SerializerBinding getSerializerBinding() {
- return serializerBinding;
- }
-
- /**
- * Set serializer info.
- * @param serializerBinding
- */
- public void setSerializerBinding(SerializerBinding serializerBinding) {
- this.serializerBinding = serializerBinding;
- }
-
- /**
- * Deserializer info.
- * @return deserialzier
- */
- public DeserializerBinding getDeserializerBinding() {
- return deserializerBinding;
- }
-
- /**
- * Deserializer info.
- * @param deserializerBinding deserializer
- */
- public void setDeserializerBinding(DeserializerBinding deserializerBinding) {
- this.deserializerBinding = deserializerBinding;
- }
-
- /**
- * Date format for formatting dates.
- * @return date format
- */
- public JsonbDateFormatter getDateFormatter() {
- return dateFormatter;
- }
-
- /**
- * Date format for formatting dates.
- * @param dateFormatter date format
- */
- public CustomizationBuilder setDateFormatter(JsonbDateFormatter dateFormatter) {
- this.dateFormatter = dateFormatter;
- return this;
- }
-
- /**
- * Number formatter for formatting numbers
- * @return number format
- */
- public JsonbNumberFormatter getNumberFormat() {
- return numberFormat;
- }
-
- /**
- * Number formatter for formatting numbers.
- * @param numberFormat number format
- */
- public void setNumberFormat(JsonbNumberFormatter numberFormat) {
- this.numberFormat = numberFormat;
- }
-
- /**
- * Custom constructor or method for user instantiation.
- * @return creator
- */
- public JsonbCreator getCreator() {
- return creator;
- }
-
- /**
- * Custom constructor or method for user instantiation.
- */
- public void setCreator(JsonbCreator creator) {
- this.creator = creator;
- }
-
- /**
- * Names of properties to sort with.
- *
- * @return sorted names of properties
- */
- public String[] getPropertyOrder() {
- return propertyOrder;
- }
-
- public void setPropertyOrder(String[] propertyOrder) {
- this.propertyOrder = propertyOrder;
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/JsonBindingModel.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/JsonBindingModel.java
deleted file mode 100644
index 294ce39..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/JsonBindingModel.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.model;
-
-import java.lang.reflect.Type;
-
-/**
- * Represents data binding logic to read write data from / to object or a collection.
- *
- * @author Roman Grigoriadi
- */
-public interface JsonBindingModel {
-
- /**
- * Introspected customization of a property or class.
- * @return immutable property customization
- */
- Customization getCustomization();
-
- /**
- * Type of a property, either bean property type or collection / array component type.
- * @return class type
- */
- Type getType();
-
- /**
- * Name of json key that will be written by marshaller.
- * @return
- */
- String getWriteName();
-
- /**
- * Current context of json generator.
- * @return context
- */
- JsonContext getContext();
-
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/JsonContext.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/JsonContext.java
deleted file mode 100644
index 706bb91..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/JsonContext.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package org.eclipse.persistence.json.bind.model;
-
-/**
- * @author Roman Grigoriadi
- */
-public enum JsonContext {
- ROOT, JSON_OBJECT, JSON_ARRAY;
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/JsonbAnnotated.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/JsonbAnnotated.java
deleted file mode 100644
index 9948b1c..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/JsonbAnnotated.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.model;
-
-import org.eclipse.persistence.json.bind.internal.properties.MessageKeys;
-import org.eclipse.persistence.json.bind.internal.properties.Messages;
-
-import javax.json.bind.JsonbException;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.AnnotatedElement;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Element wrapper containing merged annotation from class, superclasses and interfaces.
- *
- * @author Roman Grigoriadi
- */
-public class JsonbAnnotated implements AnnotatedElement {
-
- protected final Map<Class<? extends Annotation>, Annotation> annotations;
-
- public JsonbAnnotated(Annotation[] initialAnnotations) {
- this.annotations = new HashMap<>();
- addInitialAnnotations(initialAnnotations);
- }
-
- private void addInitialAnnotations(Annotation[] initialAnnotations) {
- for (Annotation ann : initialAnnotations) {
- annotations.put(ann.annotationType(), ann);
- }
- }
-
- @Override
- public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
- return annotationClass.cast(annotations.get(annotationClass));
- }
-
- @Override
- public Annotation[] getAnnotations() {
- final Collection<Annotation> values = annotations.values();
- return values.toArray(new Annotation[values.size()]);
- }
-
- @Override
- public Annotation[] getDeclaredAnnotations() {
- throw new UnsupportedOperationException("Jsonb elements don't track declared annotations");
- }
-
- public void putAnnotation(Annotation annotation) {
- if (annotations.containsKey(annotation.annotationType())) {
- throw new JsonbException(Messages.getMessage(MessageKeys.INTERNAL_ERROR, "Annotation already present: " + annotation));
- }
- annotations.put(annotation.annotationType(), annotation);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/JsonbAnnotatedElement.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/JsonbAnnotatedElement.java
deleted file mode 100644
index be0e380..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/JsonbAnnotatedElement.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.model;
-
-import java.lang.reflect.AnnotatedElement;
-
-/**
- * Annotation holder for fields, getters and setters.
- *
- * @author Roman Grigoriadi
- */
-public class JsonbAnnotatedElement<T extends AnnotatedElement> extends JsonbAnnotated {
-
- private final T element;
-
- public JsonbAnnotatedElement(T element) {
- super(element.getAnnotations());
- this.element = element;
- }
-
- public T getElement() {
- return element;
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/JsonbCreator.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/JsonbCreator.java
deleted file mode 100644
index f08d8fe..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/JsonbCreator.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.model;
-
-import org.eclipse.persistence.json.bind.internal.properties.MessageKeys;
-import org.eclipse.persistence.json.bind.internal.properties.Messages;
-
-import javax.json.bind.JsonbException;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Executable;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-/**
- * Object holding reference to Constructor / Method for custom object creation.
- *
- * @author Roman Grigoriadi
- */
-public class JsonbCreator {
-
- private final Executable executable;
-
- private final String[] params;
-
- public JsonbCreator(Executable executable, String[] params) {
- this.executable = executable;
- this.params = params;
- }
-
- /**
- * Create instance by either constructor or factory method, with provided parameter values and a Class to call on.
- *
- * @param params parameters to be passed into constructor / factory method
- * @param on class to call onto
- * @param <T> Type of class / instance
- * @return instance
- */
- @SuppressWarnings("unchecked")
- public <T> T call(Object[] params, Class<T> on) {
- try {
- if (executable instanceof Constructor) {
- return ((Constructor<T>) executable).newInstance(params);
- } else {
- return (T) ((Method) executable).invoke(on, params);
- }
- } catch (IllegalAccessException | InvocationTargetException | InstantiationException e) {
- throw new JsonbException(Messages.getMessage(MessageKeys.ERROR_CALLING_JSONB_CREATOR));
- }
- }
-
- /**
- * True if param name is one of creator params.
- * @param param param name to check
- * @return true if found
- */
- public boolean contains(String param) {
- for(int i=0; i<params.length; i++) {
- if (params[i].equals(param)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Parameter names of this creator.
- * @return parameter names
- */
- public String[] getParams() {
- return params;
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/MethodHandleValuePropagation.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/MethodHandleValuePropagation.java
deleted file mode 100644
index 9947652..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/MethodHandleValuePropagation.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-package org.eclipse.persistence.json.bind.model;
-
-import org.eclipse.persistence.json.bind.internal.JsonbContext;
-import org.eclipse.persistence.json.bind.internal.properties.MessageKeys;
-import org.eclipse.persistence.json.bind.internal.properties.Messages;
-
-import javax.json.bind.JsonbException;
-import java.lang.invoke.MethodHandle;
-import java.lang.invoke.MethodHandles;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-/**
- * Propagates values to fields using {@link java.lang.invoke.MethodHandle}
- * <p>
- * Uses field getter / setter implicitly if those are present and public.
- * Uses field direct access otherwise if field is public.
- * </p>
- * Access policy could be modified by {@link javax.json.bind.annotation.JsonbVisibility}
- *
- * @author Roman Grigoriadi
- */
-class MethodHandleValuePropagation extends PropertyValuePropagation {
-
- private MethodHandle getHandle;
-
- private MethodHandle setHandle;
-
-
- MethodHandleValuePropagation(Property property, JsonbContext ctx) {
- super(property, ctx);
- }
-
- @Override
- protected void acceptMethod(Method method, OperationMode mode) {
- try {
- switch (mode) {
- case GET:
- getHandle = MethodHandles.lookup().unreflect(method);
- break;
- case SET:
- setHandle = MethodHandles.lookup().unreflect(method);
- break;
- default:
- throw new IllegalStateException("Unknown mode");
- }
- } catch (IllegalAccessException e) {
- throw new JsonbException(Messages.getMessage(MessageKeys.CREATING_HANDLES), e);
- }
- }
-
- @Override
- protected void acceptField(Field field, OperationMode mode) {
- try {
- switch (mode) {
- case GET:
- getHandle = MethodHandles.lookup().unreflectGetter(field);
- break;
- case SET:
- setHandle = MethodHandles.lookup().unreflectSetter(field);
- break;
- default:
- throw new IllegalStateException("Unknown mode");
- }
- } catch (IllegalAccessException e) {
- throw new JsonbException(Messages.getMessage(MessageKeys.CREATING_HANDLES), e);
- }
- }
-
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void setValue(Object object, Object value) {
- try {
- setHandle.invoke(object, value);
- } catch (Throwable throwable) {
- throw new JsonbException(Messages.getMessage(MessageKeys.SETTING_VALUE_WITH, setHandle), throwable);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Object getValue(Object object) {
- try {
- return getHandle.invoke(object);
- } catch (Throwable throwable) {
- throw new JsonbException(Messages.getMessage(MessageKeys.GETTING_VALUE_WITH, getHandle), throwable);
- }
- }
-
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/PolymorphismAdapter.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/PolymorphismAdapter.java
deleted file mode 100644
index 885f483..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/PolymorphismAdapter.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.model;
-
-import javax.json.bind.adapter.JsonbAdapter;
-import java.util.stream.Stream;
-
-/**
- * Predefined type adapter which is supposed to handle polymorphism.
- *
- * <p>PolymorphismAdapter is supposed to adapt polymorphic type instances to {@link TypeWrapper}, so that resulting json document
- * will contain not only a polymorphic object, but also a class name, which is required for deserialization in case
- * of polymorphic types.
- * Consider a class model:</p>
- * <pre>
- * class Pojo {
- * Animal animal;
- * List<Animal> listOfAnimals
- * }
- * </pre>
- *
- * <p>With a Dog and Cat types which extend Animal, adapter can be configured like this:</p>
- *
- * <pre>
- * class AnimalAdapter extends PolymorphismAdapter<Animal> {}
- * JsonbConfig config ...
- * config.withAdapters(new AnimalAdapter(Dog.class, Cat.class));
- * </pre>
- *
- * <p>Polymorphic types will be than transparently handled for all instances of Animal in a class model.</p>
- *
- * <p>Enumerating allowed classes: If array of allowed classes is passed into parent constructor of
- * {@link PolymorphismAdapter}, only those classes would be allowed for loading by name. If incoming JSON
- * is not trusted, this option should always be used.</p>
- *
- * @author Roman Grigoriadi
- */
-public class PolymorphismAdapter<T> implements JsonbAdapter<T, TypeWrapper<T>> {
-
- private final String[] allowedClasses;
-
- public PolymorphismAdapter(final Class... allowedClasses) {
- this.allowedClasses = Stream.of(allowedClasses).map(Class::getName).toArray(value -> new String[allowedClasses.length]);
- }
-
- public String[] getAllowedClasses() {
- return allowedClasses;
- }
-
- @Override
- public TypeWrapper<T> adaptToJson(T obj) throws Exception {
- TypeWrapper<T> wrapper = new TypeWrapper<>();
- wrapper.setClassName(obj.getClass().getName());
- wrapper.setInstance(obj);
- return wrapper;
- }
-
- @Override
- public T adaptFromJson(TypeWrapper<T> obj) throws Exception {
- return obj.getInstance();
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/Property.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/Property.java
deleted file mode 100644
index 5907823..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/Property.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-package org.eclipse.persistence.json.bind.model;
-
-import javax.json.bind.JsonbException;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Type;
-
-/**
- * Property of a class, field, getter and setter methods (javabean alike).
- * Used during class model initialization, than dereferenced.
- *
- * @author Roman Grigoriadi
- */
-public class Property {
-
- private final String name;
-
- private final JsonbAnnotatedElement<Class<?>> declaringClassElement;
-
- private JsonbAnnotatedElement<Field> fieldElement;
-
- private JsonbAnnotatedElement<Method> getterElement;
-
- private JsonbAnnotatedElement<Method> setterElement;
-
- /**
- * Create instance of property.
- * @param name not null
- * @param declaringClassModel Class model for a class declaring property.
- */
- public Property(String name, JsonbAnnotatedElement<Class<?>> declaringClassModel) {
- this.name = name;
- this.declaringClassElement = declaringClassModel;
- }
-
- /**
- * Name of a property, java bean convention.
- *
- * @return name
- */
- public String getName() {
- return name;
- }
-
- /**
- * {@link Field} representing property if any
- *
- * @return field if present
- */
- public Field getField() {
- if (fieldElement == null) {
- return null;
- }
- return fieldElement.getElement();
- }
-
- /**
- * @param field field not null
- */
- public void setField(Field field) {
- this.fieldElement = new JsonbAnnotatedElement<>(field);
- }
-
- /**
- * {@link Method} representing getter of a property if any.
- *
- * @return getter if present
- */
- public Method getGetter() {
- if (getterElement == null) {
- return null;
- }
- return getterElement.getElement();
- }
-
- /**
- * @param getter not null
- */
- public void setGetter(Method getter) {
- this.getterElement = new JsonbAnnotatedElement<>(getter);
- }
-
- /**
- * {@link Method} representing setter of a property if any.
- *
- * @return setter if present
- */
- public Method getSetter() {
- if (setterElement == null) {
- return null;
- }
- return setterElement.getElement();
- }
-
- /**
- * @param setter setter not null
- */
- public void setSetter(Method setter) {
- this.setterElement = new JsonbAnnotatedElement<>(setter);
- }
-
- /**
- * Class element with annotation under construction for declaring class of this property.
- * This ClassModel is not fully initialized yet.
- * @return ClassModel
- */
- public JsonbAnnotatedElement<Class<?>> getDeclaringClassElement() {
- return declaringClassElement;
- }
-
- /**
- * Extracts type from first not null element:
- * Field, Getter, Setter.
- *
- * @return type of a property
- */
- public Type getPropertyType() {
- if (getField() != null) {
- return getField().getGenericType();
- } else if (getGetter() != null) {
- return getGetter().getGenericReturnType();
- } else if (getSetter() != null) {
- Type[] genericParameterTypes = getSetter().getGenericParameterTypes();
- if (genericParameterTypes.length != 1) {
- throw new JsonbException("Invalid count of arguments for setter: " + getSetter());
- }
- return genericParameterTypes[0];
- }
- throw new JsonbException("Empty property: " + name);
- }
-
- /**
- * Element with field and its annotations.
- * @return field with annotations
- */
- public JsonbAnnotatedElement<Field> getFieldElement() {
- return fieldElement;
- }
-
- /**
- * Element with getter and its annotations.
- * @return getter with annotations
- */
- public JsonbAnnotatedElement<Method> getGetterElement() {
- return getterElement;
- }
-
- /**
- * Element with setter and its annotations.
- * @return setter with annotations
- */
- public JsonbAnnotatedElement<Method> getSetterElement() {
- return setterElement;
- }
-
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/PropertyCustomization.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/PropertyCustomization.java
deleted file mode 100644
index 172358e..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/PropertyCustomization.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.model;
-
-/**
- * Customization for a property of a class.
- *
- * @author Roman Grigoriadi
- */
-public class PropertyCustomization extends Customization {
-
- private final String jsonReadName;
-
- private final String jsonWriteName;
-
-
- /**
- * Copies properties from builder an creates immutable instance.
- * @param builder not null
- */
- public PropertyCustomization(CustomizationBuilder builder) {
- super(builder);
- this.jsonReadName = builder.getJsonReadName();
- this.jsonWriteName = builder.getJsonWriteName();
- }
-
- /**
- * Name if specified for property setter with {@link javax.json.bind.annotation.JsonbProperty}.
- * @return read name
- */
- public String getJsonReadName() {
- return jsonReadName;
- }
-
- /**
- * Name if specified for property getter with {@link javax.json.bind.annotation.JsonbProperty}.
- * @return write name
- */
- public String getJsonWriteName() {
- return jsonWriteName;
- }
-
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/PropertyModel.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/PropertyModel.java
deleted file mode 100644
index dba78b0..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/PropertyModel.java
+++ /dev/null
@@ -1,294 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-package org.eclipse.persistence.json.bind.model;
-
-import org.eclipse.persistence.json.bind.internal.AnnotationIntrospector;
-import org.eclipse.persistence.json.bind.internal.JsonbContext;
-import org.eclipse.persistence.json.bind.internal.ReflectionUtils;
-import org.eclipse.persistence.json.bind.internal.adapter.AdapterBinding;
-import org.eclipse.persistence.json.bind.internal.adapter.SerializerBinding;
-import org.eclipse.persistence.json.bind.internal.serializer.AdaptedObjectSerializer;
-import org.eclipse.persistence.json.bind.internal.serializer.DefaultSerializers;
-import org.eclipse.persistence.json.bind.internal.serializer.SerializerProviderWrapper;
-import org.eclipse.persistence.json.bind.internal.serializer.UserSerializerSerializer;
-
-import javax.json.bind.config.PropertyNamingStrategy;
-import javax.json.bind.serializer.JsonbSerializer;
-import java.lang.reflect.Type;
-import java.util.Objects;
-import java.util.Optional;
-
-/**
- * A model for class property.
- * Property is JavaBean alike meta information field / getter / setter of a property in class.
- *
- * @author Dmitry Kornilov
- * @author Roman Grigoriadi
- */
-public class PropertyModel implements JsonBindingModel, Comparable<PropertyModel> {
-
- /**
- * Field propertyName as in class by java bean convention.
- */
- private final String propertyName;
-
- /**
- * Calculated name to be used when reading json document.
- */
- private final String readName;
-
- /**
- * Calculated name to be used when writing json document.
- */
- private final String writeName;
-
- /**
- * Field propertyType.
- */
- private final Type propertyType;
-
- /**
- * Model of the class this field belongs to.
- */
- private final ClassModel classModel;
-
- /**
- * Customization of this property.
- */
- final private PropertyCustomization customization;
-
- private final PropertyValuePropagation propagation;
-
- private final JsonbSerializer<?> propertySerializer;
-
- /**
- * Flag to cache serializer. If type is not resolved (TypeVariable or ParameterizedType containing TypeVariables)
- * Serializer / Adapter caching is not possible.
- */
- private final boolean resolvedType;
-
- /**
- * Creates instance.
- * @param classModel classModel of declaring class.
- * @param property javabean like property to model.
- */
- public PropertyModel(ClassModel classModel, Property property, JsonbContext jsonbContext) {
- this.classModel = classModel;
- this.propertyName = property.getName();
- this.propertyType = property.getPropertyType();
- this.propagation = PropertyValuePropagation.createInstance(property, jsonbContext);
- this.customization = introspectCustomization(property, jsonbContext);
- this.readName = calculateReadWriteName(customization.getJsonReadName(), jsonbContext.getPropertyNamingStrategy());
- this.writeName = calculateReadWriteName(customization.getJsonWriteName(), jsonbContext.getPropertyNamingStrategy());
- this.propertySerializer = resolveCachedSerializer();
- this.resolvedType = ReflectionUtils.isResolvedType(propertyType);
- }
-
-
- /**
- * Try to cache serializer for this bean property. Only if type cannot be changed during runtime.
- *
- * @return serializer instance to be cached
- */
- private JsonbSerializer<?> resolveCachedSerializer() {
- if (!ReflectionUtils.isResolvedType(propertyType)) {
- return null;
- }
- if (customization.getAdapterBinding() != null) {
- return new AdaptedObjectSerializer<>(this, customization.getAdapterBinding());
- }
- if (customization.getSerializerBinding() != null) {
- return new UserSerializerSerializer<>(this, customization.getSerializerBinding().getJsonbSerializer());
- }
-
- final Class<?> propertyRawType = ReflectionUtils.getRawType(propertyType);
- final Optional<SerializerProviderWrapper> valueSerializerProvider = DefaultSerializers.getInstance().findValueSerializerProvider(propertyRawType);
- if (valueSerializerProvider.isPresent()) {
- return valueSerializerProvider.get().getSerializerProvider().provideSerializer(this);
- }
-
- return null;
- }
-
- private AdapterBinding getUserAdapterBinding(Property property, JsonbContext jsonbContext) {
- final AdapterBinding adapterBinding = jsonbContext.getAnnotationIntrospector().getAdapterBinding(property);
- if (adapterBinding != null) {
- return adapterBinding;
- }
- return jsonbContext.getComponentMatcher().getAdapterBinding(propertyType, null).orElse(null);
- }
-
- private SerializerBinding<?> getUserSerializerBinding(Property property, JsonbContext jsonbContext) {
- final SerializerBinding serializerBinding = jsonbContext.getAnnotationIntrospector().getSerializerBinding(property);
- if (serializerBinding != null) {
- return serializerBinding;
- }
- return jsonbContext.getComponentMatcher().getSerialzierBinding(propertyType, null).orElse(null);
- }
-
- private PropertyCustomization introspectCustomization(Property property, JsonbContext jsonbContext) {
- final AnnotationIntrospector introspector = jsonbContext.getAnnotationIntrospector();
- final CustomizationBuilder builder = new CustomizationBuilder();
- //drop all other annotations for transient properties
- if (introspector.isTransient(property)) {
- builder.setJsonbTransient(true);
- return builder.buildPropertyCustomization();
- }
- builder.setJsonReadName(introspector.getJsonbPropertyJsonReadName(property));
- builder.setJsonWriteName(introspector.getJsonbPropertyJsonWriteName(property));
- builder.setNillable(classModel.getClassCustomization().isNillable()
- || introspector.isPropertyNillable(property));
- builder.setAdapterInfo(getUserAdapterBinding(property, jsonbContext));
- builder.setSerializerBinding(getUserSerializerBinding(property, jsonbContext));
- builder.setDeserializerBinding(introspector.getDeserializerBinding(property));
- builder.setDateFormatter(introspector.getJsonbDateFormat(property));
- builder.setNumberFormat(introspector.getJsonbNumberFormat(property));
- return builder.buildPropertyCustomization();
- }
-
- /**
- * Read a property.
- *
- * @param object object to read property from.
- * @return value in case property value is set and field is readable. If null or not readable (transient, static), return s null.
- */
- public Object getValue(Object object) {
- if (!isReadable()) {
- //nulls are omitted in produced JSON, unless overriden
- return null;
- }
- return propagation.getValue(object);
- }
-
- /**
- * Sets a property.
- *
- * If not writable (final, transient, static), ignores property.
- *
- * @param object Object to set value in.
- * @param value Value to set.
- */
- public void setValue(Object object, Object value) {
- if (!isWritable()) {
- return;
- }
- propagation.setValue(object, value);
- }
-
- /**
- * Property is readable. Based on access policy and java field modifiers.
- * @return true if can be serialized to JSON
- */
- public boolean isReadable() {
- return !customization.isJsonbTransient() && propagation.isReadable();
- }
-
- /**
- * Property is writable. Based on access policy and java field modifiers.
- * @return true if can be deserialized from JSON
- */
- public boolean isWritable() {
- return !customization.isJsonbTransient() && propagation.isWritable();
- }
-
- /**
- * Default property name according to Field / Getter / Setter method names.
- * This name is use for identifying properties, for JSON serialization is used customized name
- * which may be derived from default name.
- * @return default name
- */
- public String getPropertyName() {
- return propertyName;
- }
-
- /**
- * Runtime type of a property. May be a TypeVariable or WildcardType.
- *
- * @return type of a property
- */
- public Type getPropertyType() {
- return propertyType;
- }
-
- /**
- * Model of declaring class of this property.
- * @return class model
- */
- public ClassModel getClassModel() {
- return classModel;
- }
-
- /**
- * Introspected customization of a property.
- * @return immutable property customization
- */
- @Override
- public PropertyCustomization getCustomization() {
- return customization;
- }
-
- /**
- * Class of a property, either bean property type or collection / array component type.
- *
- * @return class type
- */
- @Override
- public Type getType() {
- return getPropertyType();
- }
-
- @Override
- public int compareTo(PropertyModel o) {
- return propertyName.compareTo(o.getPropertyName());
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- PropertyModel that = (PropertyModel) o;
- return Objects.equals(propertyName, that.propertyName);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(propertyName);
- }
-
- @Override
- public JsonContext getContext() {
- return JsonContext.JSON_OBJECT;
- }
-
- public String getReadName() {
- return readName;
- }
-
- @Override
- public String getWriteName() {
- return writeName;
- }
-
- public JsonbSerializer<?> getPropertySerializer() {
- return propertySerializer;
- }
-
- /**
- * If customized by JsonbPropertyAnnotation, than is used, otherwise use strategy to translate.
- * Since this is cached for performance reasons strategy has to be consistent
- * with calculated values for same input.
- */
- private String calculateReadWriteName(String readWriteName, PropertyNamingStrategy strategy) {
- return readWriteName != null ? readWriteName : strategy.translateName(propertyName);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/PropertyValuePropagation.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/PropertyValuePropagation.java
deleted file mode 100644
index 0474156..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/PropertyValuePropagation.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- * <p>
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.model;
-
-import org.eclipse.persistence.json.bind.internal.JsonbContext;
-
-import javax.json.bind.config.PropertyVisibilityStrategy;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.Optional;
-import java.util.function.Function;
-
-/**
- * Abstract class for getting / setting value into the property.
- *
- * @author Roman Grigoriadi
- */
-public abstract class PropertyValuePropagation {
-
- /**
- * Mode of property propagation get or set.
- */
- public enum OperationMode {
- GET, SET
- }
-
- /**
- * Property can be written (unmarshalled from json)
- */
- protected boolean writable;
-
- /**
- * Property can be read (marshalled to json)
- */
- protected boolean readable;
-
- /**
- * Construct a property propagation.
- * @param property provided property
- * @param ctx
- */
- protected PropertyValuePropagation(Property property, JsonbContext ctx) {
- initReadable(property.getField(), property.getGetter(), ctx);
- initWritable(property.getField(), property.getSetter(), ctx);
- }
-
- /**
- * Create typed instance to use.
- * @param property property to create from
- * @param ctx
- * @return propagation instance
- */
- public static PropertyValuePropagation createInstance(Property property, JsonbContext ctx) {
- return new ReflectionPropagation(property, ctx);
- }
-
- private void initReadable(Field field, Method getter, JsonbContext ctx) {
-
- final boolean fieldReadable = field == null || (field.getModifiers() & (Modifier.TRANSIENT | Modifier.STATIC)) == 0;
- if (!fieldReadable) {
- readable = false;
- return;
- }
- if (getter != null) {
- if (!isVisible(getter, ctx)) {
- return; //don't check field if getter is not visible
- }
- if (!Modifier.isPublic(getter.getModifiers()) || getter.getDeclaringClass().isAnonymousClass()) {
- getter.setAccessible(true);
- }
- acceptMethod(getter, OperationMode.GET);
- readable = true;
- } else if (isVisible(field, ctx)) {
- if (!Modifier.isPublic(field.getModifiers()) || field.getDeclaringClass().isAnonymousClass()) {
- field.setAccessible(true);
- }
- acceptField(field, OperationMode.GET);
- readable = true;
- }
- }
-
- private void initWritable(Field field, Method setter, JsonbContext ctx) {
-
- final boolean fieldWritable = field == null || (field.getModifiers() & (Modifier.TRANSIENT | Modifier.STATIC | Modifier.FINAL)) == 0;
- if (!fieldWritable) {
- writable = false;
- return;
- }
- if (setter != null) {
- if (!isVisible(setter, ctx) || setter.getDeclaringClass().isAnonymousClass()) {
- return;
- }
- if (!Modifier.isPublic(setter.getModifiers())) {
- setter.setAccessible(true);
- }
- acceptMethod(setter, OperationMode.SET);
- writable = true;
- } else if (isVisible(field, ctx) && !field.getDeclaringClass().isAnonymousClass()) {
- if (!Modifier.isPublic(field.getModifiers())) {
- field.setAccessible(true);
- }
- acceptField(field, OperationMode.SET);
- writable = true;
- }
- }
-
- private boolean isVisible(Field field, JsonbContext ctx) {
- if (field == null) {
- return false;
- }
- return isVisible(strategy -> strategy.isVisible(field), field.getDeclaringClass(), ctx)
- .orElseGet(()->Modifier.isPublic(field.getModifiers()));
- }
-
- private boolean isVisible(Method method, JsonbContext ctx) {
- if (method == null) {
- return false;
- }
- return isVisible(strategy -> strategy.isVisible(method), method.getDeclaringClass(), ctx)
- .orElseGet(()->Modifier.isPublic(method.getModifiers()));
- }
-
- /**
- * Look up class and package level @JsonbVisibility, or global config PropertyVisibilityStrategy.
- * If any is found it is used for resolving visibility by calling provided visibilityCheckFunction.
- *
- * @param visibilityCheckFunction function declaring visibility check
- * @param declaringClass class to lookup annotation onto
- * @param ctx jsonb context
- * @return Optional with result of visibility check, or empty optional if no strategy is found
- */
- private Optional<Boolean> isVisible(Function<PropertyVisibilityStrategy, Boolean> visibilityCheckFunction, Class<?> declaringClass, JsonbContext ctx) {
- final Optional<PropertyVisibilityStrategy> classLevelStrategy =
- ctx.getAnnotationIntrospector().getPropertyVisibilityStrategy(declaringClass);
- Optional<PropertyVisibilityStrategy> strategy =
- Optional.ofNullable(classLevelStrategy.orElseGet(ctx::getPropertyVisibilityStrategy));
-
- return strategy.map(visibilityCheckFunction);
- }
-
- /**
- * Accept a {@link Method} to use value propagation.
- * @param method method
- * @param mode read or write
- */
- protected abstract void acceptMethod(Method method, OperationMode mode);
-
- /**
- * Accept a {@link Field} to use for value propagation.
- * @param field field
- * @param mode mod
- */
- protected abstract void acceptField(Field field, OperationMode mode);
-
- /**
- * Set a value to a field. Based on policy invokes a setter or sets directly to a field.
- *
- * @param object object to set value in
- * @param value value to set, null is valid
- */
- abstract void setValue(Object object, Object value);
-
- /**
- * Gets a value of a field. Based on policy invokes a getter or gets directly from a field.
- *
- * @param object object to get from
- */
- abstract Object getValue(Object object);
-
- /**
- * Property is writable. Based on access policy and java field modifiers.
- * @return true if can be deserialized from JSON
- */
- public boolean isWritable() {
- return writable;
- }
-
- /**
- * Property is readable. Based on access policy and java field modifiers.
- * @return true if can be serialized to JSON
- */
- public boolean isReadable() {
- return readable;
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/ReflectionPropagation.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/ReflectionPropagation.java
deleted file mode 100644
index f8355d0..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/ReflectionPropagation.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-package org.eclipse.persistence.json.bind.model;
-
-import org.eclipse.persistence.json.bind.internal.JsonbContext;
-
-import javax.json.bind.JsonbException;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-/**
- * @author Roman Grigoriadi
- */
-public class ReflectionPropagation extends PropertyValuePropagation {
-
- private interface GetValueCommand {
- Object internalGetValue(Object object) throws IllegalAccessException, InvocationTargetException;
-
- default Object getValue(Object object) {
- try {
- return internalGetValue(object);
- } catch (InvocationTargetException | IllegalAccessException e) {
- throw new JsonbException("Error getting value on: " + object, e);
- }
- }
- }
-
- private interface SetValueCommand {
- void internalSetValue(Object object, Object value) throws IllegalAccessException, InvocationTargetException;
-
- default void setValue(Object object, Object value) {
- try {
- internalSetValue(object, value);
- } catch (InvocationTargetException | IllegalAccessException e) {
- throw new JsonbException("Error getting value on: " + object, e);
- }
- }
- }
-
- private GetValueCommand getValueCommand;
-
- private SetValueCommand setValueCommand;
-
- ReflectionPropagation(Property property, JsonbContext ctx) {
- super(property, ctx);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void acceptMethod(Method method, OperationMode mode) {
- switch (mode) {
- case GET:
- getValueCommand = method::invoke;
- break;
- case SET:
- setValueCommand = method::invoke;
- break;
- default: throw new IllegalStateException("Unknown mode");
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- protected void acceptField(Field field, OperationMode mode) {
- switch (mode) {
- case GET:
- getValueCommand = field::get;
- break;
- case SET:
- setValueCommand = field::set;
- break;
- default: throw new IllegalStateException("Unknown mode");
- }
- }
-
- @Override
- void setValue(Object object, Object value) {
- setValueCommand.setValue(object, value);
- }
-
- @Override
- Object getValue(Object object) {
- return getValueCommand.getValue(object);
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/TypeWrapper.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/TypeWrapper.java
deleted file mode 100644
index 72f8f52..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/model/TypeWrapper.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.model;
-
-/**
- * Type wrapper used to represent polymorphic types during serialization / deserialization.
- *
- * @author Roman Grigoriadi
- */
-public class TypeWrapper<T> {
-
- private String className;
- private T instance;
-
- public String getClassName() {
- return className;
- }
-
- public void setClassName(String className) {
- this.className = className;
- }
-
- public T getInstance() {
- return instance;
- }
-
- public void setInstance(T instance) {
- this.instance = instance;
- }
-}
diff --git a/jsonb/src/main/java/org/eclipse/persistence/json/bind/serializer/UserDeserializerParser.java b/jsonb/src/main/java/org/eclipse/persistence/json/bind/serializer/UserDeserializerParser.java
deleted file mode 100644
index 4d921c8..0000000
--- a/jsonb/src/main/java/org/eclipse/persistence/json/bind/serializer/UserDeserializerParser.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.serializer;
-
-import org.eclipse.persistence.json.bind.internal.JsonbParser;
-import org.eclipse.persistence.json.bind.internal.JsonbRiParser;
-import org.eclipse.persistence.json.bind.internal.unmarshaller.UserDeserializerDeserializer;
-
-import javax.json.stream.JsonLocation;
-import javax.json.stream.JsonParser;
-import java.math.BigDecimal;
-import java.util.Stack;
-
-/**
- * Decorator for JSONP parser. Adds some checks for parser cursor manipulation methods.
- *
- * @author Roman Grigoriadi
- */
-public class UserDeserializerParser implements JsonbParser {
-
- private final JsonbParser jsonbParser;
-
- /**
- * Remembered parser level, which is applied to user deserializer structure.
- */
- private final JsonbRiParser.LevelContext level;
-
- /**
- * Constructs an instance with parser and context.
- * @param parser jsonb parser to decorate
- */
- public UserDeserializerParser(JsonbParser parser) {
- this.jsonbParser = parser;
- level = jsonbParser.getCurrentLevel();
- }
-
- /**
- * JsonParser in JSONB runtime is shared with user components, if user lefts cursor half way in progress
- * it must be advanced artificially to the end of JSON structure representing deserialized object.
- */
- public void advanceParserToEnd() {
- while (!level.isParsed() && jsonbParser.hasNext()) {
- next();
- }
- }
-
- @Override
- public boolean hasNext() {
- return !level.isParsed() && jsonbParser.hasNext();
- }
-
- @Override
- public Event next() {
- if (level.isParsed()) {
- throw new IllegalStateException("Parser level data inconsistent.");
- }
- return jsonbParser.next();
- }
-
-
- @Override
- public String getString() {
- return jsonbParser.getString();
- }
-
- @Override
- public boolean isIntegralNumber() {
- return jsonbParser.isIntegralNumber();
- }
-
- @Override
- public int getInt() {
- return jsonbParser.getInt();
- }
-
- @Override
- public long getLong() {
- return jsonbParser.getLong();
- }
-
- @Override
- public BigDecimal getBigDecimal() {
- return jsonbParser.getBigDecimal();
- }
-
- @Override
- public JsonLocation getLocation() {
- return jsonbParser.getLocation();
- }
-
- @Override
- public void close() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Moves parser to required event, if current event is equal to required does nothing.
- *
- * @param event required event
- */
- @Override
- public void moveTo(Event event) {
- jsonbParser.moveTo(event);
- }
-
- /**
- * Moves parser cursor to any JSON value.
- */
- @Override
- public Event moveToValue() {
- return jsonbParser.moveToValue();
- }
-
- /**
- * Moves parser cursor to START_OBJECT or START_ARRAY.
- */
- @Override
- public Event moveToStartStructure() {
- return jsonbParser.moveToStartStructure();
- }
-
- /**
- * Current level of JsonbRiParser.
- *
- * @return current level
- */
- @Override
- public JsonbRiParser.LevelContext getCurrentLevel() {
- return jsonbParser.getCurrentLevel();
- }
-
- /**
- * Skips a value or a structure.
- * If current event is START_ARRAY or START_OBJECT, whole structure is skipped to end.
- */
- @Override
- public void skipJsonStructure() {
- jsonbParser.skipJsonStructure();
- }
-}
diff --git a/jsonb/src/main/resources/messages.properties b/jsonb/src/main/resources/messages.properties
deleted file mode 100644
index 64448ff..0000000
--- a/jsonb/src/main/resources/messages.properties
+++ /dev/null
@@ -1,64 +0,0 @@
-################################################################################
-# Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
-# This program and the accompanying materials are made available under the
-# terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
-# which accompanies this distribution.
-# The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
-# and the Eclipse Distribution License is available at
-# http://www.eclipse.org/org/documents/edl-v10.php.
-#
-# Contributors:
-# Roman Grigoriadi
-# David Kral
-################################################################################
-
-cannotMarshallObject = Cannot marshall object
-typeResolutionError = Error resolving runtime type for type: {0}
-genericBoundNotFound = Generic bound not found for type {0} declared in {1}.
-cantConvertJsonValue = Can'''t convert JSON value into: {0}
-cantCreateRootInstance = Can'''t create root instance
-invokingGetter = Error invoking getter method.
-gettingValue = Error getting field value.
-settingValue = Error setting field value.
-noLoggerName = Logger name has to be set
-resolveParametrizedType = Can''t resolve ParameterizedType superclass for: {0}
-cantCreateInstance = Can''t create instance
-inferTypeForUnmarshall = Can''t infer a type for unmarshalling into: {0}
-notValueType = Not a value type: {0}
-unexpectedParseEvent = Unexpected parser event: {0}
-processFromJson = Process class: {0} from json using converter: {1}
-processToJson = Process class: {0} to json using converter: {1}
-creatingHandles = Error creating handles.
-settingValueWith = Error setting value with: {0}
-gettingValueWith = Error getting value with: {0}
-unpairedSurrogate = String contains unpaired surrogate.
-adapterException = Problem adapting object of type {0} to {1} in class {2}
-adapterFound = Found adapter from type {0} to type {1}.
-adapterIncompatible = Adapter of runtime type {0} does not match property type {1}
-propertyOrder = "Property order strategy with name {0} wasn't recognized"
-unsupportedJsonpSerializerValue=Unsupported value of type {0} for JSON serializer.
-beanManagerNotFoundJndi=BeanManager not found in JNDI under {0}.\nNamingException explanation: {1}
-beanManagerNotFoundNoProvider=No provider was registered for BeanManager.
-usingDefaultConstructorInstantiator=Falling back to default constructor component creator.
-iJsonEnabledSingleValue = Cannot marshal single value because I-Json is enabled!
-dateTypeNotSupported=Date type not supported: {0}
-errorParsingDate=Error parsing date from value: {0} with formatter: {1}
-noDefaultConstructor=Can''t create instance of a class: {0}, No default constructor found.
-offsetDateTimeFromMillis=Parsing {0} from epoch millisecond, default zone {1} will be used.
-timeToEpochMillisError=Cant convert {0} to/from epoch milliseconds.
-configPropertyInvalidType=JsonbConfig property [{0}] must be of type [{1}].
-conversionNotSupported=Conversion of type [{0}] to/from string value is not supported.
-endOfJsonStructure=End of JSON structure reached.
-invalidDeserializationType=Invalid json value type {0} for deserialization into type {1}.
-czechDiacritics=p\u0159\u00edli\u0161,\u017elu\u0165ou\u010dk\u00fd,k\u016f\u0148,\u00fap\u011bl,\u010f\u00e1belsk\u00e9,\u00f3dy
-russianDiacritics=\u0441\u043b\u0438\u0448\u043a\u043e\u043c,\u0436\u0435\u043b\u0442\u0435\u043d\u044c\u043a\u0438\u0439,\u043a\u043e\u043d\u044c,\u043f\u0435\u043b,\u0430\u0434\u0441\u043a\u0438\u0435,\u043e\u0434\u044b
-propertyNotFoundDeserializer=Property {0} was not found in class {1}. Skipping value {2}.
-settingPropertyDeserializer=Setting property {0} in class {1} with value {2}.
-classLoadNotAllowed=Class load for {0} name is not allowed!errorCallingJsonbCreator=Exception occurred during call to JSONB creator on class: {0}.
-incompatibleFactoryCreatorReturnType=Return type of creator {0} must be of type {1}.
-multipleJsonbCreators=More than one @JsonbCreator declared in class {0}.
-internalError=Internal error: {0}
-deserializeValueError=Error deserialize JSON value into type: {0}.
-parsingNumber=Error parsing number {0} with format {1}.
-unknownBinaryDataStrategy=Unknown binary data strategy: {0}
-invalidPropertyNamingStrategy=Property naming strategy must be either: String name, or instance of javax.json.bind.config.PropertyNamingStrategy.
\ No newline at end of file
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/SimpleTest.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/SimpleTest.java
deleted file mode 100644
index 5a579a0..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/SimpleTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package org.eclipse.persistence.json.bind;
-
-import org.eclipse.persistence.json.bind.defaultmapping.basic.SingleValueTest;
-import org.eclipse.persistence.json.bind.internal.JsonBindingBuilder;
-import org.junit.Test;
-
-import javax.json.bind.Jsonb;
-import javax.json.bind.JsonbBuilder;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * @author Roman Grigoriadi
- */
-public class SimpleTest {
-
- public static class StringWrapper {
- public String value;
-
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
- }
-
-
- Jsonb jsonb = JsonbBuilder.create();
-
- @Test
- public void testSimpleSerialize() {
- Jsonb jsonb = (new JsonBindingBuilder()).build();
- final StringWrapper wrapper = new StringWrapper();
- wrapper.setValue("abc");
- jsonb.toJson(wrapper);
- final String val = jsonb.toJson(wrapper);
- assertEquals("{\"value\":\"abc\"}", val);
- }
-
- @Test
- public void testSimpleDeserialzier() {
- final StringWrapper stringWrapper = jsonb.fromJson("{\"value\":\"abc\"}", StringWrapper.class);
- assertEquals("abc", stringWrapper.getValue());
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/TestTypeToken.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/TestTypeToken.java
deleted file mode 100644
index 8b8e19e..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/TestTypeToken.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package org.eclipse.persistence.json.bind;
-
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-
-/**
- * @author Roman Grigoriadi
- */
-public abstract class TestTypeToken<T> {
- public Type getType() {
- return ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/adapters/AdaptersTest.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/adapters/AdaptersTest.java
deleted file mode 100644
index 45cf5d0..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/adapters/AdaptersTest.java
+++ /dev/null
@@ -1,407 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- * <p>
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.adapters;
-
-
-import org.eclipse.persistence.json.bind.TestTypeToken;
-import org.eclipse.persistence.json.bind.adapters.model.*;
-import org.junit.Test;
-
-import javax.json.bind.Jsonb;
-import javax.json.bind.JsonbBuilder;
-import javax.json.bind.JsonbConfig;
-import javax.json.bind.adapter.JsonbAdapter;
-import java.math.BigDecimal;
-import java.util.*;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Tests adapters to behave correctly.
- *
- * @author Roman Grigoriadi
- */
-public class AdaptersTest {
-
- private Jsonb jsonb;
-
- public static class NonGenericPojo {
- public String strValues;
- public Box box;
- }
-
- @Test
- public void testBoxToCrateNoGenerics() throws Exception {
- JsonbAdapter<?, ?>[] adapters = {
- new JsonbAdapter<Box, Crate>() {
- @Override
- public Crate adaptToJson(Box box) {
- final Crate crate = new Crate();
- crate.setCrateStrField("crateAdapted" + box.getBoxStrField());
- crate.setCrateIntField(box.getBoxIntegerField() + 1);
- return crate;
- }
-
- @Override
- public Box adaptFromJson(Crate crate) {
- Box box = new Box();
- box.setBoxStrField("boxAdapted" + crate.getCrateStrField());
- box.setBoxIntegerField(crate.getCrateIntField() + 1);
- return box;
- }
- }
- };
- jsonb = JsonbBuilder.create(new JsonbConfig().setProperty(JsonbConfig.ADAPTERS, adapters));
-
- AdaptedPojo pojo = new AdaptedPojo();
- Box box = new Box();
- box.setBoxStrField("BoxStr");
- box.setBoxIntegerField(10);
- pojo.box = box;
- String json = jsonb.toJson(pojo);
- assertEquals("{\"box\":{\"crateIntField\":11,\"crateStrField\":\"crateAdaptedBoxStr\"}}", json);
-
- AdaptedPojo<?> result = jsonb.fromJson("{\"box\":{\"crateIntField\":10,\"crateStrField\":\"CrateStr\"}}", AdaptedPojo.class);
- assertEquals(Integer.valueOf(11), result.box.getBoxIntegerField());
- assertEquals("boxAdaptedCrateStr", result.box.getBoxStrField());
- }
-
- @Test
- public void testValueFieldAdapter() throws Exception {
- JsonbAdapter<?, ?>[] adapters = {
- new JsonbAdapter<Integer, String>() {
- @Override
- public String adaptToJson(Integer integer) {
- return String.valueOf(integer);
- }
-
- @Override
- public Integer adaptFromJson(String s) {
- return Integer.parseInt(s);
- }
- }
- };
- jsonb = JsonbBuilder.create(new JsonbConfig().setProperty(JsonbConfig.ADAPTERS, adapters));
-
- AdaptedPojo pojo = new AdaptedPojo();
- pojo.intField = 11;
- String json = jsonb.toJson(pojo);
- assertEquals("{\"intField\":\"11\"}", json);
-
- AdaptedPojo<?> result = jsonb.fromJson("{\"intField\":\"10\"}", AdaptedPojo.class);
- assertEquals(Integer.valueOf(10), result.intField);
- }
-
- @Test
- public void testGenericAdapter() throws Exception {
- JsonbAdapter<?, ?>[] adapters = {new BoxToCrateCompatibleGenericsAdapter<Integer>() {
- }};
- jsonb = JsonbBuilder.create(new JsonbConfig().setProperty(JsonbConfig.ADAPTERS, adapters));
-
- AdaptedPojo<Integer> pojo = new AdaptedPojo<>();
- pojo.strField = "POJO_STRING";
- pojo.intBox = new GenericBox<>("INT_BOX_STR", 11);
- pojo.tBox = new GenericBox<>("T_BOX_STR", 110);
-
- String marshalledJson = jsonb.toJson(pojo, new TestTypeToken<AdaptedPojo<Integer>>(){}.getType());
- assertEquals("{\"intBox\":{\"adaptedT\":11,\"crateStrField\":\"INT_BOX_STR\"}," +
- "\"strField\":\"POJO_STRING\"," +
- "\"tBox\":{\"adaptedT\":110,\"crateStrField\":\"T_BOX_STR\"}}", marshalledJson);
-
- String toUnmarshall = "{\"intBox\":{\"crateStrField\":\"Box3\",\"adaptedT\":33}," +
- "\"tBox\":{\"crateStrField\":\"tGenBoxCrateStr\",\"adaptedT\":22}," +
- "\"strField\":\"POJO_STRING\"," +
- "\"strBox\":{\"strField\":\"strBoxStr\",\"x\":\"44\"}}";
- AdaptedPojo result = jsonb.fromJson(toUnmarshall, new TestTypeToken<AdaptedPojo<Integer>>(){}.getType());
- assertEquals("POJO_STRING", result.strField);
- assertEquals("Box3", result.intBox.getStrField());
- assertEquals(33, result.intBox.getX());
- assertEquals("tGenBoxCrateStr", result.tBox.getStrField());
- assertEquals(22, result.tBox.getX());
- assertEquals("strBoxStr", result.strBox.getStrField());
- assertEquals("44", result.strBox.getX());
-
- }
-
- @Test
- public void testPropagatedTypeArgs() throws Exception {
- JsonbAdapter<?, ?>[] adapters = {new BoxToCratePropagatedIntegerStringAdapter()};
- jsonb = JsonbBuilder.create(new JsonbConfig().setProperty(JsonbConfig.ADAPTERS, adapters));
-
- AdaptedPojo<Integer> pojo = new AdaptedPojo<>();
- pojo.intBox = new GenericBox<>("INT_BOX_STR", 110);
- pojo.tBox = new GenericBox<>("T_BOX_STR", 111);
- pojo.strBox = new GenericBox<>("STR_BOX_STR", "101");
-
- String marshalledJson = jsonb.toJson(pojo, new TestTypeToken<AdaptedPojo<Integer>>(){}.getType());
- assertEquals("{\"intBox\":{\"adaptedT\":{\"x\":[\"110\"]},\"crateStrField\":\"INT_BOX_STR\"}," +
- "\"strBox\":{\"strField\":\"STR_BOX_STR\",\"x\":\"101\"}," +
- "\"tBox\":{\"adaptedT\":{\"x\":[\"111\"]},\"crateStrField\":\"T_BOX_STR\"}}",
- marshalledJson);
-
- String toUnmarshall = "{\"intBox\":{\"crateStrField\":\"strCrateStr\",\"adaptedT\":{\"strField\":\"crateBoxStrField\",\"x\":[\"77\"]}}," +
- "\"tBox\":{\"crateStrField\":\"tStrCrateStr\",\"adaptedT\":{\"strField\":\"crateBoxStrField\",\"x\":[\"88\"]}}," +
- "\"strField\":\"POJO_STRING\"," +
- "\"strBox\":{\"strField\":\"strBoxStr\",\"x\":\"44\"}}";
-
- AdaptedPojo result = jsonb.fromJson(toUnmarshall, new TestTypeToken<AdaptedPojo<Integer>>(){}.getType());
- assertEquals("POJO_STRING", result.strField);
- assertEquals("strCrateStr", result.intBox.getStrField());
- assertEquals(77, result.intBox.getX());
- assertEquals("tStrCrateStr", result.tBox.getStrField());
- assertEquals(88, result.tBox.getX());
- assertEquals("strBoxStr", result.strBox.getStrField());
- assertEquals("44", result.strBox.getX());
- }
-
- @Test
- public void testStringToGenericCollectionAdapter() throws Exception {
-
- JsonbAdapter<?, ?>[] adapters = {new IntegerListToStringAdapter()};
- jsonb = JsonbBuilder.create(new JsonbConfig().setProperty(JsonbConfig.ADAPTERS, adapters));
-
- AdaptedPojo<List<Integer>> pojo = new AdaptedPojo<>();
- pojo.tVar = Arrays.asList(11, 22, 33);
- pojo.integerList = Arrays.asList(110, 111, 101);
- String marshalledJson = jsonb.toJson(pojo, new TestTypeToken<AdaptedPojo<List<Integer>>>(){}.getType());
- assertEquals("{\"integerList\":\"110#111#101\"," +
- "\"tVar\":\"11#22#33\"}", marshalledJson);
-
- String toUnmarshall = "{\"integerList\":\"11#22#33#44\",\"stringList\":[\"first\",\"second\"]," +
- "\"tVar\":\"110#111#101\"}";
-
- AdaptedPojo result = jsonb.fromJson(toUnmarshall, new TestTypeToken<AdaptedPojo<List<Integer>>>(){}.getType());
- List<Integer> expectedIntegerList = Arrays.asList(11, 22, 33, 44);
- List<String> expectedStringList = Arrays.asList("first", "second");
- List<Integer> expectedTList = Arrays.asList(110, 111, 101);
-
- assertEquals(expectedIntegerList, result.integerList);
- assertEquals(expectedStringList, result.stringList);
- assertEquals(expectedTList, result.tVar);
- }
-
- @Test
- public void testAdaptObjectInCollection() throws Exception {
- JsonbAdapter<?, ?>[] adapters = {new BoxToCrateCompatibleGenericsAdapter<Integer>() {
- }};
- jsonb = JsonbBuilder.create(new JsonbConfig().setProperty(JsonbConfig.ADAPTERS, adapters));
-
- AdaptedPojo<Integer> pojo = new AdaptedPojo<>();
-
- pojo.tGenericBoxList = new ArrayList<>();
- pojo.tGenericBoxList.add(new GenericBox<>("GEN_BOX_STR_1", 110));
- pojo.tGenericBoxList.add(new GenericBox<>("GEN_BOX_STR_2", 101));
-
- String marshalledJson = jsonb.toJson(pojo, new TestTypeToken<AdaptedPojo<Integer>>(){}.getType());
- assertEquals("{\"tGenericBoxList\":[{\"adaptedT\":110,\"crateStrField\":\"GEN_BOX_STR_1\"},{\"adaptedT\":101,\"crateStrField\":\"GEN_BOX_STR_2\"}]}", marshalledJson);
-
- String toUnmarshall = "{\"integerList\":[11,22,33,44],\"stringList\":[\"first\",\"second\"]," +
- "\"tGenericBoxList\":[{\"crateStrField\":\"FirstCrate\",\"adaptedT\":11},{\"crateStrField\":\"SecondCrate\",\"adaptedT\":22}]}";
-
- AdaptedPojo<Integer> result = jsonb.fromJson(toUnmarshall, new TestTypeToken<AdaptedPojo<Integer>>(){}.getType());
- assertEquals("FirstCrate", result.tGenericBoxList.get(0).getStrField());
- assertEquals("SecondCrate", result.tGenericBoxList.get(1).getStrField());
- assertEquals(Integer.valueOf(11), result.tGenericBoxList.get(0).getX());
- assertEquals(Integer.valueOf(22), result.tGenericBoxList.get(1).getX());
- }
-
- @Test
- public void testAdaptTypeIntoCollection() throws Exception {
-
- JsonbAdapter<?, ?>[] adapters = {new JsonbAdapter<String, List<Integer>>() {
- @Override
- public List<Integer> adaptToJson(String s) {
- List<Integer> result = new ArrayList<>();
- for (String str : s.split(",")) {
- result.add(Integer.parseInt(str));
- }
- return result;
- }
-
- @Override
- public String adaptFromJson(List<Integer> ints) {
- StringBuilder sb = new StringBuilder();
- for (Integer i : ints) {
- if (!sb.toString().isEmpty()) {
- sb.append(",");
- }
- sb.append(i);
- }
- return sb.toString();
- }
- }
- };
- jsonb = JsonbBuilder.create(new JsonbConfig().setProperty(JsonbConfig.ADAPTERS, adapters));
-
- String json = "{\"strValues\":[11,22,33]}";
- final NonGenericPojo object = new NonGenericPojo();
- object.strValues = "11,22,33";
- assertEquals(json, jsonb.toJson(object));
- NonGenericPojo pojo = jsonb.fromJson(json, NonGenericPojo.class);
- assertEquals("11,22,33", pojo.strValues);
- }
-
- @Test
- public void testMarshallGenericField() throws Exception {
- JsonbAdapter<?, ?>[] adapters = {new BoxToCratePropagatedIntegerStringAdapter()};
- jsonb = JsonbBuilder.create(new JsonbConfig().setProperty(JsonbConfig.ADAPTERS, adapters));
-
- AdaptedPojo<Integer> adaptedPojo = new AdaptedPojo<>();
- adaptedPojo.tBox = new GenericBox<>("tGenBoxStrField", 22);
- adaptedPojo.intBox = new GenericBox<>("genBoxStrField", 11);
- String json = jsonb.toJson(adaptedPojo, new TestTypeToken<AdaptedPojo<Integer>>(){}.getType());
- assertEquals("{\"intBox\":{\"adaptedT\":{\"x\":[\"11\"]},\"crateStrField\":\"genBoxStrField\"},\"tBox\":{\"adaptedT\":{\"x\":[\"22\"]},\"crateStrField\":\"tGenBoxStrField\"}}", json);
-
- AdaptedPojo<Integer> unmarshalledAdaptedPojo = jsonb.fromJson(json, new TestTypeToken<AdaptedPojo<Integer>>(){}.getType());
- assertEquals("genBoxStrField", unmarshalledAdaptedPojo.intBox.getStrField());
- assertEquals(Integer.valueOf(11), unmarshalledAdaptedPojo.intBox.getX());
- }
-
- @Test
- public void testTypeVariable() throws Exception {
- JsonbAdapter<?, ?>[] adapters = {new JsonbAdapter<List<GenericBox<Double>>, BigDecimal>() {
- @Override
- public BigDecimal adaptToJson(List<GenericBox<Double>> genericBoxes) {
- return BigDecimal.valueOf(genericBoxes.get(0).getX());
- }
-
- @Override
- public List<GenericBox<Double>> adaptFromJson(BigDecimal bigDecimal) {
- List<GenericBox<Double>> list = new ArrayList<>();
- list.add(new GenericBox<>("", bigDecimal.doubleValue()));
- return list;
- }
- }};
- jsonb = JsonbBuilder.create(new JsonbConfig().setProperty(JsonbConfig.ADAPTERS, adapters));
-
- AdaptedPojo<List<GenericBox<Double>>> intBoxPojo = new AdaptedPojo<>();
- List<GenericBox<Double>> intBoxList = new ArrayList<>();
- intBoxList.add(new GenericBox<>("", 11d));
- intBoxPojo.tVar = intBoxList;
-
- String json = jsonb.toJson(intBoxPojo, new TestTypeToken<AdaptedPojo<List<GenericBox<Double>>>>(){}.getType());
- assertEquals("{\"tVar\":11.0}", json);
-
- AdaptedPojo<List<GenericBox<Double>>> result = jsonb.fromJson(json, new TestTypeToken<AdaptedPojo<List<GenericBox<Double>>>>(){}.getType());
- assertEquals(Double.valueOf(11), result.tVar.get(0).getX());
- }
-
- @Test
- public void testAdaptRoot() throws Exception {
-
- JsonbAdapter<?, ?>[] adapters = {new JsonbAdapter<Box, Crate>() {
- @Override
- public Crate adaptToJson(Box box) {
- return new Crate(box.getBoxStrField(), box.getBoxIntegerField());
- }
-
- @Override
- public Box adaptFromJson(Crate crate) {
- return new Box(crate.getCrateStrField(), crate.getCrateIntField());
- }
- }};
- jsonb = JsonbBuilder.create(new JsonbConfig().setProperty(JsonbConfig.ADAPTERS, adapters));
-
- Box pojo = new Box("BOX_STR", 101);
- String marshalledJson = jsonb.toJson(pojo);
- assertEquals("{\"crateIntField\":101,\"crateStrField\":\"BOX_STR\"}", marshalledJson);
-
- Box result = jsonb.fromJson("{\"crateIntField\":110,\"crateStrField\":\"CRATE_STR\"}", Box.class);
- assertEquals("CRATE_STR", result.getBoxStrField());
- assertEquals(Integer.valueOf(110), result.getBoxIntegerField());
- }
-
- @Test
- public void testAdaptMapString() throws Exception {
-
- JsonbAdapter<?, ?>[] adapters = {new JsonbAdapter<Map<String, Integer>, String>() {
- @Override
- public Map<String, Integer> adaptFromJson(String obj) throws Exception {
- final HashMap<String, Integer> result = new HashMap<>();
- result.put("fake", 101);
- return result;
- }
-
- @Override
- public String adaptToJson(Map<String, Integer> obj) throws Exception {
- StringBuilder sb = new StringBuilder();
- for (Map.Entry<String, Integer> entry : obj.entrySet()) {
- if (sb.length() > 0) {
- sb.append("#");
- }
- sb.append(entry.getKey()).append("-").append(entry.getValue());
- }
- return sb.toString();
- }
- }};
- jsonb = JsonbBuilder.create(new JsonbConfig().setProperty(JsonbConfig.ADAPTERS, adapters));
-
- AdaptedPojo<Integer> pojo = new AdaptedPojo();
- pojo.stringIntegerMap = new HashMap<>();
- pojo.stringIntegerMap.put("first", 11);
- pojo.stringIntegerMap.put("second", 22);
- pojo.tMap = new HashMap<>(pojo.stringIntegerMap);
- String marshalledJson = jsonb.toJson(pojo, new AdaptedPojo<Integer>(){}.getClass());
- assertEquals("{\"stringIntegerMap\":\"first-11#second-22\",\"tMap\":\"first-11#second-22\"}", marshalledJson);
-
- AdaptedPojo<Integer> result = jsonb.fromJson("{\"stringIntegerMap\":\"fake-value\",\"tMap\":\"fake-value\"}", new TestTypeToken<AdaptedPojo<Integer>>(){}.getType());
- assertEquals(Integer.valueOf(101), result.stringIntegerMap.get("fake"));
- assertEquals(Integer.valueOf(101), result.tMap.get("fake"));
- }
-
- @Test
- public void testAdaptMapToObject() throws Exception {
- JsonbAdapter<?, ?>[] adapters = {new JsonbAdapter<Map<String, String>, Crate>() {
- @Override
- public Map<String, String> adaptFromJson(Crate obj) throws Exception {
- final HashMap<String, String> fake = new HashMap<>();
- fake.put("fake", "11");
- return fake;
- }
-
- @Override
- public Crate adaptToJson(Map<String, String> obj) throws Exception {
- final Map.Entry<String, String> next = obj.entrySet().iterator().next();
- return new Crate(next.getKey(), Integer.parseInt(next.getValue()));
- }
- }};
- jsonb = JsonbBuilder.create(new JsonbConfig().setProperty(JsonbConfig.ADAPTERS, adapters));
-
- AdaptedPojo<String> pojo = new AdaptedPojo<>();
- pojo.tMap = new HashMap<>();
- pojo.tMap.put("first", "101");
-
- TestTypeToken<AdaptedPojo<String>> typeToken = new TestTypeToken<AdaptedPojo<String>>() {};
-
- String marshalledJson = jsonb.toJson(pojo, typeToken.getType());
- assertEquals("{\"tMap\":{\"crateIntField\":101,\"crateStrField\":\"first\"}}", marshalledJson);
-
- AdaptedPojo<String> result = jsonb.fromJson("{\"tMap\":{\"crateIntField\":101,\"crateStrField\":\"first\"}}", typeToken.getType());
- assertEquals("11", result.tMap.get("fake"));
- }
-
- @Test
- public void testAdaptJsonObject() {
- jsonb = JsonbBuilder.create();
- JsonObjectPojo pojo = new JsonObjectPojo();
- pojo.box = new Box("strFieldValue", 110);
-
- String json = jsonb.toJson(pojo);
- assertEquals("{\"box\":{\"boxStrField\":\"strFieldValue\",\"boxIntegerField\":110}}", json);
-
- JsonObjectPojo result = jsonb.fromJson(json, JsonObjectPojo.class);
- assertEquals("strFieldValue", result.box.getBoxStrField());
- assertEquals(Integer.valueOf(110), result.box.getBoxIntegerField());
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/adapters/JsonbTypeAdapterTest.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/adapters/JsonbTypeAdapterTest.java
deleted file mode 100644
index e8e25d9..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/adapters/JsonbTypeAdapterTest.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.adapters;
-
-import org.eclipse.persistence.json.bind.TestTypeToken;
-import org.eclipse.persistence.json.bind.adapters.model.Box;
-import org.eclipse.persistence.json.bind.adapters.model.BoxToCratePropagatedIntegerStringAdapter;
-import org.eclipse.persistence.json.bind.adapters.model.GenericBox;
-import org.junit.Before;
-import org.junit.Test;
-
-import javax.json.bind.Jsonb;
-import javax.json.bind.JsonbBuilder;
-import javax.json.bind.JsonbException;
-import javax.json.bind.adapter.JsonbAdapter;
-import javax.json.bind.annotation.JsonbTypeAdapter;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-/**
- * @author Roman Grigoriadi
- */
-public class JsonbTypeAdapterTest {
-
- private Jsonb jsonb;
-
- public static class BoxToStringAdapter implements JsonbAdapter<Box, String> {
-
- @Override
- public Box adaptFromJson(String obj) throws Exception {
- String[] strs = obj.split(":");
- return new Box(strs[0], Integer.parseInt(strs[1]));
- }
-
- @Override
- public String adaptToJson(Box obj) throws Exception {
- return obj.getBoxStrField()+":"+obj.getBoxIntegerField();
- }
- }
-
- public static class IncompatibleAdapterPojo<T,X> {
-
- @JsonbTypeAdapter(BoxToStringAdapter.class)
- public String str;
-
- }
-
- public static class AnnotatedPojo<T,X> {
-
- @JsonbTypeAdapter(BoxToStringAdapter.class)
- public Box box;
- @JsonbTypeAdapter(BoxToCratePropagatedIntegerStringAdapter.class)
- public GenericBox<T> tBox;
- @JsonbTypeAdapter(BoxToCratePropagatedIntegerStringAdapter.class)
- public GenericBox<X> xBox;
- }
-
- @Before
- public void setUp() throws Exception {
- jsonb = JsonbBuilder.create();
- }
-
- @Test
- public void testIncompatibleAdapter() throws Exception {
-
- IncompatibleAdapterPojo incompatibleAdapterFieldPojo = new IncompatibleAdapterPojo();
- incompatibleAdapterFieldPojo.str = "STR";
- try {
- jsonb.toJson(incompatibleAdapterFieldPojo);
- fail();
- } catch (JsonbException e) {
- assertTrue(e.getMessage().startsWith("Adapter of runtime type class"));
- assertTrue(e.getMessage().contains("does not match property type "));
- }
-
- }
-
- @Test
- public void testGenericFieldsMatch() throws Exception {
- AnnotatedPojo<Integer, String> annotatedPojo = new AnnotatedPojo<>();
- annotatedPojo.tBox = new GenericBox<>("T_BOX", 110);
- annotatedPojo.xBox = new GenericBox<>("X_BOX", "STR");
- String marshalledJson = jsonb.toJson(annotatedPojo, new TestTypeToken<AnnotatedPojo<Integer, String>>(){}.getType());
- assertEquals("{\"tBox\":{\"adaptedT\":{\"x\":[\"110\"]},\"crateStrField\":\"T_BOX\"},\"xBox\":{\"strField\":\"X_BOX\",\"x\":\"STR\"}}", marshalledJson);
-
- AnnotatedPojo<Integer,String> result = jsonb.fromJson("{\"tBox\":{\"crateStrField\":\"T_BOX\",\"adaptedT\":{\"x\":[\"110\"]}},\"xBox\":{\"strField\":\"X_BOX\",\"x\":\"STR\"}}", new TestTypeToken<AnnotatedPojo<Integer,String>>(){}.getType());
- assertEquals("T_BOX", result.tBox.getStrField());
- assertEquals(Integer.valueOf(110), result.tBox.getX());
- assertEquals("X_BOX", result.xBox.getStrField());
- assertEquals("STR", result.xBox.getX());
- }
-
- @Test
- public void testAnnotatedTbox() throws Exception {
-
- AnnotatedPojo pojo = new AnnotatedPojo();
- pojo.box = new Box("STR", 101);
- String marshalledJson = jsonb.toJson(pojo);
- assertEquals("{\"box\":\"STR:101\"}", marshalledJson);
-
- AnnotatedPojo<?, ?> result = jsonb.fromJson("{\"box\":\"STR:110\"}", AnnotatedPojo.class);
- assertEquals("STR", result.box.getBoxStrField());
- assertEquals(Integer.valueOf(110), result.box.getBoxIntegerField());
- }
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/adapters/PolymorphismAdapterTest.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/adapters/PolymorphismAdapterTest.java
deleted file mode 100644
index af60761..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/adapters/PolymorphismAdapterTest.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.adapters;
-
-
-import org.eclipse.persistence.json.bind.internal.properties.MessageKeys;
-import org.eclipse.persistence.json.bind.internal.properties.Messages;
-import org.eclipse.persistence.json.bind.model.PolymorphismAdapter;
-import org.junit.Test;
-
-import javax.json.bind.Jsonb;
-import javax.json.bind.JsonbBuilder;
-import javax.json.bind.JsonbConfig;
-import javax.json.bind.JsonbException;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-
-/**
- * Testing polymorphic adapters.
- *
- * @author Roman Grigoriadi
- */
-public class PolymorphismAdapterTest {
-
- public static class AnimalAdapter extends PolymorphismAdapter<Animal> {
- public AnimalAdapter() {
- super(Dog.class, Cat.class);
- }
- }
-
- public static class Animal {
- public String name;
- }
-
- public static class Dog extends Animal {
- public String dogProperty;
- }
-
- public static class Cat extends Animal {
- public String catProperty;
- }
-
- public static class Pojo {
- public Animal animal;
-
- public List<Animal> listOfAnimals = new ArrayList<>();
- }
-
-
- @Test
- public void testPolymorphic() {
- Dog dog = new Dog();
- dog.name = "Ralph";
- dog.dogProperty = "Property of a Dog.";
- Pojo pojo = new Pojo();
- pojo.animal = dog;
-
- Cat cat = new Cat();
- cat.name = "Snowball";
- cat.catProperty = "Property of a Cat.";
- pojo.listOfAnimals.add(cat);
- pojo.listOfAnimals.add(dog);
-
- final String expected = "{\"animal\":{\"className\":\"org.eclipse.persistence.json.bind.adapters.PolymorphismAdapterTest$Dog\",\"instance\":{\"name\":\"Ralph\",\"dogProperty\":\"Property of a Dog.\"}},\"listOfAnimals\":[{\"className\":\"org.eclipse.persistence.json.bind.adapters.PolymorphismAdapterTest$Cat\",\"instance\":{\"name\":\"Snowball\",\"catProperty\":\"Property of a Cat.\"}},{\"className\":\"org.eclipse.persistence.json.bind.adapters.PolymorphismAdapterTest$Dog\",\"instance\":{\"name\":\"Ralph\",\"dogProperty\":\"Property of a Dog.\"}}]}";
-
- JsonbConfig config = new JsonbConfig();
- config.withAdapters(new AnimalAdapter());
-// config.withFormatting(true);
- Jsonb jsonb = JsonbBuilder.create(config);
- String json = jsonb.toJson(pojo);
-
- assertEquals(expected, json);
-
- Pojo result = jsonb.fromJson(expected, Pojo.class);
- assertEquals(Dog.class, result.animal.getClass());
- assertEquals("Ralph", result.animal.name);
- assertEquals("Property of a Dog.", ((Dog)result.animal).dogProperty);
- assertEquals(2, result.listOfAnimals.size());
- assertEquals(Cat.class, result.listOfAnimals.get(0).getClass());
- assertEquals("Snowball", result.listOfAnimals.get(0).name);
- assertEquals("Property of a Cat.", ((Cat)result.listOfAnimals.get(0)).catProperty);
- assertEquals(Dog.class, result.listOfAnimals.get(1).getClass());
- assertEquals("Ralph", result.listOfAnimals.get(1).name);
- assertEquals("Property of a Dog.", ((Dog)result.listOfAnimals.get(1)).dogProperty);
-
- /*
- Produces following JSON:
- {
- "animal":{
- "className":"org.eclipse.persistence.json.bind.adapters.PolymorphismAdapterTest$Dog",
- "instance":{
- "name":"Ralph",
- "dogProperty":"Property of a Dog."
- }
- },
- "listOfAnimals":[
- {
- "className":"org.eclipse.persistence.json.bind.adapters.PolymorphismAdapterTest$Cat",
- "instance":{
- "name":"Snowball",
- "catProperty":"Property of a Cat."
- }
- },
- {
- "className":"org.eclipse.persistence.json.bind.adapters.PolymorphismAdapterTest$Dog",
- "instance":{
- "name":"Ralph",
- "dogProperty":"Property of a Dog."
- }
- }
- ]
- }
- */
- }
-
- /**
- * Tests class load not allowed exception.
- */
- @Test()
- public void testClassLoadNotAllowed() {
- final String expected = "{\"animal\":{\"className\":\"org.eclipse.persistence.json.bind.adapters.PolymorphismAdapterTest$Dog\",\"instance\":{\"name\":\"Ralph\",\"dogProperty\":\"Property of a Dog.\"}},\"listOfAnimals\":[{\"className\":\"org.eclipse.persistence.json.bind.adapters.PolymorphismAdapterTest$Cat\",\"instance\":{\"name\":\"Snowball\",\"catProperty\":\"Property of a Cat.\"}},{\"className\":\"org.eclipse.persistence.json.bind.adapters.PolymorphismAdapterTest$Dog\",\"instance\":{\"name\":\"Ralph\",\"dogProperty\":\"Property of a Dog.\"}}]}";
-
- JsonbConfig config = new JsonbConfig();
- config.withAdapters(new PolymorphismAdapter<Animal>(Cat.class){}); //Dog.class missing and allowed classes are not empty.
-// config.withFormatting(true);
- Jsonb jsonb = JsonbBuilder.create(config);
-
- try {
- Pojo pojo = jsonb.fromJson(expected, Pojo.class);
- fail("Should throw class load not allowed");
- } catch (JsonbException e) {
- assertEquals(Messages.getMessage(MessageKeys.CLASS_LOAD_NOT_ALLOWED, Dog.class.getName()), e.getCause().getMessage());
- }
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/adapters/model/AdaptedPojo.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/adapters/model/AdaptedPojo.java
deleted file mode 100644
index 88e9660..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/adapters/model/AdaptedPojo.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.adapters.model;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Roman Grigoriadi
- */
-public class AdaptedPojo<T> {
- public String strField;
- public Integer intField;
- public Box box;
- public GenericBox<Integer> intBox;
- public GenericBox<String> strBox;
- public GenericBox<T> tBox;
- public List<GenericBox<T>> tGenericBoxList;
- public List<Integer> integerList;
- public List<String> stringList;
- public Map<String, Integer> stringIntegerMap;
- public Map<String, T> tMap;
- public T tVar;
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/adapters/model/Box.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/adapters/model/Box.java
deleted file mode 100644
index 2acf7da..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/adapters/model/Box.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.adapters.model;
-
-/**
- * @author Roman Grigoriadi
- */
-public class Box {
-
- private String boxStrField;
-
- private Integer boxIntegerField;
-
- public Box() {
- }
-
- public Box(String boxStrField, Integer boxIntegerField) {
- this.boxStrField = boxStrField;
- this.boxIntegerField = boxIntegerField;
- }
-
- public String getBoxStrField() {
- return boxStrField;
- }
-
- public void setBoxStrField(String boxStrField) {
- this.boxStrField = boxStrField;
- }
-
- public Integer getBoxIntegerField() {
- return boxIntegerField;
- }
-
- public void setBoxIntegerField(Integer boxIntegerField) {
- this.boxIntegerField = boxIntegerField;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/adapters/model/BoxToCrateCompatibleGenericsAdapter.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/adapters/model/BoxToCrateCompatibleGenericsAdapter.java
deleted file mode 100644
index 6e3e1a4..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/adapters/model/BoxToCrateCompatibleGenericsAdapter.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.adapters.model;
-
-import javax.json.bind.adapter.JsonbAdapter;
-
-/**
- * @author Roman Grigoriadi
- */
-public abstract class BoxToCrateCompatibleGenericsAdapter<T> implements JsonbAdapter<GenericBox<T>,GenericCrate<T>> {
-
- @Override
- public GenericCrate<T> adaptToJson(GenericBox<T> tGenericBox) {
- GenericCrate<T> genericCrate = new GenericCrate<>();
- genericCrate.setCrateStrField(tGenericBox.getStrField());
- genericCrate.setT(tGenericBox.getX());
- return genericCrate;
- }
-
- @Override
- public GenericBox<T> adaptFromJson(GenericCrate<T> tGenericCrate) {
- GenericBox<T> genericBox = new GenericBox<>();
- genericBox.setStrField(tGenericCrate.getCrateStrField());
- genericBox.setX(tGenericCrate.getT());
- return genericBox;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/adapters/model/BoxToCratePropagatedIntegerStringAdapter.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/adapters/model/BoxToCratePropagatedIntegerStringAdapter.java
deleted file mode 100644
index 62a311d..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/adapters/model/BoxToCratePropagatedIntegerStringAdapter.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.adapters.model;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Roman Grigoriadi
- */
-public class BoxToCratePropagatedIntegerStringAdapter extends BoxToCratePropagatedTypeArgsAdapter<Integer, String> {
- @Override
- public GenericCrate<GenericBox<List<String>>> adaptToJson(GenericBox<Integer> integerGenericBox) {
- if (integerGenericBox == null) {
- return null;
- }
- GenericCrate<GenericBox<List<String>>> crate = new GenericCrate<>();
- crate.setCrateStrField(integerGenericBox.getStrField());
- crate.setT(new GenericBox<>());
- crate.getT().setX(new ArrayList<>());
- crate.getT().getX().add(integerGenericBox.getX().toString());
- return crate;
- }
-
- @Override
- public GenericBox<Integer> adaptFromJson(GenericCrate<GenericBox<List<String>>> boxGenericCrate) {
- if (boxGenericCrate == null) {
- return null;
- }
- GenericBox<Integer> genericBox = new GenericBox<>();
- genericBox.setStrField(boxGenericCrate.getCrateStrField());
- genericBox.setX(Integer.parseInt(boxGenericCrate.getT().getX().get(0)));
- return genericBox;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/adapters/model/BoxToCratePropagatedTypeArgsAdapter.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/adapters/model/BoxToCratePropagatedTypeArgsAdapter.java
deleted file mode 100644
index fd031fd..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/adapters/model/BoxToCratePropagatedTypeArgsAdapter.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.adapters.model;
-
-import javax.json.bind.adapter.JsonbAdapter;
-
-import java.util.List;
-
-/**
- * @author Roman Grigoriadi
- */
-public abstract class BoxToCratePropagatedTypeArgsAdapter<T,X> implements JsonbAdapter<GenericBox<T>, GenericCrate<GenericBox<List<X>>>> {
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/adapters/model/BoxToJsonObjectAdapter.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/adapters/model/BoxToJsonObjectAdapter.java
deleted file mode 100644
index f6e609f..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/adapters/model/BoxToJsonObjectAdapter.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.adapters.model;
-
-import javax.json.JsonObject;
-import javax.json.JsonObjectBuilder;
-import javax.json.bind.adapter.JsonbAdapter;
-import javax.json.spi.JsonProvider;
-
-/**
- * @author Roman Grigoriadi
- */
-public class BoxToJsonObjectAdapter implements JsonbAdapter<Box, JsonObject> {
- @Override
- public JsonObject adaptToJson(Box obj) throws Exception {
- final JsonObjectBuilder builder = JsonProvider.provider().createObjectBuilder();
- builder.add("boxStrField", obj.getBoxStrField());
- builder.add("boxIntegerField", obj.getBoxIntegerField());
- return builder.build();
- }
-
- @Override
- public Box adaptFromJson(JsonObject jsonObj) throws Exception {
- Box box = new Box();
- box.setBoxStrField(jsonObj.getString("boxStrField"));
- box.setBoxIntegerField(jsonObj.getInt("boxIntegerField"));
- return box;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/adapters/model/Crate.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/adapters/model/Crate.java
deleted file mode 100644
index 63607ad..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/adapters/model/Crate.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.adapters.model;
-
-/**
- * @author Roman Grigoriadi
- */
-public class Crate {
-
- private String crateStrField;
-
- private Integer crateIntField;
-
- public Crate() {
- }
-
- public Crate(String crateStrField, Integer crateIntField) {
- this.crateStrField = crateStrField;
- this.crateIntField = crateIntField;
- }
-
- public String getCrateStrField() {
- return crateStrField;
- }
-
- public void setCrateStrField(String crateStrField) {
- this.crateStrField = crateStrField;
- }
-
- public Integer getCrateIntField() {
- return crateIntField;
- }
-
- public void setCrateIntField(Integer crateIntField) {
- this.crateIntField = crateIntField;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/adapters/model/GenericBox.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/adapters/model/GenericBox.java
deleted file mode 100644
index 9291991..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/adapters/model/GenericBox.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.adapters.model;
-
-/**
- * @author Roman Grigoriadi
- */
-public class GenericBox<X> {
-
- private String strField;
-
- private X x;
-
- public GenericBox(String strField, X x) {
- this.strField = strField;
- this.x = x;
- }
-
- public GenericBox() {
- }
-
- public X getX() {
- return x;
- }
-
- public String getStrField() {
- return strField;
- }
-
- public void setStrField(String strField) {
- this.strField = strField;
- }
-
- public void setX(X x) {
- this.x = x;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/adapters/model/GenericCrate.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/adapters/model/GenericCrate.java
deleted file mode 100644
index d404a1d..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/adapters/model/GenericCrate.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.adapters.model;
-
-import javax.json.bind.annotation.JsonbProperty;
-
-/**
- * @author Roman Grigoriadi
- */
-public class GenericCrate<T> {
-
- private String crateStrField;
-
- @JsonbProperty("adaptedT")
- private T t;
-
- public GenericCrate(String crateStrField, T t) {
- this.crateStrField = crateStrField;
- this.t = t;
- }
-
- public GenericCrate() {
- }
-
- public String getCrateStrField() {
- return crateStrField;
- }
-
- public T getT() {
- return t;
- }
-
- public void setCrateStrField(String crateStrField) {
- this.crateStrField = crateStrField;
- }
-
- public void setT(T t) {
- this.t = t;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/adapters/model/IntegerListToStringAdapter.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/adapters/model/IntegerListToStringAdapter.java
deleted file mode 100644
index 4e5bab7..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/adapters/model/IntegerListToStringAdapter.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.adapters.model;
-
-import javax.json.bind.adapter.JsonbAdapter;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Roman Grigoriadi
- */
-public class IntegerListToStringAdapter implements JsonbAdapter<List<Integer>, String> {
-
- @Override
- public String adaptToJson(List<Integer> integers) {
- StringBuilder sb = new StringBuilder();
- for (Integer integer : integers) {
- if (!sb.toString().isEmpty()) {
- sb.append("#");
- }
- sb.append(integer);
- }
- return sb.toString();
- }
-
- @Override
- public List<Integer> adaptFromJson(String s) {
- String[] items = s.split("#");
- List<Integer> integerList = new ArrayList<>();
- for (String item : items) {
- integerList.add(Integer.parseInt(item));
- }
- return integerList;
- }
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/adapters/model/JsonObjectPojo.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/adapters/model/JsonObjectPojo.java
deleted file mode 100644
index abc67f4..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/adapters/model/JsonObjectPojo.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.adapters.model;
-
-import javax.json.bind.annotation.JsonbTypeAdapter;
-
-/**
- * @author Roman Grigoriadi
- */
-public class JsonObjectPojo {
-
- @JsonbTypeAdapter(BoxToJsonObjectAdapter.class)
- public Box box;
-
- public GenericBox<Box> genericBox;
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/AnnotationInheritanceTest.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/AnnotationInheritanceTest.java
deleted file mode 100644
index 3b3d829..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/AnnotationInheritanceTest.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization;
-
-import org.eclipse.persistence.json.bind.customization.model.InheritedAnnotationsPojo;
-import org.junit.Test;
-
-import javax.json.bind.Jsonb;
-import javax.json.bind.JsonbBuilder;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * @author Roman Grigoriadi
- */
-public class AnnotationInheritanceTest {
-
- @Test
- public void testAnnotationInheritance() {
- InheritedAnnotationsPojo pojo = new InheritedAnnotationsPojo();
- String expectedJson = "{\"renamedProperty\":null}";
- final Jsonb jsonb = JsonbBuilder.create();
- assertEquals(expectedJson, jsonb.toJson(pojo));
-
- InheritedAnnotationsPojo result = jsonb.fromJson("{\"renamedProperty\":\"abc\"}", InheritedAnnotationsPojo.class);
- assertEquals("abc", result.property);
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/EncodingTest.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/EncodingTest.java
deleted file mode 100644
index c8170c4..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/EncodingTest.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization;
-
-import org.eclipse.persistence.json.bind.TestTypeToken;
-import org.junit.Test;
-
-import javax.json.bind.Jsonb;
-import javax.json.bind.JsonbBuilder;
-import javax.json.bind.JsonbConfig;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.ResourceBundle;
-import java.util.logging.Logger;
-
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-
-/**
- * Tests encoding to JSONP propagation
- *
- * @author Roman Grigoriadi
- */
-public class EncodingTest {
-
- private static final Logger logger = Logger.getLogger(EncodingTest.class.getName());
-
- private static final String[] CZECH;
- private static final String[] RUSSIAN;
-
-
- static {
- ResourceBundle messages = ResourceBundle.getBundle("messages");
- CZECH = messages.getString("czechDiacritics").split(",");
- RUSSIAN = messages.getString("russianDiacritics").split(",");
- }
-
- @Test
- public void testCP1250Encoding() throws UnsupportedEncodingException {
- testMarshaller(CZECH, "cp1250");
- testUnmarshaller(CZECH, "cp1250");
- }
-
- @Test
- public void testUTF8Encoding() throws UnsupportedEncodingException {
- testMarshaller(CZECH, "UTF-8");
- testUnmarshaller(CZECH, "UTF-8");
- testMarshaller(RUSSIAN, "UTF-8");
- testUnmarshaller(RUSSIAN, "UTF-8");
- }
-
- @Test
- public void testcp1251Encoding() throws UnsupportedEncodingException {
- testMarshaller(RUSSIAN, "cp1251");
- testUnmarshaller(RUSSIAN, "cp1251");
- }
-
- private void testMarshaller(String[] input, String encoding) throws UnsupportedEncodingException {
- JsonbConfig config = new JsonbConfig().withEncoding(encoding);
- final Jsonb jsonb = JsonbBuilder.create(config);
-
- List<String> strings = Arrays.asList(input);
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- jsonb.toJson(strings, baos);
- String marshallerResult = baos.toString(encoding);
- logger.finest("Marshaller JSON result: "+marshallerResult);
- assertEquals(diacriticsToJsonArray(input), marshallerResult);
- }
-
- private void testUnmarshaller(String[] input, String encoding) throws UnsupportedEncodingException {
- JsonbConfig config = new JsonbConfig().withEncoding(encoding);
- final Jsonb jsonb = JsonbBuilder.create(config);
-
- String json = diacriticsToJsonArray(input);
- logger.finest("JSON for unmarshaller: "+json);
- InputStream bis = new ByteArrayInputStream(json.getBytes(encoding));
- ArrayList<String> result = jsonb.fromJson(bis, new TestTypeToken<ArrayList<String>>(){}.getType());
- assertArrayEquals(input, result.toArray(new String[result.size()]));
- }
-
- private String diacriticsToJsonArray(String[] diacritics) {
- StringBuilder sb = new StringBuilder();
- sb.append("[");
- for (String str : diacritics) {
- sb.append("\"").append(str).append("\",");
- }
- sb.deleteCharAt(sb.length() - 1);
- sb.append("]");
- return sb.toString();
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/InterfaceAnnotationsTest.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/InterfaceAnnotationsTest.java
deleted file mode 100644
index 89e792d..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/InterfaceAnnotationsTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization;
-
-import org.eclipse.persistence.json.bind.customization.model.InterfacedPojoB;
-import org.eclipse.persistence.json.bind.customization.model.InterfacedPojoImpl;
-import org.junit.Test;
-
-import javax.json.bind.Jsonb;
-import javax.json.bind.JsonbBuilder;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * @author Roman Grigoriadi
- */
-public class InterfaceAnnotationsTest {
-
- @Test
- public void testJsonbPropertyIfcInheritance() {
- InterfacedPojoB pojo = new InterfacedPojoImpl();
- pojo.setPropertyA("AA");
- pojo.setPropertyB("BB");
-
- final Jsonb jsonb = JsonbBuilder.create();
- final String json = "{\"propA\":\"AA\",\"propB\":\"BB\"}";
- assertEquals(json, jsonb.toJson(pojo));
- }
-
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/JsonbCreatorTest.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/JsonbCreatorTest.java
deleted file mode 100644
index 798d8f3..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/JsonbCreatorTest.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization;
-
-import org.eclipse.persistence.json.bind.customization.model.CreatorConstructorPojo;
-import org.eclipse.persistence.json.bind.customization.model.CreatorFactoryMethodPojo;
-import org.eclipse.persistence.json.bind.customization.model.CreatorIncompatibleTypePojo;
-import org.eclipse.persistence.json.bind.customization.model.CreatorMultipleDeclarationErrorPojo;
-import org.junit.Test;
-
-import javax.json.bind.Jsonb;
-import javax.json.bind.JsonbBuilder;
-import javax.json.bind.JsonbException;
-import java.math.BigDecimal;
-
-import static org.junit.Assert.*;
-
-/**
- * @author Roman Grigoriadi
- */
-public class JsonbCreatorTest {
-
- @Test
- public void testRootConstructor() {
- String json = "{\"str1\":\"abc\",\"str2\":\"def\",\"bigDec\":25}";
- final Jsonb jsonb = JsonbBuilder.create();
- CreatorConstructorPojo pojo = jsonb.fromJson(json, CreatorConstructorPojo.class);
- assertEquals("abc", pojo.str1);
- assertEquals("def", pojo.str2);
- assertEquals(new BigDecimal("25"), pojo.bigDec);
- }
-
- @Test
- public void testRootFactoryMethod() {
- String json = "{\"str1\":\"abc\",\"str2\":\"def\",\"bigDec\":25}";
- final Jsonb jsonb = JsonbBuilder.create();
- CreatorFactoryMethodPojo pojo = jsonb.fromJson(json, CreatorFactoryMethodPojo.class);
- assertEquals("abc", pojo.str1);
- assertEquals("def", pojo.str2);
- assertEquals(new BigDecimal("25"), pojo.bigDec);
- }
-
- @Test
- public void testRootCreatorWithInnerCreator() {
- String json = "{\"str1\":\"abc\",\"str2\":\"def\",\"bigDec\":25, \"innerFactoryCreator\":{\"str1\":\"inn1\",\"str2\":\"inn2\",\"bigDec\":11}}";
- final Jsonb jsonb = JsonbBuilder.create();
- CreatorConstructorPojo pojo = jsonb.fromJson(json, CreatorConstructorPojo.class);
- assertEquals("abc", pojo.str1);
- assertEquals("def", pojo.str2);
- assertEquals(new BigDecimal("25"), pojo.bigDec);
-
- assertEquals("inn1", pojo.innerFactoryCreator.str1);
- assertEquals("inn2", pojo.innerFactoryCreator.str2);
- assertEquals(new BigDecimal("11"), pojo.innerFactoryCreator.bigDec);
- }
-
- @Test
- public void testIncompatibleFactoryMethodReturnType() {
- try {
- JsonbBuilder.create().fromJson("{\"s1\":\"abc\"}", CreatorIncompatibleTypePojo.class);
- fail();
- } catch (JsonbException e) {
- assertTrue(e.getMessage().startsWith("Return type of creator"));
- }
- }
-
- @Test
- public void testMultipleCreatorsError() {
-
- try {
- JsonbBuilder.create().fromJson("{\"s1\":\"abc\"}", CreatorMultipleDeclarationErrorPojo.class);
- fail();
- } catch (JsonbException e) {
- assertTrue(e.getMessage().startsWith("More than one @JsonbCreator"));
- }
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/JsonbNillableTest.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/JsonbNillableTest.java
deleted file mode 100644
index b188098..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/JsonbNillableTest.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization;
-
-import org.eclipse.persistence.json.bind.customization.model.JsonbNillableClassSecondLevel;
-import org.eclipse.persistence.json.bind.customization.model.JsonbNillableOverriddenWithJsonbProperty;
-import org.eclipse.persistence.json.bind.customization.model.JsonbNillableOverridesClass;
-import org.eclipse.persistence.json.bind.customization.model.JsonbNillableOverridesInterface;
-import org.eclipse.persistence.json.bind.customization.model.JsonbNillableValue;
-import org.eclipse.persistence.json.bind.customization.model.packagelevelannotations.JsonbNillablePackageLevel;
-import org.eclipse.persistence.json.bind.customization.model.packagelevelannotations.PackageLevelOverridenWithClassLevel;
-import org.junit.Before;
-import org.junit.Test;
-
-import javax.json.bind.Jsonb;
-import javax.json.bind.JsonbBuilder;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Tests a {@link javax.json.bind.annotation.JsonbNillable} annotation.
- * @author Roman Grigoriadi
- */
-public class JsonbNillableTest {
-
- private Jsonb jsonb;
-
- @Before
- public void setUp() throws Exception {
- jsonb = JsonbBuilder.create();
- }
-
- @Test
- public void testJsonbNillable() {
- JsonbNillableValue pojo = new JsonbNillableValue();
- assertEquals("{\"nillableField\":null}", jsonb.toJson(pojo));
- }
-
- @Test
- public void testJsonbNillableOverridenWithJsonbProperty() {
- JsonbNillableOverriddenWithJsonbProperty pojo = new JsonbNillableOverriddenWithJsonbProperty();
- assertEquals("{}", jsonb.toJson(pojo));
- }
-
- @Test
- public void testPackageLevelNillable() {
- JsonbNillablePackageLevel pojo = new JsonbNillablePackageLevel();
- assertEquals("{\"packageLevelNillableField\":null}", jsonb.toJson(pojo));
- }
-
- @Test
- public void testPackageLevelOverridenWithClassLevel() {
- PackageLevelOverridenWithClassLevel pojo = new PackageLevelOverridenWithClassLevel();
- assertEquals("{}", jsonb.toJson(pojo));
- }
-
- /**
- * Tests inheritance of annotations from interfaces.
- * @throws Exception
- */
- @Test
- public void testNillableInheritFromInterface() throws Exception {
- JsonbNillableClassSecondLevel pojo = new JsonbNillableClassSecondLevel();
- assertEquals("{\"classNillable\":null}", jsonb.toJson(pojo));
- }
-
- @Test
- public void testInheritanceOverride() throws Exception {
- JsonbNillableOverridesInterface overridesInterface = new JsonbNillableOverridesInterface();
- assertEquals("{}", jsonb.toJson(overridesInterface));
-
- JsonbNillableOverridesClass overridesClass = new JsonbNillableOverridesClass();
- assertEquals("{\"overridesNillableInParent\":null}", jsonb.toJson(overridesClass));
- }
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/JsonbPropertyTest.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/JsonbPropertyTest.java
deleted file mode 100644
index 6acec2c..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/JsonbPropertyTest.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization;
-
-import org.eclipse.persistence.json.bind.customization.model.JsonbPropertyName;
-import org.eclipse.persistence.json.bind.customization.model.JsonbPropertyNameCollision;
-import org.eclipse.persistence.json.bind.customization.model.JsonbPropertyNillable;
-import org.junit.Before;
-import org.junit.Test;
-
-import javax.json.bind.Jsonb;
-import javax.json.bind.JsonbBuilder;
-
-import static org.junit.Assert.*;
-
-/**
- * Tests parsing of {@link javax.json.bind.annotation.JsonbProperty} test.
- * @author Roman Grigoriadi
- */
-public class JsonbPropertyTest {
-
- private Jsonb jsonb;
-
- @Before
- public void setUp() throws Exception {
- jsonb = JsonbBuilder.create();
- }
-
- @Test
- public void testPropertyName() throws Exception {
-
- JsonbPropertyName pojo = new JsonbPropertyName();
- pojo.setFieldAnnotatedName("FIELD_ANNOTATED");
- pojo.setMethodAnnotName("METHOD_ANNOTATED");
- pojo.setFieldOverridedWithMethodAnnot("OVERRIDDEN_GETTER");
-
- assertEquals("{\"fieldAnnotatedNameCustomized\":\"FIELD_ANNOTATED\",\"getterAnnotatedName\":\"METHOD_ANNOTATED\",\"getterOverriddenName\":\"OVERRIDDEN_GETTER\"}",
- jsonb.toJson(pojo));
-
- String toUnmarshall = "{\"fieldAnnotatedNameCustomized\":\"FIELD_ANNOTATED\",\"setterOverriddenName\":\"OVERRIDDEN_GETTER\",\"setterAnnotatedName\":\"METHOD_ANNOTATED\"}";
- JsonbPropertyName result = jsonb.fromJson(toUnmarshall, JsonbPropertyName.class);
- assertEquals("FIELD_ANNOTATED", result.getFieldAnnotatedName());
- assertEquals("METHOD_ANNOTATED", result.getMethodAnnotName());
- assertEquals("OVERRIDDEN_GETTER", result.getFieldOverridedWithMethodAnnot());
- }
-
- @Test
- public void testNameCollision() {
- JsonbPropertyNameCollision nameCollisionPojo = new JsonbPropertyNameCollision();
- tryClash(()->jsonb.toJson(nameCollisionPojo));
- tryClash(()->jsonb.fromJson("{}", JsonbPropertyNameCollision.class));
- }
-
-
-
- private void tryClash(Runnable clashCommand) {
- try {
- clashCommand.run();
- fail();
- } catch (Exception e) {
- assertTrue(e.getMessage().startsWith("Property pojoName clashes with property pojoNameCollision"));
- }
- }
-
-
- @Test
- public void testPropertyNillable() {
- JsonbPropertyNillable pojo = new JsonbPropertyNillable();
- assertEquals("{\"nullField\":null}", jsonb.toJson(pojo));
- }
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/JsonbPropertyVisibilityStrategyTest.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/JsonbPropertyVisibilityStrategyTest.java
deleted file mode 100644
index f0b63cb..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/JsonbPropertyVisibilityStrategyTest.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization;
-
-import org.junit.Test;
-
-import javax.json.bind.Jsonb;
-import javax.json.bind.JsonbBuilder;
-import javax.json.bind.JsonbConfig;
-import javax.json.bind.annotation.JsonbVisibility;
-import javax.json.bind.config.PropertyVisibilityStrategy;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Tests custom {@link PropertyVisibilityStrategy}
- *
- * @author Roman Grigoriadi
- */
-public class JsonbPropertyVisibilityStrategyTest {
-
- public static class FieldPojo {
-
- private String afield;
- private String bfield;
- public String cfield;
- public String dfield;
-
- public FieldPojo(String afield, String bfield, String cfield, String dfield) {
- this.afield = afield;
- this.bfield = bfield;
- this.cfield = cfield;
- this.dfield = dfield;
- }
- }
-
- public static class GetterPojo {
- public String getAgetter() {
- return "avalue";
- }
- public String getBgetter() {
- return "bvalue";
- }
- private String getCgetter() {
- return "cvalue";
- }
- private String getDgetter() {
- return "dvalue";
- }
- }
-
- @JsonbVisibility(TestVisibilityStrategy.class)
- public static final class AnnotatedPojo {
-
- private String afield;
- private String bfield;
- public String cfield;
- public String dfield;
-
- public AnnotatedPojo(String afield, String bfield, String cfield, String dfield) {
- this.afield = afield;
- this.bfield = bfield;
- this.cfield = cfield;
- this.dfield = dfield;
- }
-
- public String getAgetter() {
- return "avalue";
- }
- public String getBgetter() {
- return "bvalue";
- }
- private String getCgetter() {
- return "cvalue";
- }
- private String getDgetter() {
- return "dvalue";
- }
- }
-
-
- public static final class TestVisibilityStrategy implements PropertyVisibilityStrategy {
- @Override
- public boolean isVisible(Field field) {
- final String fieldName = field.getName();
- return fieldName.equals("bfield") || fieldName.equals("cfield");
- }
-
- @Override
- public boolean isVisible(Method method) {
- final String methodName = method.getName();
- return methodName.equals("getBgetter") || methodName.equals("getCgetter");
- }
- }
-
- /**
- * Tests applying for both public and nonpublic fields.
- */
- @Test
- public void testFieldVisibilityStrategy() {
- JsonbConfig customizedConfig = new JsonbConfig();
- customizedConfig.setProperty(JsonbConfig.PROPERTY_VISIBILITY_STRATEGY, new PropertyVisibilityStrategy() {
- @Override
- public boolean isVisible(Field field) {
- final String fieldName = field.getName();
- return fieldName.equals("afield") || fieldName.equals("dfield");
- }
-
- @Override
- public boolean isVisible(Method method) {
- throw new IllegalStateException("Not supported");
- }
- });
-
- FieldPojo fieldPojo = new FieldPojo("avalue", "bvalue", "cvalue", "dvalue");
-
- Jsonb jsonb = JsonbBuilder.create(customizedConfig);
- assertEquals("{\"afield\":\"avalue\",\"dfield\":\"dvalue\"}", jsonb.toJson(fieldPojo));
- }
-
- /**
- * Tests applying for both public and nonpublic getters.
- */
- @Test
- public void testMethodVisibilityStrategy() {
- JsonbConfig customizedConfig = new JsonbConfig();
- customizedConfig.setProperty(JsonbConfig.PROPERTY_VISIBILITY_STRATEGY, new PropertyVisibilityStrategy() {
- @Override
- public boolean isVisible(Field field) {
- throw new IllegalStateException("Not supported");
- }
-
- @Override
- public boolean isVisible(Method method) {
- final String methodName = method.getName();
- return methodName.equals("getAgetter") || methodName.equals("getDgetter");
- }
- });
-
- GetterPojo getterPojo = new GetterPojo();
-
- Jsonb jsonb = JsonbBuilder.create(customizedConfig);
- assertEquals("{\"agetter\":\"avalue\",\"dgetter\":\"dvalue\"}", jsonb.toJson(getterPojo));
- }
-
- @Test
- public void testAnnotatedPojo() {
- final Jsonb jsonb = JsonbBuilder.create();
- AnnotatedPojo fieldPojo = new AnnotatedPojo("avalue", "bvalue", "cvalue", "dvalue");
- assertEquals("{\"bfield\":\"bvalue\",\"bgetter\":\"bvalue\",\"cfield\":\"cvalue\",\"cgetter\":\"cvalue\"}", jsonb.toJson(fieldPojo));
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/JsonbTransientTest.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/JsonbTransientTest.java
deleted file mode 100644
index 6735962..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/JsonbTransientTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization;
-
-import org.eclipse.persistence.json.bind.customization.model.JsonbTransientCollision;
-import org.eclipse.persistence.json.bind.customization.model.JsonbTransientValue;
-import org.junit.Before;
-import org.junit.Test;
-
-import javax.json.bind.Jsonb;
-import javax.json.bind.JsonbBuilder;
-import javax.json.bind.JsonbException;
-import javax.json.bind.annotation.JsonbProperty;
-
-import static org.junit.Assert.*;
-
-/**
- * @author Roman Grigoriadi
- */
-public class JsonbTransientTest {
-
- private Jsonb jsonb;
-
- @Before
- public void setUp() throws Exception {
- jsonb = JsonbBuilder.create();
- }
-
- @Test
- public void testJsonbTransientProperty() {
- JsonbTransientValue pojo = new JsonbTransientValue();
- pojo.setTransientProperty("TRANSIENT");
- pojo.setProperty("non transient");
-
- assertEquals("{\"property\":\"non transient\"}", jsonb.toJson(pojo));
- }
-
- @Test
- public void testTransientCollidesWithOtherAnnotation() throws Exception {
- JsonbTransientCollision pojo = new JsonbTransientCollision();
- try {
- jsonb.toJson(pojo);
- fail();
- } catch (JsonbException e) {
- assertTrue(e.getMessage().startsWith(String.format("JsonbTransient annotation collides with %s", JsonbProperty.class)));
- }
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/NumberFormatTest.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/NumberFormatTest.java
deleted file mode 100644
index 0808353..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/NumberFormatTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization;
-
-import org.eclipse.persistence.json.bind.customization.model.NumberFormatPojo;
-import org.junit.Test;
-
-import javax.json.bind.Jsonb;
-import javax.json.bind.JsonbBuilder;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Tests number format.
- * @author Roman Grigoriadi
- */
-public class NumberFormatTest {
- private Jsonb jsonb = JsonbBuilder.create();
-
-
-
- @Test
- public void testSerialize() {
- NumberFormatPojo pojo = new NumberFormatPojo();
- pojo.bigDecimal = BigDecimal.TEN;
- pojo.bigInteger = BigInteger.ONE;
- pojo.aDouble = .1d;
- pojo.aFloat = .35f;
- pojo.aLong = Long.MAX_VALUE;
- pojo.integer = Integer.MAX_VALUE;
- pojo.aShort = 1;
- pojo.aByte = 127;
-
- String expectedJson = "{\"aByte\":\"127\",\"aDouble\":\"000.10000000\",\"aFloat\":\"000.34999999\",\"aLong\":\"9223372036854775807\",\"aShort\":\"00001\",\"bigDecimal\":\"00000010.000000\",\"bigInteger\":\"00000001\",\"integer\":\"2147483647.0\"}";
-
- assertEquals(expectedJson, jsonb.toJson(pojo));
-
- }
-
- @Test
- public void testDeserialzier() {
- String expectedJson = "{\"aByte\":\"127\",\"aDouble\":\"000.10000000\",\"aFloat\":\"000.34999999\",\"aLong\":\"9223372036854775807\",\"aShort\":\"00001\",\"bigDecimal\":\"00000010.000000\",\"bigInteger\":\"00000001\",\"integer\":\"2147483647.0\"}";
- NumberFormatPojo pojo = jsonb.fromJson(expectedJson, NumberFormatPojo.class);
-
- assertEquals(BigDecimal.TEN, pojo.bigDecimal);
- assertEquals(BigInteger.ONE, pojo.bigInteger);
- assertEquals(new Byte((byte) 127), pojo.aByte);
- assertEquals(new Double(.1d), pojo.aDouble);
- assertEquals(new Float(.35f), pojo.aFloat);
- assertEquals((Integer)Integer.MAX_VALUE, pojo.integer);
- assertEquals(new Short((short) 1), pojo.aShort);
- assertEquals((Long)Long.MAX_VALUE, pojo.aLong);
- }
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/PrettyPrintTest.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/PrettyPrintTest.java
deleted file mode 100644
index 0a73046..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/PrettyPrintTest.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization;
-
-import org.junit.Test;
-
-import javax.json.bind.Jsonb;
-import javax.json.bind.JsonbBuilder;
-import javax.json.bind.JsonbConfig;
-import java.util.Arrays;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Tests pretty print to JSONP propagation
- *
- * @author Roman Grigoriadi
- */
-public class PrettyPrintTest {
-
- @Test
- public void testPrettyPrint() {
- final JsonbConfig config = new JsonbConfig();
- config.setProperty(JsonbConfig.FORMATTING, Boolean.TRUE);
- final Jsonb jsonb = JsonbBuilder.create(config);
- assertEquals("\n[\n \"first\",\n \"second\"\n]", jsonb.toJson(Arrays.asList("first", "second")));
- }
-
- @Test
- public void testPrettyPrintFalse() {
- final JsonbConfig config = new JsonbConfig();
- config.setProperty(JsonbConfig.FORMATTING, Boolean.FALSE);
- final Jsonb jsonb = JsonbBuilder.create(config);
- assertEquals("[\"first\",\"second\"]", jsonb.toJson(Arrays.asList("first", "second")));
- }
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/PropertyOrderTest.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/PropertyOrderTest.java
deleted file mode 100644
index 76b4a96..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/PropertyOrderTest.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization;
-
-import org.eclipse.persistence.json.bind.customization.model.FieldCustomOrder;
-import org.eclipse.persistence.json.bind.customization.model.FieldCustomOrderWrapper;
-import org.eclipse.persistence.json.bind.customization.model.FieldOrder;
-import org.eclipse.persistence.json.bind.customization.model.FieldOrderNameAnnotation;
-import org.eclipse.persistence.json.bind.customization.model.FieldSpecificOrder;
-import org.eclipse.persistence.json.bind.customization.model.JsonbTransientValue;
-import org.junit.Test;
-
-import javax.json.bind.Jsonb;
-import javax.json.bind.JsonbBuilder;
-import javax.json.bind.JsonbConfig;
-import javax.json.bind.config.PropertyOrderStrategy;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * @author Roman Grigoriadi
- */
-public class PropertyOrderTest {
-
- @Test
- public void testOrderingWithTransientField() {
- Jsonb jsonb = JsonbBuilder.create(new JsonbConfig().withPropertyOrderStrategy(PropertyOrderStrategy.LEXICOGRAPHICAL));
-
- final JsonbTransientValue pojo = new JsonbTransientValue();
- pojo.setProperty("propertyValue");
- String result = jsonb.toJson(pojo);
- System.out.println("result = " + result);
- }
-
- @Test
- public void testPropertySorting() {
- FieldOrder fieldOrder = new FieldOrder();
- Jsonb jsonb = JsonbBuilder.create(new JsonbConfig().withPropertyOrderStrategy(PropertyOrderStrategy.LEXICOGRAPHICAL));
- String expectedLexicographical = "{\"aField\":\"aValue\",\"bField\":\"bValue\",\"cField\":\"cValue\",\"dField\":\"dValue\"}";
- assertEquals(expectedLexicographical, jsonb.toJson(fieldOrder));
-
- jsonb = JsonbBuilder.create(new JsonbConfig().withPropertyOrderStrategy(PropertyOrderStrategy.REVERSE));
- String expectedReverse = "{\"dField\":\"dValue\",\"cField\":\"cValue\",\"bField\":\"bValue\",\"aField\":\"aValue\"}";
- assertEquals(expectedReverse, jsonb.toJson(fieldOrder));
- }
-
- @Test
- public void testPropertyCustomOrder() {
- FieldCustomOrder fieldCustomOrder = new FieldCustomOrder();
- Jsonb jsonb = JsonbBuilder.create(new JsonbConfig().withPropertyOrderStrategy(PropertyOrderStrategy.LEXICOGRAPHICAL));
- String expectedCustomOrder = "{\"aField\":\"aValue\",\"cField\":\"cValue\",\"dField\":\"dValue\",\"bField\":\"bValue\"}";
- assertEquals(expectedCustomOrder, jsonb.toJson(fieldCustomOrder));
-
- FieldCustomOrderWrapper fieldCustomOrderWrapper = new FieldCustomOrderWrapper();
- String expectedOrder = "{\"fieldCustomOrder\":{\"aField\":\"aValue\",\"cField\":\"cValue\",\"dField\":\"dValue\",\"bField\":\"bValue\"},\"intField\":1,\"stringField\":\"stringValue\"}";
- assertEquals(expectedOrder, jsonb.toJson(fieldCustomOrderWrapper));
- }
-
- @Test
- public void testPropertySetCustomOrder() {
- Jsonb jsonb = JsonbBuilder.create();
- FieldSpecificOrder fieldSpecificOrder = new FieldSpecificOrder();
- String expectedSpecific = "{\"aField\":\"aValue\",\"dField\":\"dValue\"}";
- assertEquals(expectedSpecific, jsonb.toJson(fieldSpecificOrder));
- }
-
- @Test
- public void testPropertySortingWithNamingAnnotation() {
- FieldOrderNameAnnotation fieldOrderNameAnnotation = new FieldOrderNameAnnotation();
- Jsonb jsonb = JsonbBuilder.create(new JsonbConfig().withPropertyOrderStrategy(PropertyOrderStrategy.LEXICOGRAPHICAL));
- String expectedLexicographical = "{\"bField\":\"bValue\",\"cField\":\"cValue\",\"dField\":\"dValue\",\"zField\":\"aValue\"}";
- assertEquals(expectedLexicographical, jsonb.toJson(fieldOrderNameAnnotation));
-
- jsonb = JsonbBuilder.create(new JsonbConfig().withPropertyOrderStrategy(PropertyOrderStrategy.REVERSE));
- String expectedReverse = "{\"zField\":\"aValue\",\"dField\":\"dValue\",\"cField\":\"cValue\",\"bField\":\"bValue\"}";
- assertEquals(expectedReverse, jsonb.toJson(fieldOrderNameAnnotation));
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/CreatorConstructorPojo.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/CreatorConstructorPojo.java
deleted file mode 100644
index a2870bb..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/CreatorConstructorPojo.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization.model;
-
-import javax.json.bind.annotation.JsonbCreator;
-import java.math.BigDecimal;
-
-/**
- * @author Roman Grigoriadi
- */
-public class CreatorConstructorPojo {
-
- public String str1;
-
- public String str2;
-
- public BigDecimal bigDec;
-
- public CreatorFactoryMethodPojo innerFactoryCreator;
-
- @JsonbCreator
- public CreatorConstructorPojo(String str1, String str2) {
- this.str1 = str1;
- this.str2 = str2;
- }
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/CreatorFactoryMethodPojo.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/CreatorFactoryMethodPojo.java
deleted file mode 100644
index 8420a97..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/CreatorFactoryMethodPojo.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization.model;
-
-import javax.json.bind.annotation.JsonbCreator;
-import java.math.BigDecimal;
-
-/**
- * @author Roman Grigoriadi
- */
-public class CreatorFactoryMethodPojo {
-
- public String str1;
-
- public String str2;
-
- public BigDecimal bigDec;
-
- @JsonbCreator
- public static CreatorFactoryMethodPojo getInstance(String str1, String str2) {
- CreatorFactoryMethodPojo result = new CreatorFactoryMethodPojo();
- result.str1 = str1;
- result.str2 = str2;
- return result;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/CreatorIncompatibleTypePojo.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/CreatorIncompatibleTypePojo.java
deleted file mode 100644
index 0f21dc1..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/CreatorIncompatibleTypePojo.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization.model;
-
-import javax.json.bind.annotation.JsonbCreator;
-import java.io.Serializable;
-
-/**
- * @author Roman Grigoriadi
- */
-public class CreatorIncompatibleTypePojo {
-
- public String s1;
-
- @JsonbCreator
- public static Serializable getInstance() {
- return null;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/CreatorMultipleDeclarationErrorPojo.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/CreatorMultipleDeclarationErrorPojo.java
deleted file mode 100644
index f28caba..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/CreatorMultipleDeclarationErrorPojo.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization.model;
-
-import javax.json.bind.annotation.JsonbCreator;
-
-/**
- * @author Roman Grigoriadi
- */
-public class CreatorMultipleDeclarationErrorPojo {
-
- public String s1;
-
- @JsonbCreator
- public CreatorMultipleDeclarationErrorPojo(String s1) {
- this.s1 = s1;
- }
-
- @JsonbCreator
- public static CreatorMultipleDeclarationErrorPojo getInstance() {
- return null;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/FieldCustomOrder.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/FieldCustomOrder.java
deleted file mode 100644
index 7b04ae7..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/FieldCustomOrder.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * David Kral
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization.model;
-
-import javax.json.bind.annotation.JsonbPropertyOrder;
-
-/**
- * @author David Kral
- */
-@JsonbPropertyOrder({"aField", "cField", "dField" ,"bField"})
-public class FieldCustomOrder {
-
- public String aField = "aValue";
- public String dField = "dValue";
- public String bField = "bValue";
- public String cField = "cValue";
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/FieldCustomOrderWrapper.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/FieldCustomOrderWrapper.java
deleted file mode 100644
index 55cdce0..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/FieldCustomOrderWrapper.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * David Kral
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization.model;
-
-/**
- * @author David Kral
- */
-public class FieldCustomOrderWrapper {
-
- public String stringField = "stringValue";
- public int intField = 1;
- public FieldCustomOrder fieldCustomOrder = new FieldCustomOrder();
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/FieldOrder.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/FieldOrder.java
deleted file mode 100644
index a54f0cb..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/FieldOrder.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * David Kral
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization.model;
-
-/**
- * @author David Kral
- */
-public class FieldOrder {
-
- public String aField = "aValue";
- public String dField = "dValue";
- public String bField = "bValue";
- public String cField = "cValue";
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/FieldOrderNameAnnotation.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/FieldOrderNameAnnotation.java
deleted file mode 100644
index e4eded9..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/FieldOrderNameAnnotation.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * David Kral
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization.model;
-
-import javax.json.bind.annotation.JsonbProperty;
-
-/**
- * @author David Kral
- */
-public class FieldOrderNameAnnotation {
-
- @JsonbProperty(value = "zField")
- public String aField = "aValue";
- public String dField = "dValue";
- public String bField = "bValue";
- public String cField = "cValue";
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/FieldSpecificOrder.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/FieldSpecificOrder.java
deleted file mode 100644
index 1825711..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/FieldSpecificOrder.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * David Kral
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization.model;
-
-import javax.json.bind.annotation.JsonbPropertyOrder;
-
-/**
- * @author David Kral
- */
-@JsonbPropertyOrder({"aField", "dField"})
-public class FieldSpecificOrder {
-
- public String aField = "aValue";
- public String dField = "dValue";
- public String bField = "bValue";
- public String cField = "cValue";
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/InheritedAnnotationsPojo.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/InheritedAnnotationsPojo.java
deleted file mode 100644
index a65597d..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/InheritedAnnotationsPojo.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization.model;
-
-/**
- * @author Roman Grigoriadi
- */
-@InheritsNillableRecursion
-public class InheritedAnnotationsPojo {
-
- @InheritsJsonbProperty
- public String property;
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/InheritsJsonbProperty.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/InheritsJsonbProperty.java
deleted file mode 100644
index 9a79b34..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/InheritsJsonbProperty.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization.model;
-
-import javax.json.bind.annotation.JsonbProperty;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@JsonbProperty("renamedProperty")
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.PARAMETER})
-public @interface InheritsJsonbProperty {
- String value() default "abc";
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/InheritsNillable.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/InheritsNillable.java
deleted file mode 100644
index 6bd82874..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/InheritsNillable.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization.model;
-
-import javax.json.bind.annotation.JsonbNillable;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
-import static java.lang.annotation.ElementType.PACKAGE;
-import static java.lang.annotation.ElementType.TYPE;
-
-@JsonbNillable()
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ANNOTATION_TYPE, TYPE, PACKAGE})
-public @interface InheritsNillable {
- String value() default "abc";
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/InheritsNillableRecursion.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/InheritsNillableRecursion.java
deleted file mode 100644
index 62119ee..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/InheritsNillableRecursion.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization.model;
-
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
-import static java.lang.annotation.ElementType.PACKAGE;
-import static java.lang.annotation.ElementType.TYPE;
-
-@InheritsNillable
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ANNOTATION_TYPE, TYPE, PACKAGE})
-public @interface InheritsNillableRecursion {
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/InterfacedPojoA.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/InterfacedPojoA.java
deleted file mode 100644
index f1b39bf..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/InterfacedPojoA.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization.model;
-
-import javax.json.bind.annotation.JsonbProperty;
-
-/**
- * @author Roman Grigoriadi
- */
-public interface InterfacedPojoA {
-
-
- @JsonbProperty("propA")
- String getPropertyA();
-
- @JsonbProperty("propA")
- void setPropertyA(String property);
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/InterfacedPojoB.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/InterfacedPojoB.java
deleted file mode 100644
index 2c4734b..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/InterfacedPojoB.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization.model;
-
-import javax.json.bind.annotation.JsonbProperty;
-
-/**
- * @author Roman Grigoriadi
- */
-public interface InterfacedPojoB extends InterfacedPojoA {
-
- @JsonbProperty("propB")
- String getPropertyB();
-
- @JsonbProperty("propB")
- void setPropertyB(String propertyB);
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/InterfacedPojoC.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/InterfacedPojoC.java
deleted file mode 100644
index 276055a..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/InterfacedPojoC.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization.model;
-
-import javax.json.bind.annotation.JsonbProperty;
-
-/**
- * @author Roman Grigoriadi
- */
-public interface InterfacedPojoC extends InterfacedPojoB {
-
- @JsonbProperty("propC")
- String getPropertyC();
-
- @JsonbProperty("propC")
- void setPropertyC(String propertyC);
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/InterfacedPojoImpl.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/InterfacedPojoImpl.java
deleted file mode 100644
index 6556fcb..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/InterfacedPojoImpl.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization.model;
-
-/**
- * @author Roman Grigoriadi
- */
-public class InterfacedPojoImpl extends IntetrfacedPojoAbsImpl implements InterfacedPojoB {
-
- private String propertyB;
-
- @Override
- public String getPropertyB() {
- return propertyB;
- }
-
- @Override
- public void setPropertyB(String propertyB) {
- this.propertyB = propertyB;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/IntetrfacedPojoAbsImpl.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/IntetrfacedPojoAbsImpl.java
deleted file mode 100644
index 46ba818..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/IntetrfacedPojoAbsImpl.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization.model;
-
-/**
- * @author Roman Grigoriadi
- */
-public abstract class IntetrfacedPojoAbsImpl implements InterfacedPojoA {
-
- private String propertyA;
-
- @Override
- public String getPropertyA() {
- return propertyA;
- }
-
- @Override
- public void setPropertyA(String property) {
- this.propertyA = property;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/JsonbNillableClassFirstLevel.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/JsonbNillableClassFirstLevel.java
deleted file mode 100644
index 5b88973..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/JsonbNillableClassFirstLevel.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization.model;
-
-/**
- * Implements a class with nillable annotation.
- *
- * @author Roman Grigoriadi
- */
-public class JsonbNillableClassFirstLevel implements JsonbNillableInterfaceBaseOne {
-
- private String classNillable;
-
- public String getClassNillable() {
- return classNillable;
- }
-
- public void setClassNillable(String classNillable) {
- this.classNillable = classNillable;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/JsonbNillableClassSecondLevel.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/JsonbNillableClassSecondLevel.java
deleted file mode 100644
index cf1c8a3..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/JsonbNillableClassSecondLevel.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization.model;
-
-/**
- * Extends a class which implements intefrace which is nillable.
- *
- * @author Roman Grigoriadi
- */
-public class JsonbNillableClassSecondLevel extends JsonbNillableClassFirstLevel {
-
- private String subclassNillable;
-
- public String getSubclassNillable() {
- return subclassNillable;
- }
-
- public void setSubclassNillable(String subclassNillable) {
- this.subclassNillable = subclassNillable;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/JsonbNillableInterfaceBase.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/JsonbNillableInterfaceBase.java
deleted file mode 100644
index 886501b..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/JsonbNillableInterfaceBase.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization.model;
-
-import javax.json.bind.annotation.JsonbNillable;
-
-/**
- * All extending classes should be nillable.
- * @author Roman Grigoriadi
- */
-@JsonbNillable
-public interface JsonbNillableInterfaceBase {
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/JsonbNillableInterfaceBaseOne.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/JsonbNillableInterfaceBaseOne.java
deleted file mode 100644
index d1aed74..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/JsonbNillableInterfaceBaseOne.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization.model;
-
-/**
- * @author Roman Grigoriadi
- */
-public interface JsonbNillableInterfaceBaseOne extends JsonbNillableInterfaceBase {
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/JsonbNillableInterfaceBaseTwo.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/JsonbNillableInterfaceBaseTwo.java
deleted file mode 100644
index b3af775..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/JsonbNillableInterfaceBaseTwo.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization.model;
-
-import javax.json.bind.annotation.JsonbNillable;
-
-/**
- * Overrides super interface nillable value.
- *
- * @author Roman Grigoriadi
- */
-@JsonbNillable(false)
-public interface JsonbNillableInterfaceBaseTwo extends JsonbNillableInterfaceBase {
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/JsonbNillableOverriddenWithJsonbProperty.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/JsonbNillableOverriddenWithJsonbProperty.java
deleted file mode 100644
index 2133ebe..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/JsonbNillableOverriddenWithJsonbProperty.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization.model;
-
-import javax.json.bind.annotation.JsonbProperty;
-
-/**
- * @author Roman Grigoriadi
- */
-public class JsonbNillableOverriddenWithJsonbProperty {
-
- @JsonbProperty("nillableOverriddenAccidentallyWithDefaultValue")
- private String nillableOverriddenWithFieldJsonbProperty;
-
- private String nillableOverriddenWithGetterJsonbProperty;
-
- private String nillableOverriddenWithSetterJsonbProperty;
-
- public String getNillableOverriddenWithFieldJsonbProperty() {
- return nillableOverriddenWithFieldJsonbProperty;
- }
-
- public void setNillableOverriddenWithFieldJsonbProperty(String nillableOverriddenWithFieldJsonbProperty) {
- this.nillableOverriddenWithFieldJsonbProperty = nillableOverriddenWithFieldJsonbProperty;
- }
-
- @JsonbProperty(nillable = false)
- public String getNillableOverriddenWithGetterJsonbProperty() {
- return nillableOverriddenWithGetterJsonbProperty;
- }
-
- public void setNillableOverriddenWithGetterJsonbProperty(String nillableOverriddenWithGetterJsonbProperty) {
- this.nillableOverriddenWithGetterJsonbProperty = nillableOverriddenWithGetterJsonbProperty;
- }
-
- public String getNillableOverriddenWithSetterJsonbProperty() {
- return nillableOverriddenWithSetterJsonbProperty;
- }
-
- @JsonbProperty(nillable = false)
- public void setNillableOverriddenWithSetterJsonbProperty(String nillableOverriddenWithSetterJsonbProperty) {
- this.nillableOverriddenWithSetterJsonbProperty = nillableOverriddenWithSetterJsonbProperty;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/JsonbNillableOverridesClass.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/JsonbNillableOverridesClass.java
deleted file mode 100644
index 07ac773..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/JsonbNillableOverridesClass.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization.model;
-
-import javax.json.bind.annotation.JsonbNillable;
-import javax.json.bind.annotation.JsonbProperty;
-
-/**
- * @author Roman Grigoriadi
- */
-@JsonbNillable
-public class JsonbNillableOverridesClass extends JsonbNillableOverridesInterface {
- @JsonbProperty("overridesNillableInParent")
- public String nillableField;
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/JsonbNillableOverridesInterface.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/JsonbNillableOverridesInterface.java
deleted file mode 100644
index 32ff285..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/JsonbNillableOverridesInterface.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization.model;
-
-import javax.json.bind.annotation.JsonbNillable;
-
-/**
- * @author Roman Grigoriadi
- */
-@JsonbNillable(false)
-public class JsonbNillableOverridesInterface implements JsonbNillableInterfaceBaseTwo {
- public String nillableField;
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/JsonbNillableValue.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/JsonbNillableValue.java
deleted file mode 100644
index 094f67e..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/JsonbNillableValue.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization.model;
-
-import javax.json.bind.annotation.JsonbNillable;
-
-/**
- * @author Roman Grigoriadi
- */
-@JsonbNillable
-public class JsonbNillableValue {
-
- private String nillableField;
-
- public String getNillableField() {
- return nillableField;
- }
-
- public void setNillableField(String nillableField) {
- this.nillableField = nillableField;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/JsonbPropertyName.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/JsonbPropertyName.java
deleted file mode 100644
index 69699a4..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/JsonbPropertyName.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization.model;
-
-import javax.json.bind.annotation.JsonbProperty;
-
-/**
- * @author Roman Grigoriadi
- */
-public class JsonbPropertyName {
-
- @JsonbProperty("fieldAnnotatedNameCustomized")
- private String fieldAnnotatedName;
-
- private String methodAnnotName;
-
- @JsonbProperty("fieldAnnotatedNameToOverride")
- private String fieldOverridedWithMethodAnnot;
-
- public String getFieldAnnotatedName() {
- return fieldAnnotatedName;
- }
-
- public void setFieldAnnotatedName(String fieldAnnotatedName) {
- this.fieldAnnotatedName = fieldAnnotatedName;
- }
-
- @JsonbProperty("getterAnnotatedName")
- public String getMethodAnnotName() {
- return methodAnnotName;
- }
-
- @JsonbProperty("setterAnnotatedName")
- public void setMethodAnnotName(String methodAnnotName) {
- this.methodAnnotName = methodAnnotName;
- }
-
- @JsonbProperty("getterOverriddenName")
- public String getFieldOverridedWithMethodAnnot() {
- return fieldOverridedWithMethodAnnot;
- }
-
- @JsonbProperty("setterOverriddenName")
- public void setFieldOverridedWithMethodAnnot(String fieldOverridedWithMethodAnnot) {
- this.fieldOverridedWithMethodAnnot = fieldOverridedWithMethodAnnot;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/JsonbPropertyNameCollision.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/JsonbPropertyNameCollision.java
deleted file mode 100644
index 332dba1..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/JsonbPropertyNameCollision.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization.model;
-
-import javax.json.bind.annotation.JsonbProperty;
-
-/**
- * @author Roman Grigoriadi
- */
-public class JsonbPropertyNameCollision {
-
- private String pojoName;
-
- @JsonbProperty("pojoName")
- private String pojoNameCollision;
-
- public String getPojoName() {
- return pojoName;
- }
-
- public void setPojoName(String pojoName) {
- this.pojoName = pojoName;
- }
-
- public String getPojoNameCollision() {
- return pojoNameCollision;
- }
-
- public void setPojoNameCollision(String pojoNameCollision) {
- this.pojoNameCollision = pojoNameCollision;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/JsonbPropertyNillable.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/JsonbPropertyNillable.java
deleted file mode 100644
index 4a883c0..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/JsonbPropertyNillable.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization.model;
-
-import javax.json.bind.annotation.JsonbProperty;
-
-/**
- * @author Roman Grigoriadi
- */
-public class JsonbPropertyNillable {
-
- @JsonbProperty(nillable = true)
- private String nullField;
-
- @JsonbProperty(nillable = false)
- private String nillableOverride;
-
- public String getNullField() {
- return nullField;
- }
-
- public void setNullField(String nullField) {
- this.nullField = nullField;
- }
-
- @JsonbProperty(nillable = true)
- public String getNillableOverride() {
- return nillableOverride;
- }
-
- public void setNillableOverride(String nillableOverride) {
- this.nillableOverride = nillableOverride;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/JsonbTransientCollision.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/JsonbTransientCollision.java
deleted file mode 100644
index eae9673..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/JsonbTransientCollision.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization.model;
-
-import javax.json.bind.annotation.JsonbProperty;
-import javax.json.bind.annotation.JsonbTransient;
-
-/**
- * @author Roman Grigoriadi
- */
-public class JsonbTransientCollision {
-
- @JsonbProperty("collision")
- private String transientAnnotated1;
-
- @JsonbTransient
- public String getTransientAnnotated1() {
- return transientAnnotated1;
- }
-
- public void setTransientAnnotated1(String transientAnnotated1) {
- this.transientAnnotated1 = transientAnnotated1;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/JsonbTransientValue.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/JsonbTransientValue.java
deleted file mode 100644
index 991436c..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/JsonbTransientValue.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization.model;
-
-import javax.json.bind.annotation.JsonbTransient;
-
-/**
- * @author Roman Grigoriadi
- */
-public class JsonbTransientValue {
-
- @JsonbTransient
- private String transientProperty;
-
- private String property;
-
- public String getTransientProperty() {
- return transientProperty;
- }
-
- public void setTransientProperty(String transientProperty) {
- this.transientProperty = transientProperty;
- }
-
- public String getProperty() {
- return property;
- }
-
- public void setProperty(String property) {
- this.property = property;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/NumberFormatPojo.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/NumberFormatPojo.java
deleted file mode 100644
index 832f13a..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/NumberFormatPojo.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization.model;
-
-import javax.json.bind.annotation.JsonbNumberFormat;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-
-/**
- * @author Roman Grigoriadi
- */
-@JsonbNumberFormat("0.0")
-public class NumberFormatPojo {
-
- @JsonbNumberFormat("00000000.000000")
- public BigDecimal bigDecimal;
-
- @JsonbNumberFormat("00000000")
- public BigInteger bigInteger;
-
- @JsonbNumberFormat("000.00000000")
- public Double aDouble;
-
- @JsonbNumberFormat("000.00000000")
- public Float aFloat;
-
- @JsonbNumberFormat("00000000000")
- public Long aLong;
-
- public Integer integer;
-
- @JsonbNumberFormat("00000")
- public Short aShort;
-
- @JsonbNumberFormat("000")
- public Byte aByte;
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/packagelevelannotations/JsonbNillablePackageLevel.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/packagelevelannotations/JsonbNillablePackageLevel.java
deleted file mode 100644
index 518133c..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/packagelevelannotations/JsonbNillablePackageLevel.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization.model.packagelevelannotations;
-
-/**
- * @author Roman Grigoriadi
- */
-public class JsonbNillablePackageLevel {
-
- private String packageLevelNillableField;
-
- public String getPackageLevelNillableField() {
- return packageLevelNillableField;
- }
-
- public void setPackageLevelNillableField(String packageLevelNillableField) {
- this.packageLevelNillableField = packageLevelNillableField;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/packagelevelannotations/PackageLevelOverridenWithClassLevel.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/packagelevelannotations/PackageLevelOverridenWithClassLevel.java
deleted file mode 100644
index 531f61a..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/packagelevelannotations/PackageLevelOverridenWithClassLevel.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.customization.model.packagelevelannotations;
-
-import javax.json.bind.annotation.JsonbNillable;
-
-/**
- * @author Roman Grigoriadi
- */
-@JsonbNillable(false)
-public class PackageLevelOverridenWithClassLevel {
-
- private String nillableOverridenField;
-
- public String getNillableOverridenField() {
- return nillableOverridenField;
- }
-
- public void setNillableOverridenField(String nillableOverridenField) {
- this.nillableOverridenField = nillableOverridenField;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/packagelevelannotations/package-info.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/packagelevelannotations/package-info.java
deleted file mode 100644
index f8e9f2a..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/customization/model/packagelevelannotations/package-info.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-/**
- * @author Roman Grigoriadi
- */
-@JsonbNillable
-package org.eclipse.persistence.json.bind.customization.model.packagelevelannotations;
-
-import javax.json.bind.annotation.JsonbNillable;
\ No newline at end of file
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/anonymous/AnonymousClassTest.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/anonymous/AnonymousClassTest.java
deleted file mode 100644
index b12d131..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/anonymous/AnonymousClassTest.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Dmitry Kornilov - initial implementation
- ******************************************************************************/
-package org.eclipse.persistence.json.bind.defaultmapping.anonymous;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import javax.json.bind.Jsonb;
-import javax.json.bind.JsonbBuilder;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * This class contains tests for marshalling/unmarshalling anonymous classes.
- *
- * @author Dmitry Kornilov
- */
-public class AnonymousClassTest {
-
- private Jsonb jsonb;
-
- @Before
- public void before() {
- jsonb = JsonbBuilder.create();
- }
-
- @Test
- public void testMarshallInnerClass() {
- assertEquals("{\"anonymousField\":\"anonymousValue\",\"id\":1,\"name\":\"pojoName\"}", jsonb.toJson(new InnerPojo() {
- public String anonymousField = "anonymousValue";
-
- @Override
- public Integer getId() {
- return 1;
- }
-
- @Override
- public String getName() {
- return "pojoName";
- }
- }));
- }
-
- @Test
- public void testMarshallOuterClass() {
- assertEquals("{\"id\":1,\"anonymousField\":\"anonymousValue\"}", jsonb.toJson(new OuterPojo() {
- public String anonymousField = "anonymousValue";
- }));
- }
-
- public static class InnerPojo {
- private Integer id;
- private String name;
-
- public Integer getId() {
- return id;
- }
-
- public void setId(Integer id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/anonymous/OuterPojo.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/anonymous/OuterPojo.java
deleted file mode 100644
index a47b768..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/anonymous/OuterPojo.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Dmitry Kornilov - initial implementation
- ******************************************************************************/
-package org.eclipse.persistence.json.bind.defaultmapping.anonymous;
-
-/**
- * Test class.
- *
- * @author Dmitry Kornilov
- */
-public class OuterPojo {
- private Integer id = 1;
- private String name;
-
- public Integer getId() {
- return id;
- }
-
- public void setId(Integer id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/basic/BasicTest.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/basic/BasicTest.java
deleted file mode 100644
index ce4eb50..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/basic/BasicTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Dmitry Kornilov - initial implementation
- ******************************************************************************/
-package org.eclipse.persistence.json.bind.defaultmapping.basic;
-
-import org.eclipse.persistence.json.bind.internal.JsonBindingBuilder;
-import org.junit.Test;
-
-import javax.json.bind.Jsonb;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.StringWriter;
-import java.io.Writer;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Default mapping primitives tests.
- *
- * @author Dmitry Kornilov
- */
-public class BasicTest {
-
- @Test
- public void testMarshallEscapedString() {
- final Jsonb jsonb = (new JsonBindingBuilder()).build();
- assertEquals("[\" \\\\ \\\" / \\f\\b\\r\\n\\t 9\"]", jsonb.toJson(new String[] {" \\ \" / \f\b\r\n\t \u0039"}));
- }
-
- @Test
- public void testMarshallWriter() {
- final Jsonb jsonb = (new JsonBindingBuilder()).build();
- Writer writer = new StringWriter();
- jsonb.toJson(new Long[]{5L}, writer);
- assertEquals("[5]", writer.toString());
- }
-
- @Test
- public void testMarshallOutputStream() throws IOException {
- final Jsonb jsonb = (new JsonBindingBuilder()).build();
-
- try (final ByteArrayOutputStream baos = new ByteArrayOutputStream()) {
- jsonb.toJson(new Long[]{5L}, baos);
- assertEquals("[5]", baos.toString("UTF-8"));
- }
- }
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/basic/BooleanTest.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/basic/BooleanTest.java
deleted file mode 100644
index f2c6307..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/basic/BooleanTest.java
+++ /dev/null
@@ -1,42 +0,0 @@
-package org.eclipse.persistence.json.bind.defaultmapping.basic;
-
-import org.eclipse.persistence.json.bind.defaultmapping.basic.model.BooleanModel;
-import org.eclipse.persistence.json.bind.defaultmapping.generics.model.GenericTestClass;
-import org.junit.Test;
-
-import javax.json.bind.Jsonb;
-import javax.json.bind.JsonbBuilder;
-import java.lang.reflect.Type;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Tests serialization and deserialization of boolean values
- *
- * Created by Ehsan Zaery Moghaddam (zaerymoghaddam@gmail.com) on 9/17/16.
- */
-public class BooleanTest {
- private Jsonb jsonb = JsonbBuilder.create();
-
- @Test
- public void testBooleanSerialization() throws Exception {
- BooleanModel booleanModel = new BooleanModel(true, false);
-
- String expected = "{\"field1\":\"true\",\"field2\":\"false\"}";
- assertEquals(expected, jsonb.toJson(booleanModel));
- }
-
- @Test
- public void testBooleanDeserializationFromBooleanAsStringValue() throws Exception {
- BooleanModel booleanModel = jsonb.fromJson("{\"field1\":\"true\",\"field2\":\"true\"}", BooleanModel.class);
- assertEquals(booleanModel.field1, true);
- assertEquals(booleanModel.field2, true);
- }
-
- @Test
- public void testBooleanDeserializationFromBooleanRawValue() throws Exception {
- BooleanModel booleanModel = jsonb.fromJson("{\"field1\":false,\"field2\":false}", BooleanModel.class);
- assertEquals(booleanModel.field1, false);
- assertEquals(booleanModel.field2, false);
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/basic/SingleValueTest.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/basic/SingleValueTest.java
deleted file mode 100644
index e7fb78a..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/basic/SingleValueTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-package org.eclipse.persistence.json.bind.defaultmapping.basic;
-
-import org.eclipse.persistence.json.bind.internal.JsonBindingBuilder;
-import org.eclipse.persistence.json.bind.internal.properties.MessageKeys;
-import org.eclipse.persistence.json.bind.internal.properties.Messages;
-import org.junit.Assert;
-import org.junit.Ignore;
-import org.junit.Test;
-
-import javax.json.bind.Jsonb;
-import javax.json.bind.JsonbConfig;
-import javax.json.bind.JsonbException;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * @author David Kral
- */
-@Ignore
-public class SingleValueTest {
-
- @Test
- public void testMarshallPrimitives() {
- final Jsonb jsonb = (new JsonBindingBuilder()).build();
-
- // String
- assertEquals("\"some_string\"", jsonb.toJson("some_string"));
-
- // Character
- assertEquals("\"\uFFFF\"", jsonb.toJson('\uFFFF'));
-
- // Byte
- assertEquals("1", jsonb.toJson((byte)1));
-
- // Short
- assertEquals("1", jsonb.toJson((short)1));
-
- // Integer
- assertEquals("1", jsonb.toJson(1));
-
- // Long
- assertEquals("5", jsonb.toJson(5L));
-
- // Float
- assertEquals("1.2", jsonb.toJson(1.2f));
-
- // Double
- assertEquals("1.2", jsonb.toJson(1.2));
-
- // BigInteger
- assertEquals("1", jsonb.toJson(new BigInteger("1")));
-
- // BigDecimal
- assertEquals("1.2", jsonb.toJson(new BigDecimal("1.2")));
-
- // Number
- assertEquals("1.2", jsonb.toJson(1.2));
-
- // Boolean true
- assertEquals("true", jsonb.toJson(true));
-
- // Boolean false
- assertEquals("false", jsonb.toJson(false));
-
- // null
- //assertEquals("null", jsonb.toJson(null));
- }
-
- @Test
- public void testSingleValue() {
- Jsonb jsonb = (new JsonBindingBuilder()).build();
- assertEquals("5", jsonb.toJson(5));
-
- jsonb = (new JsonBindingBuilder().withConfig(new JsonbConfig().withStrictIJSON(true))).build();
- try {
- jsonb.toJson(5);
- Assert.fail();
- } catch (JsonbException exception){
- assertEquals(Messages.getMessage(MessageKeys.IJSON_ENABLED_SINGLE_VALUE), exception.getMessage());
- }
- }
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/basic/model/BooleanModel.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/basic/model/BooleanModel.java
deleted file mode 100644
index 66d63db..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/basic/model/BooleanModel.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.eclipse.persistence.json.bind.defaultmapping.basic.model;
-
-/**
- * Encapsulates different types of boolean values as a field so that the boolean value's serialization and
- * deserialization could be tested
- *
- * Created by Ehsan Zaery Moghaddam (zaerymoghaddam@gmail.com) on 9/15/16.
- */
-public class BooleanModel {
- public Boolean field1;
- public boolean field2;
-
- public BooleanModel() {
- }
-
- public BooleanModel(boolean field1, Boolean field2) {
- this.field2 = field2;
- this.field1 = field1;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/collections/ArrayTest.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/collections/ArrayTest.java
deleted file mode 100644
index 2baa2be..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/collections/ArrayTest.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.collections;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.eclipse.persistence.json.bind.TestTypeToken;
-
-import javax.json.bind.Jsonb;
-import javax.json.bind.JsonbBuilder;
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static org.junit.Assert.*;
-
-/**
- * @author Roman Grigoriadi
- */
-public class ArrayTest {
-
- private Jsonb jsonb;
-
- @Before
- public void before() {
- jsonb = JsonbBuilder.create();
- }
-
- @Test
- public void testStringArray() {
- String[] stringArray = new String[3];
- stringArray[0] = "first";
- stringArray[1] = "second";
- stringArray[2] = "third";
-
- String expected = "[\"first\",\"second\",\"third\"]";
-
- assertEquals(expected, jsonb.toJson(stringArray));
-
- String[] result = jsonb.fromJson(expected, stringArray.getClass());
- assertEquals("first", result[0]);
- assertEquals("second", result[1]);
- assertEquals("third", result[2]);
- }
-
- @Test
- public void testObjectArrayOfObjects() {
- Object[] objectArray = new Object[2];
- objectArray[0] = new KeyValue("first");
- objectArray[1] = new KeyValue("second");
-
- String expected = "[{\"field\":\"first\"},{\"field\":\"second\"}]";
-
- assertEquals(expected, jsonb.toJson(objectArray));
- Object[] result = jsonb.fromJson(expected, objectArray.getClass());
- assertEquals(HashMap.class, result[0].getClass());
- assertEquals(HashMap.class, result[1].getClass());
- assertEquals("first", ((Map) result[0]).get("field"));
- assertEquals("second", ((Map) result[1]).get("field"));
- }
-
- @Test
- public void testListOfArrays() {
- List<String[]> listOfArrays = new ArrayList<>();
- String[] stringArray = new String[2];
- stringArray[0] = "first";
- stringArray[1] = "second";
- listOfArrays.add(stringArray);
- listOfArrays.add(stringArray);
-
- String expected = "[[\"first\",\"second\"],[\"first\",\"second\"]]";
- assertEquals(expected, jsonb.toJson(listOfArrays));
- List<String[]> result = jsonb.fromJson(expected, new TestTypeToken<ArrayList<String[]>>(){}.getType());
- assertEquals("first", result.get(0)[0]);
- assertEquals("second", result.get(0)[1]);
- assertEquals("first", result.get(1)[0]);
- assertEquals("second", result.get(1)[1]);
- }
-
- @Test
- public void testMultidimensionalArrays() {
- String[][] multi = new String[2][2];
- multi[0][0] = "[0],[0]";
- multi[0][1] = "[0],[1]";
- multi[1][0] = "[1],[0]";
- multi[1][1] = "[1],[1]";
- String expected = "[[\"[0],[0]\",\"[0],[1]\"],[\"[1],[0]\",\"[1],[1]\"]]";
- assertEquals(expected, jsonb.toJson(multi));
- String[][] result = jsonb.fromJson(expected, multi.getClass());
- assertEquals("[0],[0]", result[0][0]);
- assertEquals("[0],[1]", result[0][1]);
- assertEquals("[1],[0]", result[1][0]);
- assertEquals("[1],[1]", result[1][1]);
- }
-
- @Test
- public void testDeserializeJsonArrayIntoObject() {
- String json = "[\"first\",\"second\",\"third\"]";
- Object result = jsonb.fromJson(json, Object.class);
- assertTrue(result instanceof List);
- assertEquals("first", ((List)result).get(0));
- assertEquals("second", ((List)result).get(1));
- assertEquals("third", ((List)result).get(2));
- }
-
- @Test
- public void testDeserializeJsonObjectIntoListOfMaps() {
- String json = "[{\"first\":1,\"second\":10}]";
- Object result = jsonb.fromJson(json, List.class);
- assertTrue(result instanceof List);
- assertEquals(BigDecimal.ONE, ((Map) ((List) result).get(0)).get("first"));
- assertEquals(BigDecimal.TEN, ((Map) ((List) result).get(0)).get("second"));
- }
-
- @Test
- public void testUnmarshallMapWithArrayValue() {
- Map<String, String[]> arrayValueMap = new HashMap<>();
- String[] strings = new String[2];
- strings[0] = "zero";
- strings[1] = "one";
- arrayValueMap.put("first", strings);
- String expected = "{\"first\":[\"zero\",\"one\"]}";
- assertEquals(expected, jsonb.toJson(arrayValueMap));
- Map<String, String[]> result = jsonb.fromJson(expected, new TestTypeToken<HashMap<String, String[]>>(){}.getType());
- assertEquals("zero", result.get("first")[0]);
- assertEquals("one", result.get("first")[1]);
- }
-
- @Test
- public void testArrayOfNulls() {
- String[] nulls = new String[2];
- String expected = "[null,null]";
- assertEquals(expected, jsonb.toJson(nulls));
- String[] result = jsonb.fromJson(expected, nulls.getClass());
- assertTrue(result.length == 2);
- assertNull(result[0]);
- assertNull(result[1]);
- }
-
- @Test
- public void testByteArray() {
- byte[] byteArr = {-128, 127};
- assertEquals("[-128,127]", jsonb.toJson(byteArr));
- assertArrayEquals(byteArr, jsonb.fromJson("[-128, 127]", byte[].class));
- }
-
- @Test
- public void testShortArray() {
- short[] shortArr = {-128, 127};
- assertEquals("[-128,127]", jsonb.toJson(shortArr));
- assertArrayEquals(shortArr, jsonb.fromJson("[-128, 127]", short[].class));
- }
-
- @Test
- public void testIntArray() {
- int[] intArr = {-128, 127};
- assertEquals("[-128,127]", jsonb.toJson(intArr));
- assertArrayEquals(intArr, jsonb.fromJson("[-128, 127]", int[].class));
- }
-
- @Test
- public void testLongArray() {
- long[] longArr = {-128, 127};
- assertEquals("[-128,127]", jsonb.toJson(longArr));
- assertArrayEquals(longArr, jsonb.fromJson("[-128, 127]", long[].class));
- }
-
- @Test
- public void testFloatArray() {
- float[] floatArr = {-128, 127};
- assertEquals("[-128.0,127.0]", jsonb.toJson(floatArr));
- assertArrayEquals(floatArr, jsonb.fromJson("[-128.0, 127.0]", float[].class), 0f);
- }
-
- @Test
- public void testDoubleArray() {
- double[] doubleArr = {-128, 127};
- assertEquals("[-128.0,127.0]", jsonb.toJson(doubleArr));
- assertArrayEquals(doubleArr, jsonb.fromJson("[-128.0, 127.0]", double[].class), 0d);
- }
-
- public static class KeyValue {
- public String field;
-
- public KeyValue(String field) {
- this.field = field;
- }
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/collections/CollectionsTest.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/collections/CollectionsTest.java
deleted file mode 100644
index 9575641..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/collections/CollectionsTest.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Dmitry Kornilov - initial implementation
- ******************************************************************************/
-package org.eclipse.persistence.json.bind.defaultmapping.collections;
-
-import org.eclipse.persistence.json.bind.TestTypeToken;
-import org.eclipse.persistence.json.bind.defaultmapping.generics.model.Circle;
-import org.eclipse.persistence.json.bind.defaultmapping.generics.model.ScalarValueWrapper;
-import org.junit.Before;
-import org.junit.Test;
-
-import javax.json.bind.Jsonb;
-import javax.json.bind.JsonbBuilder;
-import java.math.BigDecimal;
-import java.util.*;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-/**
- * Default mapping arrays/collections/enums tests.
- *
- * @author Dmitry Kornilov
- */
-public class CollectionsTest {
-
- private Jsonb jsonb;
-
- @Before
- public void before() {
- jsonb = JsonbBuilder.create();
- }
-
- @Test
- public void testMarshallCollection() {
-
- final Collection<Integer> collection = Arrays.asList(1, 2, 3);
- assertEquals("[1,2,3]", jsonb.toJson(collection));
- }
-
- @Test
- public void testMarshallMap() {
-
- Map<String, Integer> stringIntegerMap = new LinkedHashMap<>();
- stringIntegerMap.put("1",1);
- stringIntegerMap.put("2",2);
- stringIntegerMap.put("3",3);
-
- assertEquals("{\"1\":1,\"2\":2,\"3\":3}", jsonb.toJson(stringIntegerMap));
-
- assertEquals(stringIntegerMap, jsonb.fromJson("{\"1\":1,\"2\":2,\"3\":3}", new LinkedHashMap<String, Integer>(){}.getClass().getGenericSuperclass()));
- }
-
- @Test
- public void testListOfListsOfStrings() {
-
- List<List<String>> listOfListsOfStrings = new ArrayList<>();
- for(int i=0; i<10; i++) {
- List<String> stringList = new ArrayList<>();
- stringList.add("first");
- stringList.add("second");
- stringList.add("third");
- listOfListsOfStrings.add(stringList);
- }
- final String expected = "[[\"first\",\"second\",\"third\"],[\"first\",\"second\",\"third\"],[\"first\",\"second\",\"third\"],[\"first\",\"second\",\"third\"],[\"first\",\"second\",\"third\"],[\"first\",\"second\",\"third\"],[\"first\",\"second\",\"third\"],[\"first\",\"second\",\"third\"],[\"first\",\"second\",\"third\"],[\"first\",\"second\",\"third\"]]";
- assertEquals(expected, jsonb.toJson(listOfListsOfStrings));
- assertEquals(listOfListsOfStrings, jsonb.fromJson(expected, new ArrayList<List<String>>(){}.getClass().getGenericSuperclass()));
- }
-
- @Test
- public void listOfMapsOfListsOfMaps() {
-
- List<Map<String, List<Map<String, Integer>>>> listOfMapsOfListsOfMaps = new ArrayList<>();
- for(int i=0; i<3; i++) {
- Map<String, List<Map<String, Integer>>> mapOfListsOfMap = new HashMap<>();
- for(int j=0; j<3; j++) {
- List<Map<String, Integer>> listOfMaps = new ArrayList<>();
- for(int k=0; k<3; k++) {
- Map<String, Integer> stringIntegerMap = new HashMap<>();
- stringIntegerMap.put("first", 1);
- stringIntegerMap.put("second", 2);
- stringIntegerMap.put("third", 3);
- listOfMaps.add(stringIntegerMap);
- }
- mapOfListsOfMap.put(String.valueOf(j), listOfMaps);
- }
- listOfMapsOfListsOfMaps.add(mapOfListsOfMap);
- }
- String expected = "[{\"0\":[{\"third\":3,\"first\":1,\"second\":2},{\"third\":3,\"first\":1,\"second\":2},{\"third\":3,\"first\":1,\"second\":2}],\"1\":[{\"third\":3,\"first\":1,\"second\":2},{\"third\":3,\"first\":1,\"second\":2},{\"third\":3,\"first\":1,\"second\":2}],\"2\":[{\"third\":3,\"first\":1,\"second\":2},{\"third\":3,\"first\":1,\"second\":2},{\"third\":3,\"first\":1,\"second\":2}]},{\"0\":[{\"third\":3,\"first\":1,\"second\":2},{\"third\":3,\"first\":1,\"second\":2},{\"third\":3,\"first\":1,\"second\":2}],\"1\":[{\"third\":3,\"first\":1,\"second\":2},{\"third\":3,\"first\":1,\"second\":2},{\"third\":3,\"first\":1,\"second\":2}],\"2\":[{\"third\":3,\"first\":1,\"second\":2},{\"third\":3,\"first\":1,\"second\":2},{\"third\":3,\"first\":1,\"second\":2}]},{\"0\":[{\"third\":3,\"first\":1,\"second\":2},{\"third\":3,\"first\":1,\"second\":2},{\"third\":3,\"first\":1,\"second\":2}],\"1\":[{\"third\":3,\"first\":1,\"second\":2},{\"third\":3,\"first\":1,\"second\":2},{\"third\":3,\"first\":1,\"second\":2}],\"2\":[{\"third\":3,\"first\":1,\"second\":2},{\"third\":3,\"first\":1,\"second\":2},{\"third\":3,\"first\":1,\"second\":2}]}]";
- assertEquals(expected, jsonb.toJson(listOfMapsOfListsOfMaps));
- ArrayList<Map<String, List<Map<String, Integer>>>> result = jsonb.fromJson(expected, new TestTypeToken<ArrayList<Map<String, List<Map<String, Integer>>>>>(){}.getType());
- assertEquals(listOfMapsOfListsOfMaps, result);
- }
-
- @Test
- public void testAnyCollection() {
- final Deque<String> deque = new ArrayDeque<>();
- deque.add("dequeueFirst");
- deque.add("dequeueSecond");
- String expected = "[\"dequeueFirst\",\"dequeueSecond\"]";
- assertEquals(expected, jsonb.toJson(deque));
- Deque<String> dequeueResult = jsonb.fromJson(expected, new TestTypeToken<ArrayDeque<String>>(){}.getType());
- assertEquals("dequeueFirst", dequeueResult.getFirst());
- assertEquals("dequeueSecond", dequeueResult.getLast());
-
- LinkedHashSet<String> linkedHashSet = new LinkedHashSet<>();
- linkedHashSet.add("setFirst");
- linkedHashSet.add("setSecond");
- expected = "[\"setFirst\",\"setSecond\"]";
- assertEquals(expected, jsonb.toJson(linkedHashSet));
- LinkedHashSet<String> linkedHashSetResult = jsonb.fromJson(expected, new TestTypeToken<LinkedHashSet<String>>(){}.getType());
- Iterator<String> iterator = linkedHashSetResult.iterator();
- assertEquals("setFirst", iterator.next());
- assertEquals("setSecond", iterator.next());
-
- LinkedList<String> linkedList = new LinkedList<>();
- linkedList.add("listFirst");
- linkedList.add("listSecond");
- expected = "[\"listFirst\",\"listSecond\"]";
- assertEquals(expected, jsonb.toJson(linkedList));
- LinkedList<String> linkedListResult = jsonb.fromJson(expected, new TestTypeToken<LinkedList<String>>(){}.getType());
- iterator = linkedListResult.iterator();
- assertEquals("listFirst", iterator.next());
- assertEquals("listSecond", iterator.next());
- }
-
-
- @Test
- public void testMarshallArray() {
-
- //support of arrays of types that JSON Binding is able to serialize
- //Byte[], Short[], Integer[] Long[], Float[], Double[], BigInteger[], BigDecimal[], Number[]
- //Object[], JsonArray[], JsonObject[], JsonStructure[]
- //String[], Character[]
- //byte[], short[], int[], long[], float[], double[], char[], boolean[]
- //java.net.URL[], java.net.URI[]
- //Map[], Collection[], other collections ...
- //enum, EnumSet, EnumMap
- //support of multidimensional arrays
-
-
- final Byte[] byteArray = {1, 2, 3};
- assertEquals("[1,2,3]", jsonb.toJson(byteArray));
-
- final Integer[] integerArray = {1, 2, 3};
- assertEquals("[1,2,3]", jsonb.toJson(integerArray));
-
- final String[] stringArray = {"first", "second", "third"};
- assertEquals("[\"first\",\"second\",\"third\"]", jsonb.toJson(stringArray));
-
- final byte[] bytePrimitivesArray = {1, 2, 3};
- assertEquals("[1,2,3]", jsonb.toJson(bytePrimitivesArray));
-
- final int[] intArray = {1, 2, 3};
- assertEquals("[1,2,3]", jsonb.toJson(intArray));
-
- final String[][] stringMultiArray = {{"first", "second"},{"third", "fourth"}};
- assertEquals("[[\"first\",\"second\"],[\"third\",\"fourth\"]]", jsonb.toJson(stringMultiArray));
-
- final Map<String, Object>[][] mapMultiArray = new LinkedHashMap[2][2];
- mapMultiArray[0][0] = new LinkedHashMap<>(1);
- mapMultiArray[0][0].put("0", 0);
- mapMultiArray[0][1] = new LinkedHashMap<>(1);
- mapMultiArray[0][1].put("0", 1);
- mapMultiArray[1][0] = new LinkedHashMap<>(1);
- mapMultiArray[1][0].put("1", 0);
- mapMultiArray[1][1] = new LinkedHashMap<>(1);
- mapMultiArray[1][1].put("1", 1);
-
- assertEquals("[[{\"0\":0},{\"0\":1}],[{\"1\":0},{\"1\":1}]]", jsonb.toJson(mapMultiArray));
- }
-
- @Test
- public void testMarshallEnum() {
-
- final Language language = Language.Russian;
- assertEquals("{\"value\":\"Russian\"}", jsonb.toJson(new ScalarValueWrapper<Language>(language)));
- }
-
- @Test
- public void testMarshallEnumSet() {
-
- final EnumSet<Language> languageEnumSet = EnumSet.of(Language.Czech, Language.Slovak);
-
- final String result = jsonb.toJson(languageEnumSet);
- assertTrue("[\"Czech\",\"Slovak\"]".equals(result) || "[\"Slovak\",\"Czech\"]".equals(result));
- }
-
- @Test
- public void testMarshallEnumMap() {
-
- final EnumMap<Language, String> languageEnumMap = new EnumMap<>(Language.class);
- languageEnumMap.put(Language.Russian, "ru");
- languageEnumMap.put(Language.English, "en");
-
- final String result = jsonb.toJson(languageEnumMap);
- assertTrue("{\"Russian\":\"ru\",\"English\":\"en\"}".equals(result) ||
- "{\"English\":\"en\",\"Russian\":\"ru\"}".equals(result));
- }
-
- @Test
- public void testRawCollection() {
- List rawList = new ArrayList();
- rawList.add("first");
- Circle circle = new Circle();
- circle.setRadius(2.0);
- circle.setArea(1.0);
- rawList.add(circle);
-
- String expected = "[\"first\",{\"area\":1.0,\"radius\":2.0}]";
- assertEquals(expected, jsonb.toJson(rawList));
- List result = jsonb.fromJson(expected, List.class);
- assertEquals("first", result.get(0));
- assertEquals(new BigDecimal("2.0"), ((Map)result.get(1)).get("radius"));
- assertEquals(new BigDecimal("1.0"), ((Map)result.get(1)).get("area"));
- }
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/collections/Language.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/collections/Language.java
deleted file mode 100644
index ae01418..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/collections/Language.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Dmitry Kornilov - initial implementation
- ******************************************************************************/
-package org.eclipse.persistence.json.bind.defaultmapping.collections;
-
-/**
- * Test enumeration.
- *
- * @author Dmitry Kornilov
- */
-public enum Language {
- English,
- Russian,
- Slovak,
- Czech
-}
\ No newline at end of file
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/dates/DatesTest.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/dates/DatesTest.java
deleted file mode 100644
index e2e2a31..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/dates/DatesTest.java
+++ /dev/null
@@ -1,386 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Dmitry Kornilov - initial implementation
- ******************************************************************************/
-package org.eclipse.persistence.json.bind.defaultmapping.dates;
-
-import org.eclipse.persistence.json.bind.TestTypeToken;
-import org.eclipse.persistence.json.bind.defaultmapping.dates.model.CalendarPojo;
-import org.eclipse.persistence.json.bind.defaultmapping.dates.model.ClassLevelDateAnnotation;
-import org.eclipse.persistence.json.bind.defaultmapping.dates.model.DatePojo;
-import org.eclipse.persistence.json.bind.defaultmapping.dates.model.InstantPojo;
-import org.eclipse.persistence.json.bind.defaultmapping.dates.model.LocalDatePojo;
-import org.eclipse.persistence.json.bind.defaultmapping.dates.model.LocalDateTimePojo;
-import org.eclipse.persistence.json.bind.defaultmapping.dates.model.LocalTimePojo;
-import org.eclipse.persistence.json.bind.defaultmapping.dates.model.OffsetDateTimePojo;
-import org.eclipse.persistence.json.bind.defaultmapping.dates.model.OffsetTimePojo;
-import org.eclipse.persistence.json.bind.defaultmapping.dates.model.ZonedDateTimePojo;
-import org.eclipse.persistence.json.bind.defaultmapping.generics.model.ScalarValueWrapper;
-import org.eclipse.persistence.json.bind.internal.JsonBindingBuilder;
-import org.junit.Test;
-
-import javax.json.bind.Jsonb;
-import javax.json.bind.JsonbBuilder;
-import javax.json.bind.JsonbConfig;
-import javax.json.bind.annotation.JsonbDateFormat;
-import javax.json.bind.config.PropertyVisibilityStrategy;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.time.Duration;
-import java.time.Instant;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.LocalTime;
-import java.time.Month;
-import java.time.OffsetDateTime;
-import java.time.OffsetTime;
-import java.time.Period;
-import java.time.ZoneId;
-import java.time.ZoneOffset;
-import java.time.ZonedDateTime;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.GregorianCalendar;
-import java.util.Locale;
-import java.util.SimpleTimeZone;
-import java.util.TimeZone;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * This class contains tests for marshalling/unmarshalling dates.
- *
- * @author Dmitry Kornilov
- */
-public class DatesTest {
-
- private final Jsonb jsonb = (new JsonBindingBuilder()).build();
-
- @Test
- public void testDate() throws ParseException {
- final SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");
- final Date parsedDate = sdf.parse("04.03.2015");
-
- DatePojo pojo = new DatePojo();
- pojo.customDate = parsedDate;
- pojo.defaultFormatted = parsedDate;
- pojo.millisFormatted = parsedDate;
-
- // marshal to ISO format
- final String expected = "{\"defaultFormatted\":\"2015-03-04T00:00:00\",\"millisFormatted\":\"1425423600000\",\"customDate\":\"00:00:00 | 04-03-2015\"}";
- assertEquals(expected, jsonb.toJson(pojo));
- DatePojo result = jsonb.fromJson(expected, DatePojo.class);
- assertEquals(parsedDate, result.customDate);
- assertEquals(parsedDate, result.defaultFormatted);
- assertEquals(parsedDate, result.millisFormatted);
- }
-
- @Test
- public void testCalendar() {
- final Calendar timeCalendar = new Calendar.Builder().setDate(2015, Calendar.APRIL, 3).setTimeOfDay(11, 11, 10)
- .setTimeZone(TimeZone.getTimeZone("Europe/Prague"))
- .build();
-
- CalendarPojo calendarPojo = new CalendarPojo();
- calendarPojo.customCalendar = timeCalendar;
- calendarPojo.defaultFormatted = timeCalendar;
- calendarPojo.millisFormatted = timeCalendar;
-
- // marshal to ISO_DATE
- final String expected = "{\"defaultFormatted\":\"2015-04-03T11:11:10+02:00[Europe/Prague]\",\"millisFormatted\":\"1428052270000\",\"customCalendar\":\"11:11:10 | 03-04-2015, +0200\"}";
- assertEquals(expected, jsonb.toJson(calendarPojo));
-
- // marshal to ISO_DATE_TIME
- CalendarPojo result = jsonb.fromJson(expected, CalendarPojo.class);
- assertEquals(timeCalendar.getTime(), result.customCalendar.getTime());
- assertEquals(timeCalendar.getTime(), result.millisFormatted.getTime());
- assertEquals(timeCalendar.getTime(), result.defaultFormatted.getTime());
- }
-
- @Test
- public void testCalendarWithNonDefaultTimeZone() {
- ZoneId zoneId = ZoneId.of("Australia/Sydney");
- final Calendar timeCalendar = new Calendar.Builder().setDate(2015, Calendar.APRIL, 3).setTimeOfDay(10, 10, 10)
- .setTimeZone(TimeZone.getTimeZone(zoneId)).build();
-
- CalendarPojo calendarPojo = new CalendarPojo();
- calendarPojo.customCalendar = timeCalendar;
- calendarPojo.defaultFormatted = timeCalendar;
- calendarPojo.millisFormatted = timeCalendar;
-
- // marshal to ISO_DATE
- final String expected = "{\"defaultFormatted\":\"2015-04-03T10:10:10+11:00[Australia/Sydney]\",\"millisFormatted\":\"1428016210000\",\"customCalendar\":\"10:10:10 | 03-04-2015, +1100\"}";
- assertEquals(expected, jsonb.toJson(calendarPojo));
-
- // marshal to ISO_DATE_TIME
- CalendarPojo result = jsonb.fromJson(expected, CalendarPojo.class);
- assertEquals(timeCalendar.getTime(), result.customCalendar.getTime());
- assertEquals(timeCalendar.getTime(), result.millisFormatted.getTime());
- assertEquals(timeCalendar.getTime(), result.defaultFormatted.getTime());
- }
-
- @Test
- public void testCalendarWithoutTime() {
- final Calendar dateCalendar = Calendar.getInstance();
- dateCalendar.clear();
- dateCalendar.set(2015, Calendar.APRIL, 3);
-
- CalendarPojo calendarPojo = new CalendarPojo();
- calendarPojo.customCalendar = dateCalendar;
- calendarPojo.defaultFormatted = dateCalendar;
- calendarPojo.millisFormatted = dateCalendar;
-
- // marshal to ISO_DATE
- final String expected = "{\"defaultFormatted\":\"2015-04-03\",\"millisFormatted\":\"1428012000000\",\"customCalendar\":\"00:00:00 | 03-04-2015, +0200\"}";
- assertEquals(expected, jsonb.toJson(calendarPojo));
-
- // marshal to ISO_DATE_TIME
- CalendarPojo result = jsonb.fromJson(expected, CalendarPojo.class);
- assertEquals(dateCalendar.getTime(), result.customCalendar.getTime());
- assertEquals(dateCalendar.getTime(), result.millisFormatted.getTime());
- assertEquals(dateCalendar.getTime(), result.defaultFormatted.getTime());
- }
-
- @Test
- public void testMarshalGregorianCalendar() {
- final Calendar dateGregorianCalendar = GregorianCalendar.getInstance();
- dateGregorianCalendar.clear();
- dateGregorianCalendar.set(2015, Calendar.APRIL, 3);
-
- // marshal to ISO_DATE
- assertEquals("{\"value\":\"2015-04-03\"}", jsonb.toJson(new ScalarValueWrapper<>(dateGregorianCalendar)));
-
- // marshal to ISO_DATE_TIME
- final Calendar dateTimeGregorianCalendar = new Calendar.Builder().setDate(2015, 3, 3)
- .setTimeZone(TimeZone.getTimeZone("Europe/Prague"))
- .build();
- assertEquals("{\"value\":\"2015-04-03T00:00:00+02:00[Europe/Prague]\"}", jsonb.toJson(new ScalarValueWrapper<>(dateTimeGregorianCalendar)));
- }
-
- @Test
- public void testMarshalTimeZone() {
- assertEquals("{\"value\":\"Europe/Prague\"}", jsonb.toJson(new ScalarValueWrapper<>(TimeZone.getTimeZone("Europe/Prague"))));
- assertEquals("{\"value\":\"Europe/Prague\"}", jsonb.toJson(new ScalarValueWrapper<>(SimpleTimeZone.getTimeZone("Europe/Prague"))));
- }
-
- @Test
- public void testMarshalInstant() {
-
- final Instant instant = Instant.parse("2015-03-03T23:00:00Z");
- InstantPojo instantPojo = new InstantPojo(instant);
-
- final String expected = "{\"defaultFormatted\":\"2015-03-03T23:00:00Z\",\"millisFormatted\":\"2015-03-03T23:00:00Z\",\"instant\":\"2015-03-03T23:00:00Z\"}";
- assertEquals(expected, jsonb.toJson(instantPojo));
-
- InstantPojo result = jsonb.fromJson(expected, InstantPojo.class);
- assertEquals(instant, result.defaultFormatted);
- assertEquals(instant, result.millisFormatted);
- assertEquals(instant, result.instant);
- }
-
- @Test
- public void testMarshalDuration() {
- assertEquals("{\"value\":\"PT5H4M\"}", jsonb.toJson(new ScalarValueWrapper<>(Duration.ofHours(5).plusMinutes(4))));
- }
-
- @Test
- public void testMarshalPeriod() {
- assertEquals("{\"value\":\"P10Y\"}", jsonb.toJson(new ScalarValueWrapper<>(Period.between(LocalDate.of(1960, Month.JANUARY, 1), LocalDate.of(1970, Month.JANUARY, 1)))));
- }
-
- @Test
- public void testLocalDate() {
- LocalDate localDate = LocalDate.of(2015, Month.APRIL, 10);
-
- LocalDatePojo pojo = new LocalDatePojo(localDate);
- String expected = "{\"defaultFormatted\":\"2015-04-10\",\"millisFormatted\":\"1428616800000\",\"customLocalDate\":\"10-04-2015\"}";
- assertEquals(expected, jsonb.toJson(pojo));
-
- LocalDatePojo result = jsonb.fromJson(expected, LocalDatePojo.class);
- assertEquals(localDate, result.customLocalDate);
- assertEquals(localDate, result.millisFormatted);
- assertEquals(localDate, result.defaultFormatted);
- }
-
- @Test
- public void testlLocalTime() {
- Jsonb jsonb = getJsonbWithMillisIgnored();
- final LocalTime localTime = LocalTime.of(22, 33);
- LocalTimePojo localTimePojo = new LocalTimePojo(localTime);
- String expected = "{\"defaultFormatted\":\"22:33:00\",\"localTime\":\"22:33:00\"}";
- assertEquals(expected, jsonb.toJson(localTimePojo));
-
- LocalTimePojo result = jsonb.fromJson(expected, LocalTimePojo.class);
- assertEquals(localTime, result.defaultFormatted);
- assertEquals(localTime, result.localTime);
- }
-
- private Jsonb getJsonbWithMillisIgnored() {
- JsonbConfig config = new JsonbConfig();
- config.withPropertyVisibilityStrategy(new PropertyVisibilityStrategy() {
- @Override
- public boolean isVisible(Field field) {
- return !field.getName().startsWith("millis");
- }
-
- @Override
- public boolean isVisible(Method method) {
- return false;
- }
- });
- return JsonbBuilder.create(config);
- }
-
- @Test
- public void testLocalDateTime() {
- final LocalDateTime dateTime = LocalDateTime.of(2015, 2, 16, 13, 21);
- LocalDateTimePojo pojo = new LocalDateTimePojo(dateTime);
-
- String expected = "{\"defaultFormatted\":\"2015-02-16T13:21:00\",\"millisFormatted\":\"1424089260000\",\"customLocalDate\":\"16-02-2015--00:21:13\"}";
- assertEquals(expected, jsonb.toJson(pojo));
-
- LocalDateTimePojo result = jsonb.fromJson(expected, LocalDateTimePojo.class);
- assertEquals(dateTime, result.defaultFormatted);
- assertEquals(dateTime, result.millisFormatted);
- assertEquals(dateTime, result.customLocalDate);
- }
-
- @Test
- public void testLocalDateTimeWithoutConfig() {
- final LocalDateTime dateTime = LocalDateTime.of(2015, 2, 16, 13, 21);
- ScalarValueWrapper<LocalDateTime> pojo = new ScalarValueWrapper<>();
- pojo.setValue(dateTime);
-
- String expected = "{\"value\":\"2015-02-16T13:21:00\"}";
- assertEquals(expected, jsonb.toJson(pojo));
-
- ScalarValueWrapper<LocalDateTime> result = jsonb.fromJson(expected, new TestTypeToken<ScalarValueWrapper<LocalDateTime>>(){}.getType());
- assertEquals(dateTime, result.getValue());
- }
-
- @Test
- public void testDifferentConfigsLocalDateTime() {
- final LocalDateTime dateTime = LocalDateTime.of(2015, 2, 16, 13, 21);
- ScalarValueWrapper<LocalDateTime> pojo = new ScalarValueWrapper<>();
- pojo.setValue(dateTime);
-
- String expected = "{\"value\":\"2015-02-16T13:21:00\"}";
- assertEquals(expected, jsonb.toJson(pojo));
-
- Jsonb jsonb1 = JsonbBuilder.create(new JsonbConfig().withDateFormat(JsonbDateFormat.TIME_IN_MILLIS, Locale.FRENCH));
- assertEquals("{\"value\":\"1424089260000\"}", jsonb1.toJson(pojo));
-
- ScalarValueWrapper<LocalDateTime> result = jsonb.fromJson(expected, new TestTypeToken<ScalarValueWrapper<LocalDateTime>>(){}.getType());
- assertEquals(dateTime, result.getValue());
-
- result = jsonb1.fromJson("{\"value\":\"1424089260000\"}", new TestTypeToken<ScalarValueWrapper<LocalDateTime>>(){}.getType());
- assertEquals(dateTime, result.getValue());
- }
-
- @Test
- public void testZonedDateTime() {
- final ZonedDateTime dateTime = ZonedDateTime.of(2015, 2, 16, 13, 21, 0, 0, ZoneId.of("Asia/Almaty"));
- ZonedDateTimePojo pojo = new ZonedDateTimePojo(dateTime);
-
- String expected = "{\"defaultFormatted\":\"2015-02-16T13:21:00+06:00[Asia/Almaty]\",\"millisFormatted\":\"1424071260000\",\"customZonedDate\":\"+06Asia/Almaty | 16-02-2015--00:21:13\"}";
- assertEquals(expected, jsonb.toJson(pojo));
-
- ZonedDateTimePojo result = jsonb.fromJson(expected, ZonedDateTimePojo.class);
- assertEquals(dateTime, result.defaultFormatted);
-// assertEquals(dateTime, result.millisFormatted);
- assertEquals(dateTime, result.customZonedDate);
-
- //time zone and seconds omitted
- ZonedDateTimePojo result1 = jsonb.fromJson("{\"defaultFormatted\":\"2015-02-16T13:21+06:00\"}", ZonedDateTimePojo.class);
- assertEquals(dateTime.getHour(), result1.defaultFormatted.getHour());
- assertEquals(dateTime.getOffset(), result1.defaultFormatted.getOffset());
-
- }
-
- @Test
- public void testMarshalZoneId() {
- assertEquals("{\"value\":\"Europe/Prague\"}", jsonb.toJson(new ScalarValueWrapper<>(ZoneId.of("Europe/Prague"))));
- }
-
- @Test
- public void testMarshalZoneOffset() {
- assertEquals("{\"value\":\"+02:00\"}", jsonb.toJson(new ScalarValueWrapper<>(ZoneOffset.of("+02:00"))));
- }
-
- @Test
- public void testMarshalOffsetDateTime() {
- final OffsetDateTime dateTime = OffsetDateTime.of(2015, 2, 16, 13, 21, 0, 0, ZoneOffset.of("+05:00"));
- OffsetDateTimePojo pojo = new OffsetDateTimePojo(dateTime);
-
- String expected = "{\"defaultFormatted\":\"2015-02-16T13:21:00+05:00\",\"millisFormatted\":\"1424074860000\",\"offsetDateTime\":\"+0500 16-02-2015--00:21:13\"}";
- assertEquals(expected, jsonb.toJson(pojo));
-
- OffsetDateTimePojo result = jsonb.fromJson(expected, OffsetDateTimePojo.class);
- assertEquals(dateTime, result.defaultFormatted);
- //assertEquals(dateTime, result.millisFormatted); can not parse zone offset from millis other than default
- assertEquals(dateTime, result.offsetDateTime);
-
- }
-
- @Test
- public void testMarshalOffsetTime() {
- Jsonb jsonb = getJsonbWithMillisIgnored();
- final OffsetTime dateTime = OffsetTime.of(13, 21, 15, 0, ZoneOffset.of("+05:00"));
- OffsetTimePojo pojo = new OffsetTimePojo(dateTime);
-
- String expected = "{\"defaultFormatted\":\"13:21:15+05:00\",\"offsetTime\":\"13:21:15+0500\"}";
- assertEquals(expected, jsonb.toJson(pojo));
-
- OffsetTimePojo result = jsonb.fromJson(expected, OffsetTimePojo.class);
- assertEquals(dateTime, result.defaultFormatted);
- assertEquals(dateTime, result.offsetTime);
- }
-
- @Test
- public void testClassLevel() throws ParseException {
- ClassLevelDateAnnotation pojo = new ClassLevelDateAnnotation();
- final SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy");
- pojo.date = sdf.parse("04.03.2015");
- final ZoneId zone = ZoneId.of("Asia/Almaty");
- pojo.calendar = new Calendar.Builder().setDate(2015, Calendar.APRIL, 3).setTimeOfDay(11, 11, 10).setTimeZone(TimeZone.getTimeZone(zone)).build();
- pojo.zonedDateTime = ZonedDateTime.of(2015, 4, 3, 13, 21, 0, 0, zone);
- pojo.defaultZoned = pojo.zonedDateTime;
- pojo.localDateTime = LocalDateTime.of(2015, 4, 3, 13, 21, 0, 0);
-
- String expected = "{\"date\":\"04-03-2015 00:00:00\",\"localDateTime\":\"03-04-2015 13:21:00\",\"calendar\":\"+06 ALMT ven. avril 03-04-2015 11:11:10\",\"defaultZoned\":\"2015-04-03T13:21:00+06:00[Asia/Almaty]\",\"zonedDateTime\":\"+06 ALMT ven. avril 03-04-2015 13:21:00\"}";
- assertEquals(expected, jsonb.toJson(pojo));
-
- ClassLevelDateAnnotation result = jsonb.fromJson(expected, ClassLevelDateAnnotation.class);
- assertEquals(pojo.date, result.date);
- assertEquals(pojo.localDateTime, result.localDateTime);
- assertEquals(pojo.calendar.getTime(), result.calendar.getTime());
- assertEquals(pojo.zonedDateTime, result.zonedDateTime);
- }
-
- @Test
- public void testGlobalConfigDateFormat() {
- JsonbConfig config = new JsonbConfig();
- config.withDateFormat("X z E MMMM dd-MM-yyyy HH:mm:ss", Locale.FRENCH);
- Jsonb jsonb = JsonbBuilder.create(config);
-
- ZonedDateTime dateTime = ZonedDateTime.of(2015, 4, 3, 13, 21, 0, 0, ZoneId.of("Asia/Almaty"));
- String expected = "{\"value\":\"+06 ALMT ven. avril 03-04-2015 13:21:00\"}";
- assertEquals(expected, jsonb.toJson(new ScalarValueWrapper<>(dateTime)));
-
- ScalarValueWrapper<ZonedDateTime> result = jsonb.fromJson(expected, new TestTypeToken<ScalarValueWrapper<ZonedDateTime>>(){}.getType());
-
- assertEquals(dateTime, result.getValue());
-
- }
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/dates/model/AbstractDateTimePojo.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/dates/model/AbstractDateTimePojo.java
deleted file mode 100644
index 40d6b5e..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/dates/model/AbstractDateTimePojo.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.dates.model;
-
-import javax.json.bind.annotation.JsonbDateFormat;
-
-/**
- * Common parent class for testing date objects.
- * Contains {@link JsonbDateFormat} DEFAULT_FORMAT and TIME_IN_MILLIS annotated date objects.
- * @author Roman Grigoriadi
- */
-public class AbstractDateTimePojo<T> {
-
- public AbstractDateTimePojo() {
- }
-
- public AbstractDateTimePojo(T dateObj) {
- this.defaultFormatted = dateObj;
- this.millisFormatted = dateObj;
- }
-
- @JsonbDateFormat(JsonbDateFormat.DEFAULT_FORMAT)
- public T defaultFormatted;
-
- @JsonbDateFormat(JsonbDateFormat.TIME_IN_MILLIS)
- public T millisFormatted;
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/dates/model/CalendarPojo.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/dates/model/CalendarPojo.java
deleted file mode 100644
index 1880099..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/dates/model/CalendarPojo.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.dates.model;
-
-import javax.json.bind.annotation.JsonbDateFormat;
-import java.util.Calendar;
-
-/**
- * @author Roman Grigoriadi
- */
-public class CalendarPojo extends AbstractDateTimePojo<Calendar> {
-
- public CalendarPojo() {
- }
-
- public CalendarPojo(Calendar dateObj) {
- super(dateObj);
- this.customCalendar = dateObj;
- }
-
- @JsonbDateFormat("HH:mm:ss | dd-MM-yyyy, Z")
- public Calendar customCalendar;
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/dates/model/ClassLevelDateAnnotation.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/dates/model/ClassLevelDateAnnotation.java
deleted file mode 100644
index f5f5536..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/dates/model/ClassLevelDateAnnotation.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.dates.model;
-
-import javax.json.bind.annotation.JsonbDateFormat;
-import java.time.ZonedDateTime;
-import java.util.Calendar;
-
-/**
- * @author Roman Grigoriadi
- */
-@JsonbDateFormat(value = "X z E MMMM dd-MM-yyyy HH:mm:ss", locale = "fr")
-public class ClassLevelDateAnnotation extends ClassLevelDateAnnotationParent {
-
- public ZonedDateTime zonedDateTime;
-
- public Calendar calendar;
-
- @JsonbDateFormat(value = JsonbDateFormat.DEFAULT_FORMAT)
- public ZonedDateTime defaultZoned;
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/dates/model/ClassLevelDateAnnotationParent.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/dates/model/ClassLevelDateAnnotationParent.java
deleted file mode 100644
index 1db05a3..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/dates/model/ClassLevelDateAnnotationParent.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.dates.model;
-
-import javax.json.bind.annotation.JsonbDateFormat;
-import java.time.LocalDateTime;
-import java.util.Date;
-
-/**
- * @author Roman Grigoriadi
- */
-@JsonbDateFormat("dd-MM-yyyy HH:mm:ss")
-public class ClassLevelDateAnnotationParent {
-
- public Date date;
-
- public LocalDateTime localDateTime;
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/dates/model/CollectionDatePojo.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/dates/model/CollectionDatePojo.java
deleted file mode 100644
index 388b435..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/dates/model/CollectionDatePojo.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.dates.model;
-
-import javax.json.bind.annotation.JsonbDateFormat;
-import java.util.Date;
-import java.util.List;
-
-/**
- * @author Roman Grigoriadi
- */
-public class CollectionDatePojo {
-
- @JsonbDateFormat("HH:mm:ss | dd-MM-yyyy")
- public List<Date> dates;
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/dates/model/DatePojo.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/dates/model/DatePojo.java
deleted file mode 100644
index 8649b1e..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/dates/model/DatePojo.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.dates.model;
-
-import javax.json.bind.annotation.JsonbDateFormat;
-import java.util.Date;
-
-/**
- * @author Roman Grigoriadi
- */
-public class DatePojo extends AbstractDateTimePojo<Date> {
-
- public DatePojo() {
- }
-
- public DatePojo(Date dateObj) {
- super(dateObj);
- this.customDate = dateObj;
- }
-
- @JsonbDateFormat("HH:mm:ss | dd-MM-yyyy")
- public Date customDate;
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/dates/model/InstantPojo.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/dates/model/InstantPojo.java
deleted file mode 100644
index d0ab450..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/dates/model/InstantPojo.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.dates.model;
-
-import javax.json.bind.annotation.JsonbDateFormat;
-import java.time.Instant;
-
-/**
- * @author Roman Grigoriadi
- */
-public class InstantPojo extends AbstractDateTimePojo<Instant> {
-
- public InstantPojo() {
- }
-
- public InstantPojo(Instant dateObj) {
- super(dateObj);
- this.instant = dateObj;
- }
-
- @JsonbDateFormat("HH:mm:ss | dd-MM-yyyy")
- public Instant instant;
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/dates/model/LocalDatePojo.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/dates/model/LocalDatePojo.java
deleted file mode 100644
index dc94d10..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/dates/model/LocalDatePojo.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.dates.model;
-
-import javax.json.bind.annotation.JsonbDateFormat;
-import java.time.LocalDate;
-
-/**
- * @author Roman Grigoriadi
- */
-public class LocalDatePojo extends AbstractDateTimePojo<LocalDate> {
-
- public LocalDatePojo() {
- }
-
- public LocalDatePojo(LocalDate date) {
- super(date);
- this.customLocalDate = date;
- }
-
- @JsonbDateFormat("dd-MM-yyyy")
- public LocalDate customLocalDate;
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/dates/model/LocalDateTimePojo.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/dates/model/LocalDateTimePojo.java
deleted file mode 100644
index 66864e6..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/dates/model/LocalDateTimePojo.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.dates.model;
-
-import javax.json.bind.annotation.JsonbDateFormat;
-import java.time.LocalDateTime;
-
-/**
- * @author Roman Grigoriadi
- */
-public class LocalDateTimePojo extends AbstractDateTimePojo<LocalDateTime> {
-
- public LocalDateTimePojo() {
- }
-
- public LocalDateTimePojo(LocalDateTime date) {
- super(date);
- this.customLocalDate = date;
- }
-
- @JsonbDateFormat("dd-MM-yyyy--ss:mm:HH")
- public LocalDateTime customLocalDate;
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/dates/model/LocalTimePojo.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/dates/model/LocalTimePojo.java
deleted file mode 100644
index 4418682..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/dates/model/LocalTimePojo.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.dates.model;
-
-import javax.json.bind.annotation.JsonbDateFormat;
-import java.time.LocalTime;
-
-/**
- * @author Roman Grigoriadi
- */
-public class LocalTimePojo extends AbstractDateTimePojo<LocalTime> {
-
- public LocalTimePojo() {
- }
-
- public LocalTimePojo(LocalTime date) {
- super(date);
- this.localTime = date;
- }
-
- @JsonbDateFormat("HH:mm:ss")
- public LocalTime localTime;
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/dates/model/OffsetDateTimePojo.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/dates/model/OffsetDateTimePojo.java
deleted file mode 100644
index 3e5c512..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/dates/model/OffsetDateTimePojo.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.dates.model;
-
-import javax.json.bind.annotation.JsonbDateFormat;
-import java.time.OffsetDateTime;
-
-/**
- * @author Roman Grigoriadi
- */
-public class OffsetDateTimePojo extends AbstractDateTimePojo<OffsetDateTime> {
-
- public OffsetDateTimePojo() {
- }
-
- public OffsetDateTimePojo(OffsetDateTime date) {
- super(date);
- this.offsetDateTime = date;
- }
-
- @JsonbDateFormat("Z dd-MM-yyyy--ss:mm:HH")
- public OffsetDateTime offsetDateTime;
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/dates/model/OffsetTimePojo.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/dates/model/OffsetTimePojo.java
deleted file mode 100644
index 28c4641..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/dates/model/OffsetTimePojo.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.dates.model;
-
-import javax.json.bind.annotation.JsonbDateFormat;
-import java.time.OffsetTime;
-
-/**
- * @author Roman Grigoriadi
- */
-public class OffsetTimePojo extends AbstractDateTimePojo<OffsetTime> {
-
- public OffsetTimePojo() {
- }
-
- public OffsetTimePojo(OffsetTime date) {
- super(date);
- this.offsetTime = date;
- }
-
- @JsonbDateFormat("HH:mm:ssZ")
- public OffsetTime offsetTime;
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/dates/model/ZonedDateTimePojo.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/dates/model/ZonedDateTimePojo.java
deleted file mode 100644
index 92f4e3a..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/dates/model/ZonedDateTimePojo.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.dates.model;
-
-import javax.json.bind.annotation.JsonbDateFormat;
-import java.time.ZonedDateTime;
-
-/**
- * @author Roman Grigoriadi
- */
-public class ZonedDateTimePojo extends AbstractDateTimePojo<ZonedDateTime> {
-
- public ZonedDateTimePojo() {
- }
-
- public ZonedDateTimePojo(ZonedDateTime date) {
- super(date);
- this.customZonedDate = date;
- }
-
- @JsonbDateFormat("XVV | dd-MM-yyyy--ss:mm:HH")
- public ZonedDateTime customZonedDate;
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/GenericsTest.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/GenericsTest.java
deleted file mode 100644
index 415ada6..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/GenericsTest.java
+++ /dev/null
@@ -1,373 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Dmitry Kornilov - initial implementation
- * Roman Grigoriadi
- ******************************************************************************/
-package org.eclipse.persistence.json.bind.defaultmapping.generics;
-
-import org.eclipse.persistence.json.bind.TestTypeToken;
-import org.eclipse.persistence.json.bind.defaultmapping.generics.model.*;
-import org.eclipse.persistence.json.bind.serializers.model.Box;
-import org.eclipse.persistence.json.bind.serializers.model.Crate;
-import org.junit.Before;
-import org.junit.Test;
-
-import javax.json.bind.Jsonb;
-import javax.json.bind.JsonbBuilder;
-import java.lang.reflect.Type;
-import java.math.BigDecimal;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.*;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-/**
- * This class contains JSONB default mapping generics tests.
- *
- * @author Dmitry Kornilov
- */
-public class GenericsTest {
-
- private Jsonb jsonb;
-
- @Before
- public void before() {
- jsonb = JsonbBuilder.create();
- }
-
-
- @Test
- public void testGenericClass() {
- GenericTestClass<String, Integer> genericClass = new GenericTestClass<>();
- genericClass.field1 = "value1";
- genericClass.field2 = 3;
-
- String expected = "{\"field1\":\"value1\",\"field2\":3}";
- assertEquals(expected, jsonb.toJson(genericClass));
-
- Type type = new TestTypeToken<GenericTestClass<String, Integer>>(){}.getType();
- GenericTestClass<String, Integer> result = jsonb.fromJson(expected, type);
- assertEquals("value1", result.field1);
- assertEquals(Integer.valueOf(3), result.field2);
- }
-
- @Test
- public void testMultiLevelGenericClass() {
-
- GenericTestClass<String, Integer> innerMostGenericClass = new GenericTestClass<>();
- innerMostGenericClass.field1 = "innerMostValue3";
- innerMostGenericClass.field2 = 3;
-
- AnotherGenericTestClass<GenericTestClass<String, Integer>, Integer> another = new AnotherGenericTestClass<>();
- another.field1 = innerMostGenericClass;
- another.field2 = 2;
-
- GenericTestClass<String, AnotherGenericTestClass<GenericTestClass<String, Integer>, Integer>> nestedGenericField = new GenericTestClass<>();
- nestedGenericField.field1 = "outerValue1";
- nestedGenericField.field2 = another;
-
- String expected = "{\"field1\":\"outerValue1\",\"field2\":{\"field1\":{\"field1\":\"innerMostValue3\",\"field2\":3},\"field2\":2}}";
- assertEquals(expected, jsonb.toJson(nestedGenericField));
-
- Type type = new TestTypeToken<GenericTestClass<String, AnotherGenericTestClass<GenericTestClass<String, Integer>, Integer>>>(){}.getType();
- GenericTestClass<String, AnotherGenericTestClass<GenericTestClass<String, Integer>, Integer>> result = jsonb.fromJson(expected, type);
- assertEquals("outerValue1", result.field1);
- assertEquals(Integer.valueOf(2), result.field2.field2);
- assertEquals("innerMostValue3", result.field2.field1.field1);
- assertEquals(Integer.valueOf(3), result.field2.field1.field2);
- }
-
- @Test
- public void testNestedGenericSelfClass() {
- GenericTestClass<String, Integer> inner = new GenericTestClass<>();
- inner.field1 = "innerValue1";
- inner.field2 = 5;
-
- GenericTestClass<String, GenericTestClass<String, Integer>> nestedGenericOnSelfClass = new GenericTestClass<>();
- nestedGenericOnSelfClass.field1 = "outerValue1";
- nestedGenericOnSelfClass.field2 = inner;
-
- String expected = "{\"field1\":\"outerValue1\",\"field2\":{\"field1\":\"innerValue1\",\"field2\":5}}";
- assertEquals(expected, jsonb.toJson(nestedGenericOnSelfClass));
-
- Type type = new TestTypeToken<GenericTestClass<String, GenericTestClass<String, Integer>>>(){}.getType();
- GenericTestClass<String, GenericTestClass<String, Integer>> result = jsonb.fromJson(expected, type);
- assertEquals("outerValue1", result.field1);
- assertEquals("innerValue1", result.field2.field1);
- assertEquals(Integer.valueOf(5), result.field2.field2);
- }
-
- @Test
- public void testCyclicGenericClass() {
-
- final MyCyclicGenericClass<CyclicSubClass> myCyclicGenericClass = new MyCyclicGenericClass<>();
- final CyclicSubClass cyclicSubClass = new CyclicSubClass();
- cyclicSubClass.subField = "subFieldValue";
- myCyclicGenericClass.field1 = cyclicSubClass;
-
- String expected = "{\"field1\":{\"subField\":\"subFieldValue\"}}";
- assertEquals(expected, jsonb.toJson(myCyclicGenericClass));
- MyCyclicGenericClass<CyclicSubClass> result = jsonb.fromJson(expected, new TestTypeToken<MyCyclicGenericClass<CyclicSubClass>>(){}.getType());
- assertEquals(CyclicSubClass.class, result.field1.getClass());
- assertEquals("subFieldValue", result.field1.subField);
- }
-
- @Test
- public void testWildCards() {
-
- final WildCardClass<Integer> integerWildCard = new WildCardClass<>();
-
- integerWildCard.number = 10;
- String expected = "{\"number\":10}";
- assertEquals(expected, jsonb.toJson(integerWildCard));
- WildCardClass<Integer> result = jsonb.fromJson(expected, new TestTypeToken<WildCardClass<Integer>>(){}.getType());
- assertEquals(Integer.valueOf(10), result.number);
- }
-
- @Test
- public void testGenericWithUnboundedWildcard() {
- //wildcardList is treated as List<Object>
- String expected = "{\"wildcardList\":[{\"k1\":\"v1\",\"k2\":\"v2\"}]}";
-
- GenericWithUnboundedWildcardClass genericWithUnboundedWildcardClass = new GenericWithUnboundedWildcardClass();
- List<Map<String, String>> list = new ArrayList<>();
- genericWithUnboundedWildcardClass.wildcardList = list;
- Map<String, String> stringMap = new HashMap<>();
- stringMap.put("k1", "v1");
- stringMap.put("k2", "v2");
- list.add(stringMap);
- assertEquals(expected, jsonb.toJson(genericWithUnboundedWildcardClass));
-
- GenericWithUnboundedWildcardClass result = jsonb.fromJson(expected, GenericWithUnboundedWildcardClass.class);
- assertTrue(result.wildcardList.get(0) instanceof Map);
- assertEquals("v1", ((Map) result.wildcardList.get(0)).get("k1"));
- assertEquals("v2", ((Map) result.wildcardList.get(0)).get("k2"));
- }
-
- @Test
- public void testWildCardMultipleBounds() {
-
- WildcardMultipleBoundsClass<BigDecimal> multipleBoundsClass = new WildcardMultipleBoundsClass<>();
- multipleBoundsClass.wildcardField = BigDecimal.ONE;
-
- GenericTestClass<String, BigDecimal> genericTestClass = new GenericTestClass<>();
- genericTestClass.field1 = "genericTestClassField1";
- genericTestClass.field2 = BigDecimal.TEN;
- multipleBoundsClass.genericTestClassPropagatedWildCard = genericTestClass;
-
- List<ExtendsBigDecimal> extendsBigDecimalList = new ArrayList<>();
- extendsBigDecimalList.add(new ExtendsBigDecimal("11"));
- multipleBoundsClass.propagatedWildcardList = extendsBigDecimalList;
-
- String expected = "{\"genericTestClassPropagatedWildCard\":{\"field1\":\"genericTestClassField1\",\"field2\":10},\"propagatedWildcardList\":[11],\"wildcardField\":1}";
- assertEquals(expected, jsonb.toJson(multipleBoundsClass, new WildcardMultipleBoundsClass<BigDecimal>(){}.getClass()));
-
-
- WildcardMultipleBoundsClass<BigDecimal> result = jsonb.fromJson(expected, new TestTypeToken<WildcardMultipleBoundsClass<BigDecimal>>(){}.getType());
- assertEquals(BigDecimal.ONE, result.wildcardField);
- assertEquals("genericTestClassField1", result.genericTestClassPropagatedWildCard.field1);
- assertEquals(BigDecimal.TEN, result.genericTestClassPropagatedWildCard.field2);
- assertEquals(new BigDecimal("11"), result.propagatedWildcardList.get(0));
-
- }
-
- @Test
- public void testWithType() {
- List<Optional<String>> expected = Arrays.asList(Optional.empty(), Optional.ofNullable("first"), Optional.of("second"));
- //String json = jsonb.toJson(expected, DefaultMappingGenericsTest.class.getField("listOfOptionalStringField").getGenericType());
-
- // TODO according to Martin V this should not pass... but it is...
- String json = jsonb.toJson(expected);
- assertEquals("[null,\"first\",\"second\"]", json);
- }
-
- @Test
- public void testPropagatedGenerics() {
- List<Integer> integerList = new ArrayList<>();
- integerList.add(1);
- integerList.add(2);
-
- GenericTestClass<List<Integer>, String> genericInList = new GenericTestClass<>();
- genericInList.field1 = integerList;
- genericInList.field2 = "GenericsInListF2";
-
- List<GenericTestClass<List<Integer>, String>> listWithGenerics = new ArrayList<>();
- listWithGenerics.add(genericInList);
-
- GenericTestClass<Integer, String> genericTestClass = new GenericTestClass<>();
- genericTestClass.field1 = 1;
- genericTestClass.field2 = "first";
-
- PropagatedGenericClass<Integer, String> propagatedGenericClass = new PropagatedGenericClass<>();
- propagatedGenericClass.genericTestClass = genericTestClass;
- propagatedGenericClass.genericList = listWithGenerics;
-
- String expected = "{\"genericList\":[{\"field1\":[1,2],\"field2\":\"GenericsInListF2\"}],\"genericTestClass\":{\"field1\":1,\"field2\":\"first\"}}";
-
- assertEquals(expected, jsonb.toJson(propagatedGenericClass, new TestTypeToken<PropagatedGenericClass<Integer, String>>(){}.getType()));
- PropagatedGenericClass<Integer, String> result = jsonb.fromJson(expected, new TestTypeToken<PropagatedGenericClass<Integer, String>>(){}.getType());
- assertEquals(GenericTestClass.class, result.genericList.get(0).getClass());
- assertEquals(Integer.valueOf(1), result.genericList.get(0).field1.get(0));
- assertEquals(Integer.valueOf(2), result.genericList.get(0).field1.get(1));
- assertEquals("GenericsInListF2", result.genericList.get(0).field2);
- assertEquals(GenericTestClass.class, result.genericTestClass.getClass());
- assertEquals(Integer.valueOf(1), result.genericTestClass.field1);
- assertEquals("first", result.genericTestClass.field2);
-
- }
-
- @Test
- public void testFunctional() {
- FunctionalInterface myFunction = new FunctionalInterface<String>() {
-
- private String value = "initValue";
-
- @Override
- public String getValue() {
- return value;
- }
-
- public void setValue(String value) {
- this.value = value;
- }
- };
-
- assertEquals("{\"value\":\"initValue\"}", jsonb.toJson(myFunction));
- }
-
- @Test
- public void testBoundedGenerics() {
- //bounded generics
- BoundedGenericClass<HashSet<Integer>, Circle> boundedGenericClass = new BoundedGenericClass<>();
- List<Shape> shapeList = new ArrayList<>();
- Circle circle = new Circle();
- circle.setRadius(2.5);
- shapeList.add(circle);
- boundedGenericClass.lowerBoundedList = shapeList;
-
- List<ColoredCircle> coloredCircles = new ArrayList<>();
- ColoredCircle coloredCircle = new ColoredCircle();
- coloredCircle.radius = 3.5;
- coloredCircle.color = "0,0,255";
- coloredCircles.add(coloredCircle);
- boundedGenericClass.upperBoundedList = coloredCircles;
-
- HashSet<Integer> intSet = new HashSet<>();
- intSet.add(3);
- boundedGenericClass.boundedSet = intSet;
-
- String expected = "{\"boundedSet\":[3],\"lowerBoundedList\":[{\"radius\":2.5}],\"upperBoundedList\":[{\"radius\":3.5,\"color\":\"0,0,255\"}]}";
- assertEquals(expected, jsonb.toJson(boundedGenericClass));
-
- BoundedGenericClass<HashSet<Integer>, Circle> result = jsonb.fromJson(expected,
- new TestTypeToken<BoundedGenericClass<HashSet<Integer>, Circle>>(){}.getType());
- assertEquals(Circle.class, result.lowerBoundedList.get(0).getClass());
- assertEquals(Double.valueOf(2.5), ((Circle) result.lowerBoundedList.get(0)).getRadius());
-
- //There is no way of identifying precise class (ColoredCircle) during json unmarshalling.
- //Fields that are missing in upper bounds are skipped.
- assertEquals(Circle.class, result.upperBoundedList.get(0).getClass());
- assertEquals(Double.valueOf(3.5), result.upperBoundedList.get(0).getRadius());
- //If it was possible we could assert following, but it is not.
- //assertEquals("0,0,255", ((ColoredCircle) result.upperBoundedList.get(0)).color);
- }
-
- @Test
- public void testIncompatibleTypes() {
- //exception incompatible types
- try {
- BoundedGenericClass<HashSet<Integer>, Circle> otherGeneric = jsonb.fromJson("{\"boundedSet\":[3],\"lowerBoundedList\":[{\"radius\":2.5}]}",
- new TestTypeToken<BoundedGenericClass<HashSet<Double>, Circle>>(){}.getType());
- HashSet<Integer> otherIntSet = otherGeneric.boundedSet;
- Integer intValue = otherIntSet.iterator().next();
- System.out.println("intValue=" + intValue);
- assert (false);
- } catch (ClassCastException e) {
- //exception - incompatible types
- //Double cannot be converted to Integer
- }
- }
-
- @Test
- public void testMultiLevelGenericExtension() {
- MultiLevelExtendedGenericTestClass extended = new MultiLevelExtendedGenericTestClass();
- extended.field1 = "first";
- extended.field2 = 1;
-
- String expected = "{\"field1\":\"first\",\"field2\":1}";
- assertEquals(expected, jsonb.toJson(extended));
- MultiLevelExtendedGenericTestClass result = jsonb.fromJson(expected, MultiLevelExtendedGenericTestClass.class);
- assertEquals("first", result.field1);
- assertEquals(Integer.valueOf(1), result.field2);
- }
-
- @Test
- public void testGenericArray() {
- GenericArrayClass<Number, Integer> genericArrayClass = new GenericArrayClass<>();
- Number[] numbers = new Number[2];
- numbers[0] = 1;
- numbers[1] = BigDecimal.TEN;
- genericArrayClass.genericArray = numbers;
-
- Integer[] integers = new Integer[2];
- integers[0] = 1;
- integers[1] = 10;
- genericArrayClass.anotherGenericArray = integers;
-
- GenericTestClass<Number[], Integer[]> genericTestClass = new GenericTestClass<>();
- genericTestClass.field1 = Arrays.copyOf(numbers, numbers.length);
- genericTestClass.field2 = Arrays.copyOf(integers, numbers.length);
- genericArrayClass.propagatedGenericArray = genericTestClass;
-
- String expected = "{\"anotherGenericArray\":[1,10],\"genericArray\":[1,10],\"propagatedGenericArray\":{\"field1\":[1,10],\"field2\":[1,10]}}";
- assertEquals(expected, jsonb.toJson(genericArrayClass, new TestTypeToken<GenericArrayClass<Number,Integer>>(){}.getType()));
- GenericArrayClass<Number, Integer> result = jsonb.fromJson(expected, new TestTypeToken<GenericArrayClass<Number, Integer>>(){}.getType());
- assertEquals(BigDecimal.ONE, result.genericArray[0]);
- assertEquals(BigDecimal.TEN, result.genericArray[1]);
- assertEquals(Integer.valueOf(1), result.anotherGenericArray[0]);
- assertEquals(Integer.valueOf(10), result.anotherGenericArray[1]);
- assertEquals(BigDecimal.ONE, result.propagatedGenericArray.field1[0]);
- assertEquals(BigDecimal.TEN, result.propagatedGenericArray.field1[1]);
- assertEquals(Integer.valueOf(1), result.propagatedGenericArray.field2[0]);
- assertEquals(Integer.valueOf(10), result.propagatedGenericArray.field2[1]);
-
- }
-
- @Test
- public void testMarshallRawList() throws ParseException {
- List rawList = new ArrayList();
- rawList.add(new SimpleDateFormat("ddMMyyyy").parse("24031981"));
- Box box = new Box();
- box.boxStr = "box string";
- box.crate = new Crate();
- box.crate.crateStr = "crate str";
- rawList.add(box);
-
- final Jsonb jsonb = JsonbBuilder.create();
- String result = jsonb.toJson(rawList);
- assertEquals("[\"1981-03-24T00:00:00\",{\"boxStr\":\"box string\",\"crate\":{\"crate_str\":\"crate str\"}}]", result);
- }
-
- public interface FunctionalInterface<T> {
- T getValue();
- }
-
- public static class ExtendsBigDecimal extends BigDecimal {
-
- public ExtendsBigDecimal(String val) {
- super(val);
- }
- }
-
-}
-
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/AnotherGenericTestClass.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/AnotherGenericTestClass.java
deleted file mode 100644
index 8d92c73..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/AnotherGenericTestClass.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.generics.model;
-
-/**
- * @author Roman Grigoriadi
- */
-public class AnotherGenericTestClass<T1, T2> {
-
- public T1 field1;
-
- public T2 field2;
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/BoundedGenericClass.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/BoundedGenericClass.java
deleted file mode 100644
index 115acc0..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/BoundedGenericClass.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.generics.model;
-
-import java.util.List;
-import java.util.Set;
-
-/**
- * @author Roman Grigoriadi
- */
-public class BoundedGenericClass<T extends Set<? extends Number>, U> {
- public List<? extends U> upperBoundedList;
- public List<? super U> lowerBoundedList;
- public T boundedSet;
-
- public BoundedGenericClass() {
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/Circle.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/Circle.java
deleted file mode 100644
index 5a218a5..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/Circle.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.generics.model;
-
-/**
- * @author Roman Grigoriadi
- */
-public class Circle extends Shape {
- public Double radius;
-
- public Circle() {
- super();
- }
-
- public Double getRadius() {
- return radius;
- }
-
- public void setRadius(double radius) {
- this.radius = radius;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/ColoredCircle.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/ColoredCircle.java
deleted file mode 100644
index 6973f81..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/ColoredCircle.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.generics.model;
-
-/**
- * @author Roman Grigoriadi
- */
-public class ColoredCircle extends Circle {
-
- public String color;
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/CyclicSubClass.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/CyclicSubClass.java
deleted file mode 100644
index d5e225d..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/CyclicSubClass.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.generics.model;
-
-/**
- * @author Roman Grigoriadi
- */
-public class CyclicSubClass extends MyCyclicGenericClass<CyclicSubClass> {
- public String subField;
-
- public CyclicSubClass() {
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/ExtendedGenericTestClass.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/ExtendedGenericTestClass.java
deleted file mode 100644
index 32a09ae..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/ExtendedGenericTestClass.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.generics.model;
-
-/**
- * @author Roman Grigoriadi
- */
-public class ExtendedGenericTestClass extends GenericTestClass<String, Integer> {
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/GenericArrayClass.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/GenericArrayClass.java
deleted file mode 100644
index 6fdd86a..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/GenericArrayClass.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.generics.model;
-
-/**
- * @author Roman Grigoriadi
- */
-public class GenericArrayClass<T, U extends T> {
- public T[] genericArray;
- public U[] anotherGenericArray;
- public GenericTestClass<T[], U[]> propagatedGenericArray;
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/GenericTestClass.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/GenericTestClass.java
deleted file mode 100644
index c174bd2..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/GenericTestClass.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-package org.eclipse.persistence.json.bind.defaultmapping.generics.model;
-
-/**
- * Test class used in generics tests.
- *
- * @author Dmitry Kornilov
- */
-public class GenericTestClass<T,U> {
- public T field1;
- public U field2;
-
- public GenericTestClass() {}
-
- public T getField1() {
- return field1;
- }
-
- public void setField1(T field1) {
- this.field1 = field1;
- }
-
- public U getField2() {
- return field2;
- }
-
- public void setField2(U field2) {
- this.field2 = field2;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/GenericWithUnboundedWildcardClass.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/GenericWithUnboundedWildcardClass.java
deleted file mode 100644
index 93a9bdb..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/GenericWithUnboundedWildcardClass.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.generics.model;
-
-import java.util.List;
-
-/**
- * @author Roman Grigoriadi
- */
-public class GenericWithUnboundedWildcardClass {
- public List<?> wildcardList;
-
- public GenericWithUnboundedWildcardClass() {
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/MultiLevelExtendedGenericTestClass.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/MultiLevelExtendedGenericTestClass.java
deleted file mode 100644
index a9af6ea..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/MultiLevelExtendedGenericTestClass.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.generics.model;
-
-/**
- * @author Roman Grigoriadi
- */
-public class MultiLevelExtendedGenericTestClass extends ExtendedGenericTestClass {
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/MyCyclicGenericClass.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/MyCyclicGenericClass.java
deleted file mode 100644
index 1e04c93..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/MyCyclicGenericClass.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.generics.model;
-
-/**
- * @author Roman Grigoriadi
- */
-public class MyCyclicGenericClass<T extends MyCyclicGenericClass<? extends T>> {
- public T field1;
-
- public MyCyclicGenericClass() {
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/PropagatedGenericClass.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/PropagatedGenericClass.java
deleted file mode 100644
index c87283f..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/PropagatedGenericClass.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.generics.model;
-
-import org.eclipse.persistence.json.bind.defaultmapping.generics.model.GenericTestClass;
-
-import java.util.List;
-
-/**
- * @author Roman Grigoriadi
- */
-public class PropagatedGenericClass<P, X> {
- public List<GenericTestClass<List<P>, X>> genericList;
- public GenericTestClass<P, X> genericTestClass;
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/ScalarValueWrapper.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/ScalarValueWrapper.java
deleted file mode 100644
index 22607ed..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/ScalarValueWrapper.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.generics.model;
-
-/**
- * @author Roman Grigoriadi
- */
-public class ScalarValueWrapper<T> {
-
- private T value;
-
- public ScalarValueWrapper() {
- }
-
- public ScalarValueWrapper(T value) {
- this.value = value;
- }
-
- public T getValue() {
- return value;
- }
-
- public void setValue(T value) {
- this.value = value;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/Shape.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/Shape.java
deleted file mode 100644
index 82a4cc0..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/Shape.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.generics.model;
-
-/**
- * @author Roman Grigoriadi
- */
-public class Shape {
- private Double area;
-
- public Shape() {
- }
-
- public Double getArea() {
- return area;
- }
-
- public void setArea(Double area) {
- this.area = area;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/WildCardClass.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/WildCardClass.java
deleted file mode 100644
index 61e6678..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/WildCardClass.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.generics.model;
-
-/**
- * @author Roman Grigoriadi
- */
-public class WildCardClass <T extends Number> {
-
- public T number;
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/WildcardMultipleBoundsClass.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/WildcardMultipleBoundsClass.java
deleted file mode 100644
index bd297a6..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/generics/model/WildcardMultipleBoundsClass.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.generics.model;
-
-import java.io.Serializable;
-import java.util.List;
-
-/**
- * @author Roman Grigoriadi
- */
-public class WildcardMultipleBoundsClass<T extends Number & Serializable & Comparable<? extends T>> {
-
- public T wildcardField;
-
- public GenericTestClass<String, T> genericTestClassPropagatedWildCard;
-
- public List<? extends T> propagatedWildcardList;
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/inheritance/InheritanceTest.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/inheritance/InheritanceTest.java
deleted file mode 100644
index ceb48a2..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/inheritance/InheritanceTest.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.inheritance;
-
-import org.eclipse.persistence.json.bind.TestTypeToken;
-import org.eclipse.persistence.json.bind.defaultmapping.generics.model.GenericTestClass;
-import org.eclipse.persistence.json.bind.defaultmapping.generics.model.PropagatedGenericClass;
-import org.eclipse.persistence.json.bind.defaultmapping.inheritance.model.SecondLevel;
-import org.eclipse.persistence.json.bind.defaultmapping.inheritance.model.generics.ExtendsExtendsPropagatedGenericClass;
-import org.eclipse.persistence.json.bind.defaultmapping.inheritance.model.generics.ExtendsPropagatedGenericClass;
-import org.eclipse.persistence.json.bind.defaultmapping.inheritance.model.generics.ImplementsGenericInterfaces;
-import org.eclipse.persistence.json.bind.defaultmapping.inheritance.model.generics.SecondLevelGeneric;
-import org.junit.Before;
-import org.junit.Test;
-
-import javax.json.bind.Jsonb;
-import javax.json.bind.JsonbBuilder;
-import java.lang.reflect.Type;
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Tests inheritance model marshalling / unmarshalling
- *
- * Tests property order, method overloading, generic type ({@link java.lang.reflect.TypeVariable}) resolving for unmarshalling.
- *
- * @author Roman Grigoriadi
- */
-public class InheritanceTest {
-
- private Jsonb jsonb;
-
- @Before
- public void setUp() throws Exception {
- jsonb = JsonbBuilder.create();
- }
-
- @Test
- public void testBasicInheritance() throws Exception {
- SecondLevel secondLevel = new SecondLevel();
- secondLevel.setInFirstLevel("IN_FIRST_LEVEL");
- secondLevel.setInSecondLevel("IN_SECOND_LEVEL");
- secondLevel.setInZeroOverriddenInFirst("IN_ZERO_OVERRIDDEN_IN_FIRST");
-
- String json = "{\"inZeroOverriddenInFirst\":\"IN_ZERO_OVERRIDDEN_IN_FIRST\",\"inFirstLevel\":\"IN_FIRST_LEVEL\",\"inSecondLevel\":\"IN_SECOND_LEVEL\"}";
- assertEquals(json, jsonb.toJson(secondLevel));
-
- SecondLevel result = jsonb.fromJson(json, SecondLevel.class);
- assertEquals("IN_FIRST_LEVEL", result.getInFirstLevel());
- assertEquals("IN_SECOND_LEVEL", result.getInSecondLevel());
- assertEquals("IN_ZERO_OVERRIDDEN_IN_FIRST", result.getInZeroOverriddenInFirst());
-
- }
-
- @Test
- public void testBasicGenericInheritance() {
- SecondLevelGeneric<Number, Short, String> secondLevelGeneric = new SecondLevelGeneric<>();
- secondLevelGeneric.setInSecondLevel(BigDecimal.TEN);
- secondLevelGeneric.setInFirstLevel((short) 255);
- secondLevelGeneric.setInZeroOverriddenInFirst("IN_ZERO_OVERRIDDEN_IN_FIRST");
- secondLevelGeneric.setInZero("IN_ZERO");
-
- String json = "{\"inZero\":\"IN_ZERO\",\"inFirstLevel\":255,\"inZeroOverriddenInFirst\":\"IN_ZERO_OVERRIDDEN_IN_FIRST\",\"inSecondLevel\":10}";
- assertEquals(json, jsonb.toJson(secondLevelGeneric));
-
- SecondLevelGeneric<Number, Short, String> result = jsonb.fromJson(json, new TestTypeToken<SecondLevelGeneric<Number, Short, String>>(){}.getType());
- assertEquals(BigDecimal.TEN, result.getInSecondLevel());
- assertEquals(Short.valueOf("255"), result.getInFirstLevel());
- assertEquals("IN_ZERO_OVERRIDDEN_IN_FIRST", result.getInZeroOverriddenInFirst());
- assertEquals("IN_ZERO", result.getInZero());
- }
-
- @Test
- public void testPropagatedGenericInheritance() throws Exception {
-
- List<String> stringList = new ArrayList<>();
- stringList.add("first");
- stringList.add("second");
-
- GenericTestClass<List<String>, BigDecimal> genericInList = new GenericTestClass<>();
- genericInList.field1 = stringList;
- genericInList.field2 = BigDecimal.TEN;
-
- List<GenericTestClass<List<String>, BigDecimal>> listWithGenerics = new ArrayList<>();
- listWithGenerics.add(genericInList);
-
- GenericTestClass<String, BigDecimal> genericTestClass = new GenericTestClass<>();
- genericTestClass.field1 = "GENERIC_STRING";
- genericTestClass.field2 = BigDecimal.ONE;
-
- ExtendsExtendsPropagatedGenericClass underTest = new ExtendsExtendsPropagatedGenericClass();
- underTest.genericTestClass = genericTestClass;
- underTest.genericList = listWithGenerics;
-
- String json = "{\"genericList\":[{\"field1\":[\"first\",\"second\"],\"field2\":10}],\"genericTestClass\":{\"field1\":\"GENERIC_STRING\",\"field2\":1}}";
- assertEquals(json, jsonb.toJson(underTest));
-
- ExtendsExtendsPropagatedGenericClass result = jsonb.fromJson(json, ExtendsExtendsPropagatedGenericClass.class);
- assertEquals(GenericTestClass.class, result.genericList.get(0).getClass());
- assertEquals("first", result.genericList.get(0).field1.get(0));
- assertEquals("second", result.genericList.get(0).field1.get(1));
- assertEquals(BigDecimal.TEN, result.genericList.get(0).field2);
- assertEquals(GenericTestClass.class, result.genericTestClass.getClass());
- assertEquals("GENERIC_STRING", result.genericTestClass.field1);
- assertEquals(BigDecimal.ONE, result.genericTestClass.field2);
- }
-
- @Test
- public void testPropagatedGenericInheritance1() throws Exception {
-
- List<String> stringList = new ArrayList<>();
- stringList.add("first");
- stringList.add("second");
-
- GenericTestClass<List<String>, BigDecimal> genericInList = new GenericTestClass<>();
- genericInList.field1 = stringList;
- genericInList.field2 = BigDecimal.TEN;
-
- List<GenericTestClass<List<String>, BigDecimal>> listWithGenerics = new ArrayList<>();
- listWithGenerics.add(genericInList);
-
- GenericTestClass<String, BigDecimal> genericTestClass = new GenericTestClass<>();
- genericTestClass.field1 = "SECOND_LEVEL_GENERIC_STRING";
- genericTestClass.field2 = BigDecimal.ONE;
-
- PropagatedGenericClass<String, BigDecimal> propagatedGenericClass = new PropagatedGenericClass<>();
- propagatedGenericClass.genericList = listWithGenerics;
- propagatedGenericClass.genericTestClass = genericTestClass;
-
-
- stringList = new ArrayList<>();
- stringList.add("third");
- stringList.add("fourth");
-
- genericInList = new GenericTestClass<>();
- genericInList.field1 = stringList;
- genericInList.field2 = BigDecimal.ZERO;
-
- listWithGenerics = new ArrayList<>();
- listWithGenerics.add(genericInList);
-
- genericTestClass = new GenericTestClass<>();
- genericTestClass.field1 = "FIRST_LEVEL_GENERIC_STRING";
- genericTestClass.field2 = new BigDecimal("11");
-
- ExtendsPropagatedGenericClass<String, BigDecimal> extendsPropagatedGenericClass = new ExtendsPropagatedGenericClass<>();
- extendsPropagatedGenericClass.genericList = listWithGenerics;
- extendsPropagatedGenericClass.genericTestClass = genericTestClass;
-
- SecondLevelGeneric<PropagatedGenericClass<String, BigDecimal>, ExtendsPropagatedGenericClass<String, BigDecimal>, String> secondLevelGeneric = new SecondLevelGeneric<>();
- secondLevelGeneric.setInSecondLevel(propagatedGenericClass);
- secondLevelGeneric.setInFirstLevel(extendsPropagatedGenericClass);
- secondLevelGeneric.setInZeroOverriddenInFirst("STRING_IN_ZERO_OVERRIDDEN_IN_FIRST");
- secondLevelGeneric.setInZero("IN_ZERO");
-
- String json = "{\"inZero\":\"IN_ZERO\",\"inFirstLevel\":{\"genericList\":[{\"field1\":[\"third\",\"fourth\"],\"field2\":0}],\"genericTestClass\":{\"field1\":\"FIRST_LEVEL_GENERIC_STRING\",\"field2\":11}},\"inZeroOverriddenInFirst\":\"STRING_IN_ZERO_OVERRIDDEN_IN_FIRST\",\"inSecondLevel\":{\"genericList\":[{\"field1\":[\"first\",\"second\"],\"field2\":10}],\"genericTestClass\":{\"field1\":\"SECOND_LEVEL_GENERIC_STRING\",\"field2\":1}}}";
-
- final Type runtimeType = new TestTypeToken<SecondLevelGeneric<PropagatedGenericClass<String, BigDecimal>, ExtendsPropagatedGenericClass<String, BigDecimal>, String>>(){}.getType();
- assertEquals(json, jsonb.toJson(secondLevelGeneric, runtimeType));
- SecondLevelGeneric<PropagatedGenericClass<String, BigDecimal>, ExtendsPropagatedGenericClass<String, BigDecimal>, String> result =
- jsonb.fromJson(json, runtimeType);
-
- assertEquals("first", result.getInSecondLevel().genericList.get(0).field1.get(0));
- assertEquals("second", result.getInSecondLevel().genericList.get(0).field1.get(1));
- assertEquals(BigDecimal.TEN, result.getInSecondLevel().genericList.get(0).field2);
- assertEquals("SECOND_LEVEL_GENERIC_STRING", result.getInSecondLevel().genericTestClass.field1);
- assertEquals(BigDecimal.ONE, result.getInSecondLevel().genericTestClass.field2);
-
- assertEquals("third", result.getInFirstLevel().genericList.get(0).field1.get(0));
- assertEquals("fourth", result.getInFirstLevel().genericList.get(0).field1.get(1));
- assertEquals(BigDecimal.ZERO, result.getInFirstLevel().genericList.get(0).field2);
- assertEquals("FIRST_LEVEL_GENERIC_STRING", result.getInFirstLevel().genericTestClass.field1);
- assertEquals(new BigDecimal("11"), result.getInFirstLevel().genericTestClass.field2);
-
- assertEquals("STRING_IN_ZERO_OVERRIDDEN_IN_FIRST", result.getInZeroOverriddenInFirst());
- assertEquals("IN_ZERO", result.getInZero());
- }
-
- @Test
- public void testInterfaceGenericInheritance() throws Exception {
-
- ImplementsGenericInterfaces<String, Integer> implementsGenericInterfaces = new ImplementsGenericInterfaces<>();
-
- implementsGenericInterfaces.setGenericValue("GENERIC_VALUE");
- implementsGenericInterfaces.setAnotherGenericValue(255);
-
- String json = "{\"anotherGenericValue\":255,\"genericValue\":\"GENERIC_VALUE\"}";
- assertEquals(json, jsonb.toJson(implementsGenericInterfaces));
-
- ImplementsGenericInterfaces<String, Integer> result = jsonb.fromJson(json, new TestTypeToken<ImplementsGenericInterfaces<String, Integer>>(){}.getType());
- assertEquals("GENERIC_VALUE", result.getGenericValue());
- assertEquals(Integer.valueOf(255), result.getAnotherGenericValue());
- }
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/inheritance/model/AbstractZeroLevel.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/inheritance/model/AbstractZeroLevel.java
deleted file mode 100644
index 48c795b..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/inheritance/model/AbstractZeroLevel.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.inheritance.model;
-
-/**
- * @author Roman Grigoriadi
- */
-public abstract class AbstractZeroLevel {
-
- protected String inZeroOverriddenInFirst;
-
- abstract String getInZeroOverriddenInFirst();
-
- abstract void setInZeroOverriddenInFirst(String value);
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/inheritance/model/FirstLevel.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/inheritance/model/FirstLevel.java
deleted file mode 100644
index 193509d..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/inheritance/model/FirstLevel.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.inheritance.model;
-
-/**
- * @author Roman Grigoriadi
- */
-public class FirstLevel extends AbstractZeroLevel {
-
- private String inFirstLevel;
-
- @Override
- public String getInZeroOverriddenInFirst() {
- return inZeroOverriddenInFirst;
- }
-
- @Override
- public void setInZeroOverriddenInFirst(String value) {
- inZeroOverriddenInFirst = value;
- }
-
- public String getInFirstLevel() {
- return inFirstLevel;
- }
-
- public void setInFirstLevel(String inFirstLevel) {
- this.inFirstLevel = inFirstLevel;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/inheritance/model/SecondLevel.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/inheritance/model/SecondLevel.java
deleted file mode 100644
index b5d480d..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/inheritance/model/SecondLevel.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.inheritance.model;
-
-/**
- * @author Roman Grigoriadi
- */
-public class SecondLevel extends FirstLevel {
-
- private String inSecondLevel;
-
- //hides inFirstLevel in FirstLevelGeneric
- private String inFirstLevel;
-
- public String getInSecondLevel() {
- return inSecondLevel;
- }
-
- public void setInSecondLevel(String inSecondLevel) {
- this.inSecondLevel = inSecondLevel;
- }
-
- @Override
- public String getInFirstLevel() {
- return inFirstLevel;
- }
-
- @Override
- public void setInFirstLevel(String inFirstLevel) {
- this.inFirstLevel = inFirstLevel;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/inheritance/model/generics/AbstractZeroLevelGeneric.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/inheritance/model/generics/AbstractZeroLevelGeneric.java
deleted file mode 100644
index 5aa68e2..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/inheritance/model/generics/AbstractZeroLevelGeneric.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.inheritance.model.generics;
-
-/**
- * @author Roman Grigoriadi
- */
-public abstract class AbstractZeroLevelGeneric<ZF, Z> {
-
- private Z inZero;
-
- protected ZF inZeroOverriddenInFirst;
-
- abstract ZF getInZeroOverriddenInFirst();
-
- abstract void setInZeroOverriddenInFirst(ZF value);
-
- public Z getInZero() {
- return inZero;
- }
-
- public void setInZero(Z inZero) {
- this.inZero = inZero;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/inheritance/model/generics/AnotherGenericInterface.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/inheritance/model/generics/AnotherGenericInterface.java
deleted file mode 100644
index aa66ccb..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/inheritance/model/generics/AnotherGenericInterface.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.inheritance.model.generics;
-
-/**
- * @author Roman Grigoriadi
- */
-public interface AnotherGenericInterface<T> {
-
- T getAnotherGenericValue();
-
- void setAnotherGenericValue(T value);
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/inheritance/model/generics/ExtendsExtendsPropagatedGenericClass.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/inheritance/model/generics/ExtendsExtendsPropagatedGenericClass.java
deleted file mode 100644
index 92ca62b..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/inheritance/model/generics/ExtendsExtendsPropagatedGenericClass.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.inheritance.model.generics;
-
-import java.math.BigDecimal;
-
-/**
- * @author Roman Grigoriadi
- */
-public class ExtendsExtendsPropagatedGenericClass extends ExtendsPropagatedGenericClass<String, BigDecimal> {
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/inheritance/model/generics/ExtendsPropagatedGenericClass.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/inheritance/model/generics/ExtendsPropagatedGenericClass.java
deleted file mode 100644
index b816dd2..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/inheritance/model/generics/ExtendsPropagatedGenericClass.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.inheritance.model.generics;
-
-import org.eclipse.persistence.json.bind.defaultmapping.generics.model.PropagatedGenericClass;
-
-/**
- * @author Roman Grigoriadi
- */
-public class ExtendsPropagatedGenericClass<A,B> extends PropagatedGenericClass<A,B> {
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/inheritance/model/generics/FirstLevelGeneric.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/inheritance/model/generics/FirstLevelGeneric.java
deleted file mode 100644
index 16d10b3..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/inheritance/model/generics/FirstLevelGeneric.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.inheritance.model.generics;
-
-/**
- * @author Roman Grigoriadi
- */
-public class FirstLevelGeneric<F, Z> extends AbstractZeroLevelGeneric<Z, String> {
-
- private F inFirstLevel;
-
- @Override
- public Z getInZeroOverriddenInFirst() {
- return inZeroOverriddenInFirst;
- }
-
- @Override
- public void setInZeroOverriddenInFirst(Z value) {
- inZeroOverriddenInFirst = value;
- }
-
- public F getInFirstLevel() {
- return inFirstLevel;
- }
-
- public void setInFirstLevel(F inFirstLevel) {
- this.inFirstLevel = inFirstLevel;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/inheritance/model/generics/GenericInterface.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/inheritance/model/generics/GenericInterface.java
deleted file mode 100644
index 378a276..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/inheritance/model/generics/GenericInterface.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.inheritance.model.generics;
-
-/**
- * @author Roman Grigoriadi
- */
-public interface GenericInterface<T> {
-
- T getGenericValue();
-
- void setGenericValue(T value);
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/inheritance/model/generics/ImplementsGenericInterfaces.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/inheritance/model/generics/ImplementsGenericInterfaces.java
deleted file mode 100644
index 35c4c61..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/inheritance/model/generics/ImplementsGenericInterfaces.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.inheritance.model.generics;
-
-/**
- * @author Roman Grigoriadi
- */
-public class ImplementsGenericInterfaces<A, B> implements GenericInterface<A>, AnotherGenericInterface<B> {
-
- private A a;
-
- private B b;
-
- @Override
- public B getAnotherGenericValue() {
- return b;
- }
-
- @Override
- public void setAnotherGenericValue(B value) {
- this.b = value;
- }
-
- @Override
- public A getGenericValue() {
- return a;
- }
-
- @Override
- public void setGenericValue(A value) {
- this.a = value;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/inheritance/model/generics/SecondLevelGeneric.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/inheritance/model/generics/SecondLevelGeneric.java
deleted file mode 100644
index 828a5bc..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/inheritance/model/generics/SecondLevelGeneric.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.inheritance.model.generics;
-
-/**
- * @author Roman Grigoriadi
- */
-public class SecondLevelGeneric<S,SF extends S,Z> extends FirstLevelGeneric<SF,Z> {
-
- private S inSecondLevel;
-
- public S getInSecondLevel() {
- return inSecondLevel;
- }
-
- public void setInSecondLevel(S inSecondLevel) {
- this.inSecondLevel = inSecondLevel;
- }
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/jsonp/JsonpLong.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/jsonp/JsonpLong.java
deleted file mode 100644
index 714d6ef..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/jsonp/JsonpLong.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Dmitry Kornilov - initial implementation
- ******************************************************************************/
-package org.eclipse.persistence.json.bind.defaultmapping.jsonp;
-
-import javax.json.JsonNumber;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-
-/**
- * Test class implementing {@link JsonNumber} interface.
- *
- * @author Dmitry Kornilov
- */
-final public class JsonpLong implements JsonNumber {
- private final long num;
- private BigDecimal bigDecimal; // assigning it lazily on demand
-
- public JsonpLong(long num) {
- this.num = num;
- }
-
- @Override
- public int intValue() {
- return bigDecimalValue().intValue();
- }
-
- @Override
- public int intValueExact() {
- return bigDecimalValue().intValueExact();
- }
-
- @Override
- public BigInteger bigIntegerValue() {
- return bigDecimalValue().toBigInteger();
- }
-
- @Override
- public BigInteger bigIntegerValueExact() {
- return bigDecimalValue().toBigIntegerExact();
- }
-
-
- @Override
- public boolean isIntegral() {
- return true;
- }
-
- @Override
- public long longValue() {
- return num;
- }
-
- @Override
- public long longValueExact() {
- return num;
- }
-
- @Override
- public double doubleValue() {
- return num;
- }
-
- @Override
- public BigDecimal bigDecimalValue() {
- // reference assignments are atomic. At the most some more temp
- // BigDecimal objects are created
- BigDecimal bd = bigDecimal;
- if (bd == null) {
- bigDecimal = bd = new BigDecimal(num);
- }
- return bd;
- }
-
- @Override
- public ValueType getValueType() {
- return ValueType.NUMBER;
- }
-
- @Override
- public String toString() {
- return Long.toString(num);
- }
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/jsonp/JsonpString.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/jsonp/JsonpString.java
deleted file mode 100644
index 0d0c096..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/jsonp/JsonpString.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Dmitry Kornilov - initial implementation
- ******************************************************************************/
-package org.eclipse.persistence.json.bind.defaultmapping.jsonp;
-
-import javax.json.JsonString;
-
-/**
- * Test class implementing {@link JsonString} interface.
- *
- * @author Dmitry Kornilov
- */
-public class JsonpString implements JsonString {
-
- private final String value;
-
- public JsonpString(String value) {
- this.value = value;
- }
-
- @Override
- public String getString() {
- return value;
- }
-
- @Override
- public CharSequence getChars() {
- return value;
- }
-
- @Override
- public ValueType getValueType() {
- return ValueType.STRING;
- }
-
- @Override
- public int hashCode() {
- return value.hashCode();
- }
-
- @Override
- public boolean equals(Object obj) {
- if (!(obj instanceof JsonString)) {
- return false;
- }
- JsonString other = (JsonString) obj;
- return getString().equals(other.getString());
- }
-
- @Override
- public String toString() {
- return "\"" + value + "\"";
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/jsonp/JsonpTest.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/jsonp/JsonpTest.java
deleted file mode 100644
index 4f83d92..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/jsonp/JsonpTest.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Dmitry Kornilov - initial implementation
- ******************************************************************************/
-package org.eclipse.persistence.json.bind.defaultmapping.jsonp;
-
-import org.eclipse.persistence.json.bind.defaultmapping.jsonp.model.JsonpPojo;
-import org.junit.Test;
-
-import javax.json.Json;
-import javax.json.JsonArray;
-import javax.json.JsonArrayBuilder;
-import javax.json.JsonBuilderFactory;
-import javax.json.JsonObject;
-import javax.json.JsonObjectBuilder;
-import javax.json.JsonValue;
-import javax.json.bind.Jsonb;
-import javax.json.bind.JsonbBuilder;
-import javax.json.bind.JsonbConfig;
-import javax.json.spi.JsonProvider;
-import java.math.BigDecimal;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Default mapping JSONP integration tests.
- *
- * @author Dmitry Kornilov
- */
-public class JsonpTest {
-
- private Jsonb jsonb = JsonbBuilder.create();
-
- public static class JsonValueWrapper {
- public JsonValue jsonValue;
-
- public JsonValueWrapper(JsonValue jsonValue) {
- this.jsonValue = jsonValue;
- }
- }
-
- @Test
- public void testMarshallJsonObject() {
-
- final JsonBuilderFactory factory = Json.createBuilderFactory(null);
- final JsonObject jsonObject = factory.createObjectBuilder()
- .add("name", "home")
- .add("city", "Prague")
- .build();
-
- final JsonObjectBuilder customerBuilder = factory.createObjectBuilder();
- customerBuilder.add("f1", "abc123");
- customerBuilder.add("f2", BigDecimal.TEN);
- customerBuilder.add("f3", 12);
- customerBuilder.add("city", jsonObject);
-
- final JsonObjectBuilder wrapperBuilder = factory.createObjectBuilder();
- wrapperBuilder.add("f1", "abc");
- wrapperBuilder.add("cust", customerBuilder);
-
- final JsonObject wrapper = wrapperBuilder.build();
-
- assertEquals("{\"f1\":\"abc\",\"cust\":{\"f1\":\"abc123\",\"f2\":10,\"f3\":12,\"city\":{\"name\":\"home\",\"city\":\"Prague\"}}}", jsonb.toJson(wrapper));
- }
-
- @Test
- public void testMarshallJsonArray() {
-
- final JsonBuilderFactory factory = Json.createBuilderFactory(null);
- final JsonArray jsonArray = factory.createArrayBuilder()
- .add(1)
- .add(2)
- .build();
-
- assertEquals("{\"jsonValue\":[1,2]}", jsonb.toJson(new JsonValueWrapper(jsonArray)));
- }
-
- @Test
- public void testMarshallJsonValue() {
- assertEquals("{\"jsonValue\":true}", jsonb.toJson(new JsonValueWrapper(JsonValue.TRUE)));
- }
-
- @Test
- public void testMarshallJsonNumber() {
- assertEquals("{\"jsonValue\":10}", jsonb.toJson(new JsonValueWrapper(new JsonpLong(10))));
- }
-
- @Test
- public void testMarshallJsonString() {
- assertEquals("{\"jsonValue\":\"hello\"}", jsonb.toJson(new JsonValueWrapper(new JsonpString("hello"))));
- }
-
- @Test
- public void testJsonPojo() {
- JsonbConfig config = new JsonbConfig();
-// config.withFormatting(true);
- Jsonb jsonb = JsonbBuilder.create(config);
-
-
- JsonpPojo pojo = new JsonpPojo();
- final JsonObjectBuilder obj1builder = JsonProvider.provider().createObjectBuilder();
- obj1builder.add("strVal", "string value");
- obj1builder.add("numVal", 2.0d);
- obj1builder.addNull("nullVal");
- obj1builder.add("boolVal", Boolean.TRUE);
-
- final JsonObjectBuilder obj2Builder = JsonProvider.provider().createObjectBuilder();
- obj2Builder.add("innerStr", "string val");
- obj2Builder.add("innerNum", 11.1d);
- final JsonObject obj2 = obj2Builder.build();
-
- JsonArrayBuilder array1Builder = JsonProvider.provider().createArrayBuilder();
- array1Builder.addNull().add(false).add(11L).add(BigDecimal.TEN).add("array STR value").add(obj2);
- JsonArray jsonArray1 = array1Builder.build();
-
- obj1builder.add("innerJsonObject", obj2);
- obj1builder.add("innerArrayObject", jsonArray1);
-
- final JsonObject obj1 = obj1builder.build();
- pojo.jsonObject = obj1;
-
- JsonArrayBuilder arrayBuilder = JsonProvider.provider().createArrayBuilder();
- arrayBuilder.add(obj1).add(true).add(obj2).add(101.0d).add(BigDecimal.TEN);
- pojo.jsonArray = arrayBuilder.build();
-
-
- String expected = "{\"jsonArray\":[{\"strVal\":\"string value\",\"numVal\":2.0,\"nullVal\":null,\"boolVal\":true,\"innerJsonObject\":{\"innerStr\":\"string val\",\"innerNum\":11.1},\"innerArrayObject\":[null,false,11,10,\"array STR value\",{\"innerStr\":\"string val\",\"innerNum\":11.1}]},true,{\"innerStr\":\"string val\",\"innerNum\":11.1},101.0,10],\"jsonObject\":{\"strVal\":\"string value\",\"numVal\":2.0,\"nullVal\":null,\"boolVal\":true,\"innerJsonObject\":{\"innerStr\":\"string val\",\"innerNum\":11.1},\"innerArrayObject\":[null,false,11,10,\"array STR value\",{\"innerStr\":\"string val\",\"innerNum\":11.1}]}}";
- final String actual = jsonb.toJson(pojo);
- assertEquals(expected, actual);
-
- JsonpPojo result = jsonb.fromJson(expected, JsonpPojo.class);
- assertEquals(pojo.jsonObject, result.jsonObject);
- assertEquals(pojo.jsonArray, result.jsonArray);
- }
-
- @Test
- public void testJsonObject() {
- final JsonObjectBuilder objBuilder = JsonProvider.provider().createObjectBuilder();
- objBuilder.add("boolTrue", Boolean.TRUE).add("boolFalse", Boolean.FALSE)
- .addNull("null").add("str", "String");
-
- JsonArrayBuilder arrBuilder = JsonProvider.provider().createArrayBuilder();
- arrBuilder.add(11L).add(Boolean.FALSE).add(BigDecimal.TEN);
- objBuilder.add("array", arrBuilder);
-
- JsonObject object = objBuilder.build();
-
- String expected = "{\"boolTrue\":true,\"boolFalse\":false,\"null\":null,\"str\":\"String\",\"array\":[11,false,10]}";
- assertEquals(expected, jsonb.toJson(object));
-
- JsonObject result = jsonb.fromJson(expected, JsonObject.class);
-
- assertEquals(object, result);
- }
-
- @Test
- public void testJsonArray() {
-
- JsonArrayBuilder arrBuilder = JsonProvider.provider().createArrayBuilder();
- arrBuilder.add(11L).add(Boolean.FALSE).add(BigDecimal.TEN);
-
- JsonObjectBuilder objBuilder = JsonProvider.provider().createObjectBuilder();
- objBuilder.add("boolTrue", Boolean.TRUE).add("boolFalse", Boolean.FALSE)
- .addNull("null").add("str", "String");
-
- arrBuilder.add(objBuilder);
-
- JsonArray arr = arrBuilder.build();
-
- String expected = "[11,false,10,{\"boolTrue\":true,\"boolFalse\":false,\"null\":null,\"str\":\"String\"}]";
- assertEquals(expected, jsonb.toJson(arr));
-
- JsonArray result = jsonb.fromJson(expected, JsonArray.class);
-
- assertEquals(arr, result);
- }
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/jsonp/model/JsonpPojo.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/jsonp/model/JsonpPojo.java
deleted file mode 100644
index 09fbbc8..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/jsonp/model/JsonpPojo.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.jsonp.model;
-
-import javax.json.JsonArray;
-import javax.json.JsonNumber;
-import javax.json.JsonObject;
-import javax.json.JsonString;
-import javax.json.JsonValue;
-
-/**
- * @author Roman Grigoriadi
- */
-public class JsonpPojo {
-
- public JsonObject jsonObject;
-
- public JsonArray jsonArray;
-
- public JsonNumber jsonNumber;
-
- public JsonString jsonString;
-
- public JsonValue jsonValue;
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/modifiers/DefaultMappingModifiersTest.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/modifiers/DefaultMappingModifiersTest.java
deleted file mode 100644
index 443be1d..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/modifiers/DefaultMappingModifiersTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.modifiers;
-
-import org.eclipse.persistence.json.bind.defaultmapping.modifiers.model.FieldModifiersClass;
-import org.eclipse.persistence.json.bind.defaultmapping.modifiers.model.MethodModifiersClass;
-import org.junit.Before;
-import org.junit.Test;
-
-import javax.json.bind.Jsonb;
-import javax.json.bind.JsonbBuilder;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
-/**
- * Test access modifiers for default mapping.
- *
- * @author Roman Grigoriadi
- */
-public class DefaultMappingModifiersTest {
-
- private Jsonb jsonb;
-
- @Before
- public void before() {
- jsonb = JsonbBuilder.create();
- }
-
- @Test
- public void testFieldModifiers() {
- FieldModifiersClass fieldModifiersClass = new FieldModifiersClass();
- assertEquals("{\"finalString\":\"FINAL_STRING\"}", jsonb.toJson(fieldModifiersClass));
- FieldModifiersClass result = jsonb.fromJson("{\"finalString\":\"FINAL_STRING\",\"staticString\":\"STATIC_STRING\",\"transientString\":\"TRANSIENT_STRING\"}", FieldModifiersClass.class);
- //no setter throwing illegal has been called.
- }
-
- @Test
- public void testMethodModifiers() {
- MethodModifiersClass methodModifiers = new MethodModifiersClass();
- methodModifiers.publicFieldWithoutMethods = "WITHOUT_METHODS";
-
- String validJson = "{\"getterWithoutFieldValue\":\"GETTER_WITHOUT_FIELD\",\"publicFieldWithoutMethods\":\"WITHOUT_METHODS\"}";
- assertEquals(validJson, jsonb.toJson(methodModifiers));
-
- MethodModifiersClass result = jsonb.fromJson("{\"publicFieldWithPrivateMethods\":\"value\"}", MethodModifiersClass.class);
- assertNull(result.publicFieldWithPrivateMethods);
-
- result = jsonb.fromJson(validJson, MethodModifiersClass.class);
- assertEquals("WITHOUT_METHODS", result.publicFieldWithoutMethods);
-
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/modifiers/model/FieldModifiersClass.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/modifiers/model/FieldModifiersClass.java
deleted file mode 100644
index 5ea7a12..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/modifiers/model/FieldModifiersClass.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.modifiers.model;
-
-/**
- * @author Roman Grigoriadi
- */
-public class FieldModifiersClass {
-
- private final String finalString = "FINAL_STRING";
-
- private static final Long serialVerisonUID = Long.MAX_VALUE;
-
- private static String staticString = "STATIC_STRING";
-
- private transient String transientString = "TRANSIENT_STRING";
-
- public String getFinalString() {
- return finalString;
- }
-
- public void setFinalString() {
- throw new IllegalStateException();
- }
-
- public static Long getSerialVerisonUID() {
- throw new IllegalStateException();
- }
-
- public String getTransientString() {
- throw new IllegalStateException();
- }
-
- public void setTransientString(String transientString) {
- throw new IllegalStateException();
- }
-
- public static String getStaticString() {
- throw new IllegalStateException();
- }
-
- public static void setStaticString(String staticString) {
- throw new IllegalStateException();
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/modifiers/model/MethodModifiersClass.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/modifiers/model/MethodModifiersClass.java
deleted file mode 100644
index 3614c3f..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/modifiers/model/MethodModifiersClass.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.modifiers.model;
-
-import java.util.function.Consumer;
-
-/**
- * @author Roman Grigoriadi
- */
-public class MethodModifiersClass {
-
- private Consumer<String> setterWithoutFieldConsumer = s -> {};
-
- public String publicFieldWithPrivateMethods;
-
- public String publicFieldWithoutMethods;
-
- public void setSetterWithoutFieldConsumer(Consumer<String> setterWithoutFieldConsumer) {
- this.setterWithoutFieldConsumer = setterWithoutFieldConsumer;
- }
-
- public String getGetterWithoutFieldValue() {
- return "GETTER_WITHOUT_FIELD";
- }
-
- public void setGetterWithoutFieldValue(String value) {
- setterWithoutFieldConsumer.accept(value);
- }
-
- private String getPublicFieldWithPrivateMethods() {
- return publicFieldWithPrivateMethods;
- }
-
- private void setPublicFieldWithPrivateMethods(String publicFieldWithPrivateMethods) {
- this.publicFieldWithPrivateMethods = publicFieldWithPrivateMethods;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/properties/PropertiesTest.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/properties/PropertiesTest.java
deleted file mode 100644
index ab80602..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/properties/PropertiesTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * David Král - initial implementation
- ******************************************************************************/
-package org.eclipse.persistence.json.bind.defaultmapping.properties;
-
-import org.eclipse.persistence.json.bind.internal.properties.MessageKeys;
-import org.eclipse.persistence.json.bind.internal.properties.Messages;
-import org.junit.Test;
-
-import java.io.IOException;
-import java.util.Locale;
-
-import static org.junit.Assert.assertEquals;
-
-
-/**
- * This class contains properties tests
- *
- * @author David Král
- */
-public class PropertiesTest {
-
- @Test
- public void testPropertiesWithoutLocale() throws IOException {
- String template = "Process class: {0} from json using converter: {1}";
- String message = Messages.getMessage(MessageKeys.PROCESS_FROM_JSON);
-
- assertEquals(template, message);
- }
-
- @Test
- public void testPropertiesWithLocale() throws IOException {
- String templateCS = "Zpracovávám třídu: {0} do jsonu za použití convertoru: {1}";
- String messageCS = Messages.getMessage(MessageKeys.PROCESS_TO_JSON, new Locale("cs"));
- String templateEN = "Process class: {0} to json using converter: {1}";
- String messageEN = Messages.getMessage(MessageKeys.PROCESS_TO_JSON, new Locale("en"));
-
- assertEquals(templateCS, messageCS);
- assertEquals(templateEN, messageEN);
- }
-
- @Test
- public void testPropertiesAttributeSetting() throws IOException {
- String template = "Zpracovávám třídu: Test do jsonu za použití convertoru: Test1";
- String message = Messages.getMessage(MessageKeys.PROCESS_TO_JSON, new Locale("cs"), "Test", "Test1");
-
- assertEquals(template, message);
- }
-
-}
-
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/specific/CustomerTest.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/specific/CustomerTest.java
deleted file mode 100644
index bd2db01..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/specific/CustomerTest.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.specific;
-
-import org.eclipse.persistence.json.bind.defaultmapping.specific.model.Address;
-import org.eclipse.persistence.json.bind.defaultmapping.specific.model.Customer;
-import org.eclipse.persistence.json.bind.defaultmapping.specific.model.Street;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * @author Roman Grigoriadi
- */
-public abstract class CustomerTest {
-
- protected void assertCustomerValues(Customer customer, String customerName) {
- assertEquals(customerName, customer.getName());
- assertEquals(Integer.valueOf(33), customer.getAge());
- /*assertEquals(1, customer.getAddresses().size());
- for (Address address : customer.getAddresses()) {
- assertEquals("Prague", address.getTown());
- assertEquals("Zoubkova88", address.getStreet().getName());
- assertEquals(Integer.valueOf(111), address.getStreet().getNumber());
- }*/
-
- if (customer.getStrings() != null) {
- assertEquals(2, customer.getStrings().size());
- assertEquals("green", customer.getStrings().get(0));
- assertEquals("yellow", customer.getStrings().get(1));
- }
-
- if (customer.getIntegers() != null) {
- assertEquals(2, customer.getIntegers().size());
- assertEquals(Integer.valueOf(0), customer.getIntegers().get(0));
- assertEquals(Integer.valueOf(1), customer.getIntegers().get(1));
- }
-
- /*assertEquals(2, customer.getStringIntegerMap().size());
- assertEquals(Integer.valueOf(1), customer.getStringIntegerMap().get("first"));
- assertEquals(Integer.valueOf(2), customer.getStringIntegerMap().get("second"));*/
- }
-
- protected Customer createCustomer(String customerName) {
- Street street = new Street("Zoubkova", 111);
- Address address = new Address(street, "Prague");
- Customer customer = new Customer(33, customerName);
-
- List<Address> addresses = new ArrayList<>();
- addresses.add(address);
- customer.setAddresses(addresses);
-
- List<String> strings = new ArrayList<>();
- strings.add("green");
- strings.add("yellow");
- customer.setStrings(strings);
-
- List<Integer> integers = new ArrayList<>();
- integers.add(0);
- integers.add(1);
- customer.setIntegers(integers);
-
- Map<String, Integer> stringIntegerMap = new HashMap<>();
- stringIntegerMap.put("first", 1);
- stringIntegerMap.put("second", 2);
- customer.setStringIntegerMap(stringIntegerMap);
-
- List<List<Integer>> listOfListsOfIntegers = new ArrayList<>();
- for(int i=0; i<3; i++) {
- List<Integer> integerList = new ArrayList<>();
- integerList.add(0);
- integerList.add(1);
- integerList.add(2);
- listOfListsOfIntegers.add(integerList);
- }
-
- customer.setListOfListsOfIntegers(listOfListsOfIntegers);
-
- return customer;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/specific/JsonStreamsTest.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/specific/JsonStreamsTest.java
deleted file mode 100644
index d307607..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/specific/JsonStreamsTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.specific;
-
-import org.eclipse.persistence.json.bind.TestTypeToken;
-import org.junit.Test;
-
-import javax.json.bind.Jsonb;
-import javax.json.bind.JsonbBuilder;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.nio.charset.Charset;
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Tests calling JSONB with {@link java.util.stream.Stream} and {@link Readable}
- *
- * @author Roman Grigoriadi
- */
-public class JsonStreamsTest {
-
- private static final String CHARSET = "UTF8";
- private Jsonb jsonb = JsonbBuilder.create();
-
- @Test
- public void testUnmarshall() throws Exception {
-
- String json = "{\"key1\":\"value1\",\"key2\":\"value2\"}";
-
- Map<String, String> result = jsonb.fromJson(new InputStreamReader(new ByteArrayInputStream(json.getBytes(CHARSET)), Charset.forName(CHARSET)), new TestTypeToken<HashMap<String, String>>(){}.getType());
- assertMapValues(result);
-
- result = jsonb.fromJson(new ByteArrayInputStream(json.getBytes(CHARSET)), new TestTypeToken<HashMap<String, String>>() {}.getType());
- assertMapValues(result);
- }
-
- @Test
- public void testMarshall() throws Exception {
- String expected = "{\"key1\":\"value1\",\"key2\":\"value2\"}";
- int len = expected.getBytes(CHARSET).length;
-
- Map<String, String> strMap = new HashMap<>();
- strMap.put("key1", "value1");
- strMap.put("key2", "value2");
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream(len);
- jsonb.toJson(strMap, baos);
- assertEquals(expected, baos.toString(CHARSET));
-
- baos = new ByteArrayOutputStream(len);
- OutputStreamWriter writer = new OutputStreamWriter(baos, Charset.forName(CHARSET));
- jsonb.toJson(strMap, writer);
- writer.close();
-
- assertEquals(expected, baos.toString(CHARSET));
- }
-
- private void assertMapValues(Map<String, String> result) {
- assertEquals(2, result.size());
- assertEquals("value1", result.get("key1"));
- assertEquals("value2", result.get("key2"));
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/specific/NullTest.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/specific/NullTest.java
deleted file mode 100644
index b45293a..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/specific/NullTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.specific;
-
-import org.eclipse.persistence.json.bind.defaultmapping.specific.model.Street;
-import org.junit.Before;
-import org.junit.Test;
-
-import javax.json.bind.Jsonb;
-import javax.json.bind.JsonbBuilder;
-
-import static org.junit.Assert.assertNull;
-
-/**
- * @author Roman Grigoriadi
- */
-public class NullTest {
-
- private Jsonb jsonb;
-
- @Before
- public void before() {
- jsonb = JsonbBuilder.create();
- }
-
- @Test
- public void testSetsNullIntoFields() {
- String json = "{\"name\":null,\"number\":null}";
-
- Street result = jsonb.fromJson(json, Street.class);
- //these have default initialization value
- assertNull(result.getName());
- assertNull(result.getNumber());
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/specific/ObjectGraphTest.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/specific/ObjectGraphTest.java
deleted file mode 100644
index bb5f555..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/specific/ObjectGraphTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.specific;
-
-import org.eclipse.persistence.json.bind.internal.JsonBindingBuilder;
-import org.eclipse.persistence.json.bind.defaultmapping.specific.model.Customer;
-import org.junit.Test;
-
-import javax.json.bind.Jsonb;
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * @author Roman Grigoriadi
- */
-public class ObjectGraphTest extends CustomerTest {
-
- private static final String EXPECTED = "{\"addresses\":[{\"street\":{\"name\":\"Zoubkova\",\"number\":111},\"town\":\"Prague\"}],\"age\":33,\"friends\":{\"firstFriend\":{\"addresses\":[{\"street\":{\"name\":\"Zoubkova\",\"number\":111},\"town\":\"Prague\"}],\"age\":33,\"integers\":[0,1],\"listOfListsOfIntegers\":[[0,1,2],[0,1,2],[0,1,2]],\"name\":\"Jasons first friend\",\"stringIntegerMap\":{\"first\":1,\"second\":2},\"strings\":[\"green\",\"yellow\"]},\"secondFriend\":{\"addresses\":[{\"street\":{\"name\":\"Zoubkova\",\"number\":111},\"town\":\"Prague\"}],\"age\":33,\"integers\":[0,1],\"listOfListsOfIntegers\":[[0,1,2],[0,1,2],[0,1,2]],\"name\":\"Jasons second friend\",\"stringIntegerMap\":{\"first\":1,\"second\":2},\"strings\":[\"green\",\"yellow\"]}},\"integers\":[0,1],\"listOfListsOfIntegers\":[[0,1,2],[0,1,2],[0,1,2]],\"name\":\"Root Jason Customer\",\"stringIntegerMap\":{\"first\":1,\"second\":2},\"strings\":[\"green\",\"yellow\"]}";
-
- @Test
- public void testObjectToJson() {
- Customer customer = createCustomer("Root Jason Customer");
-
- Map<String, Customer> friends = new HashMap<>();
- friends.put("firstFriend", createCustomer("Jasons first friend"));
- friends.put("secondFriend", createCustomer("Jasons second friend"));
- customer.setFriends(friends);
-
- Jsonb jsonb = new JsonBindingBuilder().build();
- assertEquals(EXPECTED, jsonb.toJson(customer));
- }
-
- @Test
- public void testObjectFromJson() {
- Jsonb jsonb = new JsonBindingBuilder().build();
- Customer customer = jsonb.fromJson(EXPECTED, Customer.class);
- assertCustomerValues(customer, "Root Jason Customer");
- assertEquals(2, customer.getFriends().size());
- assertCustomerValues(customer.getFriends().get("firstFriend"), "Jasons first friend");
- assertCustomerValues(customer.getFriends().get("secondFriend"), "Jasons second friend");
- }
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/specific/OptionalTest.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/specific/OptionalTest.java
deleted file mode 100644
index a2d07f7..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/specific/OptionalTest.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Dmitry Kornilov - initial implementation
- ******************************************************************************/
-package org.eclipse.persistence.json.bind.defaultmapping.specific;
-
-import org.eclipse.persistence.json.bind.internal.JsonBindingBuilder;
-import org.eclipse.persistence.json.bind.defaultmapping.generics.model.ScalarValueWrapper;
-import org.junit.Test;
-
-import javax.json.bind.Jsonb;
-import java.util.Optional;
-import java.util.OptionalDouble;
-import java.util.OptionalInt;
-import java.util.OptionalLong;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Default mapping Optional* tests.
- *
- * @author Dmitry Kornilov
- */
-public class OptionalTest {
- @Test
- public void testMarshallOptional() {
- final Jsonb jsonb = (new JsonBindingBuilder()).build();
- assertEquals("{}", jsonb.toJson(new ScalarValueWrapper<>(OptionalInt.empty())));
- assertEquals("{}", jsonb.toJson(new ScalarValueWrapper<>(OptionalLong.empty())));
- assertEquals("{}", jsonb.toJson(new ScalarValueWrapper<>(OptionalDouble.empty())));
- assertEquals("{\"value\":10}", jsonb.toJson(new ScalarValueWrapper<>(OptionalInt.of(10))));
- assertEquals("{\"value\":100}", jsonb.toJson(new ScalarValueWrapper<>(OptionalLong.of(100L))));
- assertEquals("{\"value\":10.0}", jsonb.toJson(new ScalarValueWrapper<>(OptionalDouble.of(10.0D))));
- }
-
- @Test
- public void testMarshallOptionalObject() {
- final Jsonb jsonb = (new JsonBindingBuilder()).build();
- assertEquals("{}", jsonb.toJson(new ScalarValueWrapper<>(Optional.empty())));
- assertEquals("{\"id\":1,\"name\":\"Cust1\"}", jsonb.toJson(Optional.of(new Customer(1, "Cust1"))));
- }
-
- @Test
- public void testMarshallOptionalIntArray() {
- final Jsonb jsonb = (new JsonBindingBuilder()).build();
-
- final OptionalInt[] array = {OptionalInt.of(1), OptionalInt.of(2), OptionalInt.empty()};
- assertEquals("[1,2,null]", jsonb.toJson(array));
- }
-
- @Test
- public void testMarshallOptionalArray() {
- final Jsonb jsonb = (new JsonBindingBuilder()).build();
-
- final Optional[] array = {Optional.of(new Customer(1, "Cust1")), Optional.of(new Customer(2, "Cust2")), Optional.empty()};
- assertEquals("[{\"id\":1,\"name\":\"Cust1\"},{\"id\":2,\"name\":\"Cust2\"},null]", jsonb.toJson(array));
- }
-
- public static class Customer {
- private int id;
- private String name;
-
- public Customer() {
- }
-
- public Customer(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;
- }
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/specific/SpecificTest.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/specific/SpecificTest.java
deleted file mode 100644
index 2761300..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/specific/SpecificTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Dmitry Kornilov - initial implementation
- ******************************************************************************/
-package org.eclipse.persistence.json.bind.defaultmapping.specific;
-
-import org.eclipse.persistence.json.bind.internal.JsonBindingBuilder;
-import org.eclipse.persistence.json.bind.defaultmapping.generics.model.ScalarValueWrapper;
-import org.junit.Test;
-
-import javax.json.bind.Jsonb;
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Specific standard Java SE types tests: {@link BigDecimal}, {@link BigInteger}, {@link URL}, {@link URI}.
- *
- * @author Dmitry Kornilov
- */
-public class SpecificTest {
- @Test
- public void testMarshallBigDecimal() {
- final Jsonb jsonb = (new JsonBindingBuilder()).build();
- assertEquals("{\"value\":100}", jsonb.toJson(new ScalarValueWrapper<>(BigDecimal.valueOf(100L))));
- assertEquals("{\"value\":100.1}", jsonb.toJson(new ScalarValueWrapper<>(BigDecimal.valueOf(100.1D))));
- }
-
- @Test
- public void testMarshallBigInteger() {
- final Jsonb jsonb = (new JsonBindingBuilder()).build();
- assertEquals("{\"value\":100}", jsonb.toJson(new ScalarValueWrapper<>(BigInteger.valueOf(100))));
- }
-
- @Test
- public void testMarshallUri() throws URISyntaxException {
- final Jsonb jsonb = (new JsonBindingBuilder()).build();
- assertEquals("{\"value\":\"http://www.oracle.com\"}", jsonb.toJson(new ScalarValueWrapper<>(new URI("http://www.oracle.com"))));
- }
-
- @Test
- public void testMarshallUrl() throws MalformedURLException {
- final Jsonb jsonb = (new JsonBindingBuilder()).build();
- assertEquals("{\"value\":\"http://www.oracle.com\"}", jsonb.toJson(new ScalarValueWrapper<>(new URL("http://www.oracle.com"))));
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/specific/UnmarshallingUnsupportedTypesTest.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/specific/UnmarshallingUnsupportedTypesTest.java
deleted file mode 100644
index aad0958..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/specific/UnmarshallingUnsupportedTypesTest.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.specific;
-
-import org.eclipse.persistence.json.bind.defaultmapping.specific.model.ClassWithUnsupportedFields;
-import org.eclipse.persistence.json.bind.defaultmapping.specific.model.CustomUnsupportedInterface;
-import org.eclipse.persistence.json.bind.defaultmapping.specific.model.SupportedTypes;
-import org.junit.Test;
-
-import javax.json.bind.Jsonb;
-import javax.json.bind.JsonbBuilder;
-import javax.json.bind.JsonbException;
-import java.time.Instant;
-import java.time.LocalDateTime;
-import java.time.ZoneId;
-import java.time.ZonedDateTime;
-import java.util.OptionalLong;
-import java.util.logging.Logger;
-
-import static org.junit.Assert.*;
-
-/**
- * @author Roman Grigoriadi
- */
-public class UnmarshallingUnsupportedTypesTest {
-
- private final Jsonb jsonb = JsonbBuilder.create();
-
- private static final Logger logger = Logger.getLogger(UnmarshallingUnsupportedTypesTest.class.getSimpleName());
-
- @Test
- public void testUnmarshallToUnsupportedInterface() {
- ClassWithUnsupportedFields unsupported = new ClassWithUnsupportedFields();
- unsupported.customInterface = new CustomUnsupportedInterface() {
-
- private String value = "value1";
- @Override
- public String getValue() {
- return value;
- }
-
- @Override
- public void setValue(String value) {
- throw new IllegalStateException("Not supposed to be called.");
- }
- };
- String expected = "{\"customInterface\":{\"value\":\"value1\"}}";
- assertEquals(expected, jsonb.toJson(unsupported));
- try {
- jsonb.fromJson(expected, ClassWithUnsupportedFields.class);
- fail("Should report an error");
- } catch (JsonbException e) {
- assertTrue(e.getMessage().startsWith("Can't infer a type"));
- }
- }
-
- @Test
- public void testPojoForMalformedJson() throws Exception {
-
- SupportedTypes supportedTypes = new SupportedTypes();
- LocalDateTime localDateTime = LocalDateTime.of(2015, 12, 28, 15, 57);
- ZoneId prague = ZoneId.of("Europe/Prague");
- ZonedDateTime zonedDateTime = ZonedDateTime.of(localDateTime, prague);
- supportedTypes.setInstant(Instant.from(zonedDateTime));
- supportedTypes.setOptionalLong(OptionalLong.of(11L));
- supportedTypes.setZonedDateTime(zonedDateTime);
- supportedTypes.setNestedPojo(new SupportedTypes.NestedPojo());
- supportedTypes.getNestedPojo().setIntegerValue(10);
-
- String json = "{\"instant\":\"2015-12-28T14:57:00Z\",\"nestedPojo\":{\"integerValue\":10},\"optionalLong\":11,\"zonedDateTime\":\"2015-12-28T15:57:00+01:00[Europe/Prague]\"}";
- assertEquals(json, jsonb.toJson(supportedTypes));
-
- SupportedTypes result = jsonb.fromJson(json, SupportedTypes.class);
- assertEquals(result.getInstant(), supportedTypes.getInstant());
- assertEquals(result.getZonedDateTime(), supportedTypes.getZonedDateTime());
- assertEquals(result.getOptionalLong(), supportedTypes.getOptionalLong());
- assertEquals(Integer.valueOf(10), result.getNestedPojo().getIntegerValue());
-
- }
-
- @Test
- public void testSupportedTypeAsObjectInJson() {
- //wrong, instant is wrapped with {}, unmarshalls to object.
- String json = "{\"instant\":{\"instantWrongKey\":\"2015-12-28T14:57:00Z\"},\"optionalLong\":11}";
- assertFail(json, SupportedTypes.class, "Can't create instance of a class: class java.time.Instant, No default constructor found.");
- }
-
- @Test
- public void testPojoAsScalarValue() {
- //wrong, nestedPojo is a value.
- String json = "{\"nestedPojo\":\"10\",\"optionalLong\":11}";
- assertFail(json, SupportedTypes.class, "Error deserialize JSON value into type: class org.eclipse.persistence.json.bind.defaultmapping.specific.model.SupportedTypes$NestedPojo");
- }
-
- @Test
- public void testPojoAsArray() {
- //wrong, nestedPojo is a collection.
- String json = "{\"nestedPojo\":[\"10\"],\"optionalLong\":11}";
- assertFail(json, SupportedTypes.class, "Can't deserialize JSON array into: class org.eclipse.persistence.json.bind.defaultmapping.specific.model.SupportedTypes$NestedPojo");
- }
-
- @Test
- public void testMissingFieldInModel() {
- String json = "{\"nestedPojo\":{\"integerValue\":10,\"missingField\":5},\"optionalLong\":11}";
- SupportedTypes result = jsonb.fromJson(json, SupportedTypes.class);
- assertEquals(Integer.valueOf(10), result.getNestedPojo().getIntegerValue());
- assertEquals(11, result.getOptionalLong().getAsLong());
- }
-
- private void assertFail(String json, Class clazz, String msg) {
- try {
- jsonb.fromJson(json, clazz);
- fail();
- } catch (JsonbException e) {
- if(!e.getMessage().startsWith(msg)) {
- logger.severe("Exception message does not match");
- logger.severe("Expected: "+ msg);
- logger.severe("Current: "+e.getMessage());
- fail();
- }
- }
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/specific/model/Address.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/specific/model/Address.java
deleted file mode 100644
index 3e09cc5..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/specific/model/Address.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.specific.model;
-
-/**
- * @author Roman Grigoriadi
- */
-public class Address {
- private Street street;
-
- private String town;
-
- public Address() {
- }
-
- public Address(Street street, String town) {
- this.street = street;
- this.town = town;
- }
-
- public Street getStreet() {
- return street;
- }
-
- public void setStreet(Street street) {
- this.street = street;
- }
-
- public String getTown() {
- return town;
- }
-
- public void setTown(String town) {
- this.town = town;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/specific/model/ClassWithUnsupportedFields.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/specific/model/ClassWithUnsupportedFields.java
deleted file mode 100644
index d890611..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/specific/model/ClassWithUnsupportedFields.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.specific.model;
-
-/**
- * @author Roman Grigoriadi
- */
-public class ClassWithUnsupportedFields {
- public CustomUnsupportedInterface customInterface;
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/specific/model/CustomUnsupportedInterface.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/specific/model/CustomUnsupportedInterface.java
deleted file mode 100644
index 2a3ee16..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/specific/model/CustomUnsupportedInterface.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.specific.model;
-
-/**
- * Unmarhsalling to this interface is not supported.
- *
- * @author Roman Grigoriadi
- */
-public interface CustomUnsupportedInterface {
-
- String getValue();
-
- void setValue(String value);
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/specific/model/Customer.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/specific/model/Customer.java
deleted file mode 100644
index d643866..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/specific/model/Customer.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.specific.model;
-
-import java.util.List;
-import java.util.Map;
-
-/**
- * Just a dummy pojo object, for testing object tree encapsulation.
- * Not much business sense here to look for.
- *
- * @author Roman Grigoriadi
- */
-public class Customer {
-
- private List<Address> addresses;
-
- private List<String> strings;
-
- private List<Integer> integers;
-
- private List<List<Integer>> listOfListsOfIntegers;
-
- private Map<String, Integer> stringIntegerMap;
-
- private Map<String, Customer> friends;
-
- private Integer age;
-
- private String name;
-
- public Customer() {
- }
-
- public Customer(Integer age, String name) {
- this.age = age;
- this.name = name;
- }
-
- public List<Address> getAddresses() {
- return addresses;
- }
-
- public void setAddresses(List<Address> addresses) {
- this.addresses = addresses;
- }
-
- public Integer getAge() {
- return age;
- }
-
- public void setAge(Integer age) {
- this.age = age;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public List<String> getStrings() {
- return strings;
- }
-
- public void setStrings(List<String> strings) {
- this.strings = strings;
- }
-
- public List<Integer> getIntegers() {
- return integers;
- }
-
- public void setIntegers(List<Integer> integers) {
- this.integers = integers;
- }
-
- public Map<String, Integer> getStringIntegerMap() {
- return stringIntegerMap;
- }
-
- public void setStringIntegerMap(Map<String, Integer> stringIntegerMap) {
- this.stringIntegerMap = stringIntegerMap;
- }
-
- public Map<String, Customer> getFriends() {
- return friends;
- }
-
- public void setFriends(Map<String, Customer> friends) {
- this.friends = friends;
- }
-
- public List<List<Integer>> getListOfListsOfIntegers() {
- return listOfListsOfIntegers;
- }
-
- public void setListOfListsOfIntegers(List<List<Integer>> listOfListsOfIntegers) {
- this.listOfListsOfIntegers = listOfListsOfIntegers;
- }
-}
\ No newline at end of file
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/specific/model/Street.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/specific/model/Street.java
deleted file mode 100644
index c73d7d2..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/specific/model/Street.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.specific.model;
-
-/**
- * @author Roman Grigoriadi
- */
-public class Street {
- private String name = "defaultName";
- private Integer number = 11;
-
- public Street() {
- }
-
- public Street(String name, Integer number) {
- this.name = name;
- this.number = number;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public Integer getNumber() {
- return number;
- }
-
- public void setNumber(Integer number) {
- this.number = number;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/specific/model/SupportedTypes.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/specific/model/SupportedTypes.java
deleted file mode 100644
index 66ad02c..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/specific/model/SupportedTypes.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.defaultmapping.specific.model;
-
-import java.time.Instant;
-import java.time.ZonedDateTime;
-import java.util.OptionalLong;
-
-/**
- * @author Roman Grigoriadi
- */
-public class SupportedTypes {
-
- public static class NestedPojo {
-
- private Integer integerValue;
-
- public Integer getIntegerValue() {
- return integerValue;
- }
-
- public void setIntegerValue(Integer integerValue) {
- this.integerValue = integerValue;
- }
-
- }
-
- private Instant instant;
-
- private ZonedDateTime zonedDateTime;
-
- private OptionalLong optionalLong;
-
- private NestedPojo nestedPojo;
-
- public Instant getInstant() {
- return instant;
- }
-
- public void setInstant(Instant instant) {
- this.instant = instant;
- }
-
- public OptionalLong getOptionalLong() {
- return optionalLong;
- }
-
- public void setOptionalLong(OptionalLong optionalLong) {
- this.optionalLong = optionalLong;
- }
-
- public ZonedDateTime getZonedDateTime() {
- return zonedDateTime;
- }
-
- public void setZonedDateTime(ZonedDateTime zonedDateTime) {
- this.zonedDateTime = zonedDateTime;
- }
-
- public NestedPojo getNestedPojo() {
- return nestedPojo;
- }
-
- public void setNestedPojo(NestedPojo nestedPojo) {
- this.nestedPojo = nestedPojo;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/typeConvertors/DefaultSerializersTest.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/typeConvertors/DefaultSerializersTest.java
deleted file mode 100644
index 5e74a4d..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/typeConvertors/DefaultSerializersTest.java
+++ /dev/null
@@ -1,460 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- * <p>
- * Contributors:
- * Dmitry Kornilov - initial implementation
- ******************************************************************************/
-package org.eclipse.persistence.json.bind.defaultmapping.typeConvertors;
-
-import org.eclipse.persistence.json.bind.TestTypeToken;
-import org.eclipse.persistence.json.bind.defaultmapping.generics.model.ScalarValueWrapper;
-import org.eclipse.persistence.json.bind.defaultmapping.typeConvertors.model.ByteArrayWrapper;
-import org.eclipse.persistence.json.bind.internal.JsonBindingBuilder;
-import org.junit.Test;
-
-import javax.json.bind.Jsonb;
-import javax.json.bind.JsonbBuilder;
-import javax.json.bind.JsonbConfig;
-import javax.json.bind.config.BinaryDataStrategy;
-import java.util.Base64;
-
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
-
-/**
- * This class contains Convertor tests
- *
- * @author David Král
- */
-public class DefaultSerializersTest {
-
- private final Jsonb jsonb = JsonbBuilder.create();
-
- @Test
- public void testCharacter() {
- final String json = "{\"value\":\"\uFFFF\"}";
- assertEquals(json, jsonb.toJson(new ScalarValueWrapper<>('\uFFFF')));
- ScalarValueWrapper<Character> result = jsonb.fromJson(json, new TestTypeToken<ScalarValueWrapper<Character>>(){}.getType());
- assertEquals((Character)'\uFFFF', result.getValue());
- }
-
-
- //TODO uncoment all
-
- /*private DefaultSerializers serializers = DefaultSerializers.getInstance();
-
-
-
- @Test
- public void testBooleanConvetor() throws NoSuchFieldException {
- BooleanTypeConverter booleanTypeConverter = new BooleanTypeConverter();
- assertEquals("true", booleanTypeConverter.toJson(true, null));
- assertEquals(true, booleanTypeConverter.fromJson("true", Boolean.class, null));
- }
-
- @Test
- public void testCalendarConvetor() throws NoSuchFieldException {
- Jsonb jsonb = (new JsonBindingBuilder()).build();
- final Calendar dateCalendar = Calendar.getInstance();
- dateCalendar.clear();
- dateCalendar.set(2015, Calendar.APRIL, 3);
- CalendarWrapper calendarWrapper = new CalendarWrapper();
- calendarWrapper.calendar = dateCalendar;
-
- // marshal to ISO_DATE
- assertEquals("{\"calendar\":\"2015-04-03\"}", jsonb.toJson(calendarWrapper));
- assertEquals(dateCalendar, jsonb.fromJson("{\"calendar\":\"2015-04-03\"}", CalendarWrapper.class).calendar);
-
- // marshal to ISO_DATE_TIME
- Calendar dateTimeCalendar = new Calendar.Builder().setDate(2015, 3, 3).build();
- calendarWrapper.calendar = dateTimeCalendar;
-
- assertEquals("{\"calendar\":\"2015-04-03T00:00:00+02:00[Europe/Prague]\"}", jsonb.toJson(calendarWrapper));
- assertEquals(dateTimeCalendar, jsonb.fromJson("{\"calendar\":\"2015-04-03T00:00:00\"}", CalendarWrapper.class).calendar);
-
- jsonb = (new JsonBindingBuilder()).withConfig(new JsonbConfig().withStrictIJSON(true)).build();
- calendarWrapper.calendar = dateCalendar;
- assertEquals("{\"calendar\":\"2015-04-03T00:00:00+02:00[Europe/Prague]\"}", jsonb.toJson(calendarWrapper));
- assertEquals(dateTimeCalendar, jsonb.fromJson("{\"calendar\":\"2015-04-03T00:00:00\"}", CalendarWrapper.class).calendar);
- }
-
- @Test
- public void testDateConvetor() throws NoSuchFieldException, ParseException {
- DateTypeConverter dateTypeConverter = new DateTypeConverter();
- SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
- Date parsedDate = sdf.parse("04.03.2015 12:10:20");
-
- final PropertyCustomization defaultCustomization = buildDefaultDateFormatterCustomization();
-
- assertEquals("2015-03-04T12:10:20", dateTypeConverter.toJson(parsedDate, defaultCustomization));
- assertEquals(parsedDate, dateTypeConverter.fromJson("2015-03-04T12:10:20", null, defaultCustomization));
-
- sdf = new SimpleDateFormat("dd.MM.yyyy");
- parsedDate = sdf.parse("04.03.2015");
-
- assertEquals("2015-03-04T00:00:00", dateTypeConverter.toJson(parsedDate, defaultCustomization));
- assertEquals(parsedDate, dateTypeConverter.fromJson("2015-03-04T00:00:00", null, defaultCustomization));
- }
-
- @Test
- public void testDoubleConvetor() {
- DoubleTypeConverter doubleTypeConverter = new DoubleTypeConverter();
- assertEquals("1.2", doubleTypeConverter.toJson(1.2, null));
- assertEquals(1.2, doubleTypeConverter.fromJson("1.2", Double.class, null), 0);
-
- // Double.NEGATIVE_INFINITY
- assertEquals("NEGATIVE_INFINITY", doubleTypeConverter.toJson(Double.NEGATIVE_INFINITY, null));
- assertEquals(Double.NEGATIVE_INFINITY, doubleTypeConverter.fromJson("NEGATIVE_INFINITY", Double.class, null), 0);
-
- // Double.POSITIVE_INFINITY
- assertEquals("POSITIVE_INFINITY", doubleTypeConverter.toJson(Double.POSITIVE_INFINITY, null));
- assertEquals(Double.POSITIVE_INFINITY, doubleTypeConverter.fromJson("POSITIVE_INFINITY", Double.class, null), 0);
-
- // Double.NaN
- assertEquals("NaN", doubleTypeConverter.toJson(Double.NaN, null));
- assertEquals(Double.NaN, doubleTypeConverter.fromJson("NaN", Double.class, null), 0);
- }
-
- @Test
- public void testFloatConvetor() {
- FloatTypeConverter floatTypeConverter = new FloatTypeConverter();
- assertEquals("1.2", floatTypeConverter.toJson(1.2f, null));
- assertEquals(1.2f, floatTypeConverter.fromJson("1.2", Float.class, null), 0);
- }
-
- @Test
- public void testInstantConvetor() {
- InstantTypeConverter instantTypeConverter = new InstantTypeConverter();
- assertEquals("2015-03-03T23:00:00Z", instantTypeConverter.toJson(Instant.parse("2015-03-03T23:00:00Z"), null));
- assertEquals(Instant.parse("2015-03-03T23:00:00Z"), instantTypeConverter.fromJson("2015-03-03T23:00:00Z", Instant.class, null));
- }
-
- @Test
- public void testIntegerConvetor() {
-
- IntegerTypeConverter integerTypeConverter = new IntegerTypeConverter();
- assertEquals("1", integerTypeConverter.toJson(1, null));
- assertEquals(1, integerTypeConverter.fromJson("1", Integer.class, null), 0);
- assertEquals(1, integerTypeConverter.fromJson("1", int.class, null), 0);
- Integer actual = integerTypeConverter.fromJson("1", int.class, null);
- assertEquals(1, actual, 0);
- }
-
- @Test
- public void testLocalDateTimeConvetor() {
- LocalDateTimeTypeConverter localDateTimeTypeConverter = new LocalDateTimeTypeConverter();
-
- PropertyCustomization customization = buildDefaultDateFormatterCustomization();
- assertEquals("2015-02-16T13:21:00", localDateTimeTypeConverter.toJson(LocalDateTime.of(2015, 2, 16, 13, 21), customization));
- assertEquals(LocalDateTime.of(2015, 2, 16, 13, 21), localDateTimeTypeConverter.fromJson("2015-02-16T13:21:00", LocalDateTime.class, customization));
- }
-
- @Test
- public void testLocalDateConvetor() {
- LocalDateTypeConverter localDateTypeConverter = new LocalDateTypeConverter();
-
- final PropertyCustomization defaultCustomization = buildDefaultDateFormatterCustomization();
-
- assertEquals("2013-08-10", localDateTypeConverter.toJson(LocalDate.of(2013, Month.AUGUST, 10), defaultCustomization));
- assertEquals(LocalDate.of(2013, Month.AUGUST, 10), localDateTypeConverter.fromJson("2013-08-10", LocalDate.class, defaultCustomization));
- }
-
- private PropertyCustomization buildDefaultDateFormatterCustomization() {
- JsonbDateFormatter formatter = new JsonbDateFormatter(JsonbDateFormat.DEFAULT_FORMAT, Locale.getDefault());
- return new CustomizationBuilder()
- .setDateFormatter(formatter).buildPropertyCustomization();
- }
-
- @Test
- public void testLocalTimeConvetor() {
- LocalTimeTypeConverter localTimeTypeConverter = new LocalTimeTypeConverter();
-
- PropertyCustomization customization = buildDefaultDateFormatterCustomization();
- assertEquals("22:33:00", localTimeTypeConverter.toJson(LocalTime.of(22, 33), customization));
- assertEquals(LocalTime.of(22, 33), localTimeTypeConverter.fromJson("22:33:00", LocalTime.class, customization));
- }
-
- @Test
- public void testLongConvetor() {
- LongTypeConverter longTypeConverter = new LongTypeConverter();
-
- assertEquals("10", longTypeConverter.toJson(10L, null));
- assertEquals(10L, longTypeConverter.fromJson("10", Long.class, null), 0);
- }
-
- @Test
- public void testNumberConvetor() {
- NumberTypeConverter numberTypeConverter = new NumberTypeConverter();
-
- assertEquals("10.0", numberTypeConverter.toJson(10L, null));
- assertEquals("10.1", numberTypeConverter.toJson(10.1, null));
- assertEquals(new BigDecimal("10.2"), numberTypeConverter.fromJson("10.2", null, null));
- }
-
- @Test
- public void testOffsetDateTimeConvetor() {
- OffsetDateTimeTypeConverter offsetDateTimeTypeConverter = new OffsetDateTimeTypeConverter();
-
- PropertyCustomization customization = buildDefaultDateFormatterCustomization();
- assertEquals("2015-02-16T13:21:00+02:00",
- offsetDateTimeTypeConverter.toJson(OffsetDateTime.of(2015, 2, 16, 13, 21, 0, 0, ZoneOffset.of("+02:00")), customization));
- assertEquals(OffsetDateTime.of(2015, 2, 16, 13, 21, 0, 0, ZoneOffset.of("+02:00")), offsetDateTimeTypeConverter.fromJson("2015-02-16T13:21:00+02:00", null, customization));
- }
-
- *//* @Test
- public void testOffsetTimeConvetor() {
- OffsetTimeTypeDeserializer offsetTimeTypeDeserializer = new OffsetTimeTypeDeserializer();
-
- PropertyCustomization customization = buildDefaultDateFormatterCustomization();
- assertEquals("13:21:15.000000016+02:00", offsetTimeTypeDeserializer.toJson(OffsetTime.of(13, 21, 15, 16, ZoneOffset.of("+02:00")), customization));
- assertEquals(OffsetTime.of(13, 21, 15, 16, ZoneOffset.of("+02:00")), offsetTimeTypeDeserializer.fromJson("13:21:15.000000016+02:00", null, customization));
- }*//*
-
- @Test
- public void testOptionalIntConvetor() {
- OptionalIntTypeConverter optionalIntTypeConverter = new OptionalIntTypeConverter();
-
- assertEquals("null", optionalIntTypeConverter.toJson(OptionalInt.empty(), null));
- assertEquals("10", optionalIntTypeConverter.toJson(OptionalInt.of(10), null));
- assertEquals(OptionalInt.empty(), optionalIntTypeConverter.fromJson("null", null, null));
- assertEquals(OptionalInt.of(10), optionalIntTypeConverter.fromJson("10", null, null));
- }
-
- @Test
- public void testOptionalDoubleConvetor() {
- OptionalDoubleTypeConverter optionalDoubleTypeConverter = new OptionalDoubleTypeConverter();
-
- assertEquals("null", optionalDoubleTypeConverter.toJson(OptionalDouble.empty(), null));
- assertEquals("10.0", optionalDoubleTypeConverter.toJson(OptionalDouble.of(10), null));
- assertEquals("10.1", optionalDoubleTypeConverter.toJson(OptionalDouble.of(10.1), null));
- assertEquals("POSITIVE_INFINITY", optionalDoubleTypeConverter.toJson(OptionalDouble.of(Double.POSITIVE_INFINITY), null));
- assertEquals("NEGATIVE_INFINITY", optionalDoubleTypeConverter.toJson(OptionalDouble.of(Double.NEGATIVE_INFINITY), null));
- assertEquals("NaN", optionalDoubleTypeConverter.toJson(OptionalDouble.of(Double.NaN), null));
- assertEquals(OptionalDouble.empty(), optionalDoubleTypeConverter.fromJson("null", null, null));
- assertEquals(OptionalDouble.of(10), optionalDoubleTypeConverter.fromJson("10", null, null));
- assertEquals(OptionalDouble.of(10.1), optionalDoubleTypeConverter.fromJson("10.1", null, null));
- assertEquals(OptionalDouble.of(Double.POSITIVE_INFINITY), optionalDoubleTypeConverter.fromJson("POSITIVE_INFINITY", null, null));
- assertEquals(OptionalDouble.of(Double.NEGATIVE_INFINITY), optionalDoubleTypeConverter.fromJson("NEGATIVE_INFINITY", null, null));
- assertEquals(OptionalDouble.of(Double.NaN), optionalDoubleTypeConverter.fromJson("NaN", null, null));
- }
-
- @Test
- public void testOptionalLongConvetor() {
- OptionalLongTypeConverter optionalLongTypeConverter = new OptionalLongTypeConverter();
-
- assertEquals("null", optionalLongTypeConverter.toJson(OptionalLong.empty(), null));
- assertEquals("10", optionalLongTypeConverter.toJson(OptionalLong.of(10L), null));
- assertEquals(OptionalLong.empty(), optionalLongTypeConverter.fromJson("null", null, null));
- assertEquals(OptionalLong.of(10L), optionalLongTypeConverter.fromJson("10", null, null));
- }
-
- @Test
- public void testShortConvetor() {
- ShortTypeConverter shortTypeConverter = new ShortTypeConverter();
-
- assertEquals("10", shortTypeConverter.toJson((short) 10, null));
- assertEquals((short) 10, shortTypeConverter.fromJson("10", null, null), 0);
- }
-
- @Test
- public void testStringConvetor() {
- Jsonb jsonb = (new JsonBindingBuilder()).withConfig(new JsonbConfig().withStrictIJSON(true)).build();
- StringWrapper stringWrapper = new StringWrapper();
- stringWrapper.string = "test";
-
- assertEquals("{\"string\":\"test\"}", jsonb.toJson(stringWrapper));
- try {
- stringWrapper.string = "\uDEAD";
- assertEquals("{\"string\":\"?\"}", jsonb.toJson(stringWrapper));
- Assert.fail();
- } catch (JsonbException exception) {
- assertEquals(Messages.getMessage(MessageKeys.UNPAIRED_SURROGATE), exception.getMessage());
- }
- try {
- stringWrapper.string = "\uD800\uDEAD";
- jsonb.toJson(stringWrapper);
- } catch (JsonbException exception) {
- exception.printStackTrace();
- Assert.fail();
- }
- }
-
- @Test
- public void testTimeZoneConvetor() {
- TimeZoneTypeConverter timeZoneTypeConverter = new TimeZoneTypeConverter();
-
- assertEquals("Europe/Prague", timeZoneTypeConverter.toJson(TimeZone.getTimeZone("Europe/Prague"), null));
- assertEquals(TimeZone.getTimeZone("Europe/Prague"), timeZoneTypeConverter.fromJson("Europe/Prague", null, null));
-
- try {
- timeZoneTypeConverter.fromJson("PST", null, null);
- Assert.fail();
- } catch (JsonbException ex) {
- assertEquals("Unsupported TimeZone: PST", ex.getMessage());
- }
- }
-
- @Test
- public void testUriConvertor() throws URISyntaxException {
- URITypeConverter uriTypeConverter = new URITypeConverter();
-
- assertEquals("http://www.oracle.com", uriTypeConverter.toJson(new URI("http://www.oracle.com"), null));
- assertEquals(new URI("http://www.oracle.com"), uriTypeConverter.fromJson("http://www.oracle.com", null, null));
- }
-
- @Test
- public void testUrlConvertor() throws MalformedURLException {
- URLTypeConverter urlTypeConverter = new URLTypeConverter();
-
- assertEquals("http://www.oracle.com", urlTypeConverter.toJson(new URL("http://www.oracle.com"), null));
- assertEquals(new URL("http://www.oracle.com"), urlTypeConverter.fromJson("http://www.oracle.com", null, null));
- }
-
- @Test
- public void testZonedDateTimeConvertor() {
- ZonedDateTimeTypeConverter zonedDateTimeTypeConverter = new ZonedDateTimeTypeConverter();
-
- PropertyCustomization customization = buildDefaultDateFormatterCustomization();
- assertEquals("2015-02-16T13:21:00+01:00[Europe/Prague]",
- zonedDateTimeTypeConverter.toJson(ZonedDateTime.of(2015, 2, 16, 13, 21, 0, 0, ZoneId.of("Europe/Prague")), customization));
- assertEquals(ZonedDateTime.of(2015, 2, 16, 13, 21, 0, 0, ZoneId.of("Europe/Prague")),
- zonedDateTimeTypeConverter.fromJson("2015-02-16T13:21:00+01:00[Europe/Prague]", null, customization));
- }
-
- @Test
- public void testEnum() {
- EnumTypeConverter enumTypeConverter = new EnumTypeConverter();
-
- assertEquals("HIGH", enumTypeConverter.toJson(Level.HIGH, null));
- assertEquals(Level.HIGH, enumTypeConverter.fromJson("HIGH", Level.class, null));
- }
-
- public enum Level {
- HIGH,
- MEDIUM,
- LOW
- }
-
- @Test
- public void testBigDecimal() {
- final Jsonb jsonb = (new JsonBindingBuilder().withConfig(new JsonbConfig().withStrictIJSON(true))).build();
-
- BigDecimalWrapper bigDecimalWrapper = new BigDecimalWrapper();
- bigDecimalWrapper.bigDecimal = new BigDecimal("-9007199254740991.0123");
-
- assertEquals("{\"bigDecimal\":\"-9007199254740991.0123\"}", jsonb.toJson(bigDecimalWrapper));
- assertEquals(bigDecimalWrapper.bigDecimal, jsonb.fromJson("{\"bigDecimal\":\"-9007199254740991.0123\"}", BigDecimalWrapper.class).bigDecimal);
-
- bigDecimalWrapper.bigDecimal = new BigDecimal("3.141592653589793238462643383279");
- assertEquals("{\"bigDecimal\":\"3.141592653589793238462643383279\"}", jsonb.toJson(bigDecimalWrapper));
- assertEquals(bigDecimalWrapper.bigDecimal, jsonb.fromJson("{\"bigDecimal\":\"3.141592653589793238462643383279\"}", BigDecimalWrapper.class).bigDecimal);
-
- bigDecimalWrapper.bigDecimal = new BigDecimal(new BigInteger("1"), -400);
- assertEquals("{\"bigDecimal\":\"1E+400\"}", jsonb.toJson(bigDecimalWrapper));
- assertEquals(bigDecimalWrapper.bigDecimal, jsonb.fromJson("{\"bigDecimal\":\"1E+400\"}", BigDecimalWrapper.class).bigDecimal);
-
- bigDecimalWrapper.bigDecimal = new BigDecimal("9007199254740991");
- assertEquals("{\"bigDecimal\":9007199254740991}", jsonb.toJson(bigDecimalWrapper));
- assertEquals(bigDecimalWrapper.bigDecimal, jsonb.fromJson("{\"bigDecimal\":9007199254740991}", BigDecimalWrapper.class).bigDecimal);
- }
-
- @Test
- public void testBigInteger() {
- final Jsonb jsonb = (new JsonBindingBuilder().withConfig(new JsonbConfig().withStrictIJSON(true))).build();
-
- BigIntegerWrapper bigIntegerWrapper = new BigIntegerWrapper();
-
- bigIntegerWrapper.bigInteger = new BigInteger("9007199254740991");
- assertEquals("{\"bigInteger\":9007199254740991}", jsonb.toJson(bigIntegerWrapper));
- assertEquals(bigIntegerWrapper.bigInteger, jsonb.fromJson("{\"bigInteger\":9007199254740991}", BigIntegerWrapper.class).bigInteger);
-
- bigIntegerWrapper.bigInteger = new BigInteger("9007199254740992");
- assertEquals("{\"bigInteger\":\"9007199254740992\"}", jsonb.toJson(bigIntegerWrapper));
- assertEquals(bigIntegerWrapper.bigInteger, jsonb.fromJson("{\"bigInteger\":\"9007199254740992\"}", BigIntegerWrapper.class).bigInteger);
-
- bigIntegerWrapper.bigInteger = new BigInteger("-9007199254740992");
- assertEquals("{\"bigInteger\":\"-9007199254740992\"}", jsonb.toJson(bigIntegerWrapper));
- assertEquals(bigIntegerWrapper.bigInteger, jsonb.fromJson("{\"bigInteger\":\"-9007199254740992\"}", BigIntegerWrapper.class).bigInteger);
- }
-
-
-
-
-
- */
-
- @Test
- public void testByteArray() {
- byte[] array = {1, 2, 3};
- final Jsonb jsonb = (new JsonBindingBuilder()).build();
-
- assertEquals("[1,2,3]", jsonb.toJson(array));
- }
-
- @Test
- public void testByteArrayWithBinaryStrategy() {
- byte[] array = {127, -128, 127};
- Jsonb jsonb = (new JsonBindingBuilder().withConfig(new JsonbConfig().withBinaryDataStrategy(BinaryDataStrategy.BYTE))).build();
-
- assertEquals("[127,-128,127]", jsonb.toJson(array));
- assertArrayEquals(array, jsonb.fromJson("[127,-128,127]", byte[].class));
- }
-
- @Test
- public void testByteArrayWithStrictJson() {
- byte[] array = {1, 2, 3};
- ByteArrayWrapper byteArrayWrapper = new ByteArrayWrapper();
- byteArrayWrapper.array = array;
- Jsonb jsonb = (new JsonBindingBuilder().withConfig(new JsonbConfig().withStrictIJSON(true))).build();
-
- assertEquals("{\"array\":\"" + Base64.getUrlEncoder().encodeToString(array) + "\"}", jsonb.toJson(byteArrayWrapper));
-
- jsonb = (new JsonBindingBuilder().withConfig(new JsonbConfig().withStrictIJSON(false))).build();
-
- assertEquals("{\"array\":[1,2,3]}", jsonb.toJson(byteArrayWrapper));
- }
-
- @Test
- public void testByteArrayWithStrictJsonAndBinaryStrategy() {
- byte[] array = {1, 2, 3};
- ByteArrayWrapper byteArrayWrapper = new ByteArrayWrapper();
- byteArrayWrapper.array = array;
- Jsonb jsonb = (new JsonBindingBuilder().withConfig(new JsonbConfig().withStrictIJSON(true).withBinaryDataStrategy(BinaryDataStrategy.BYTE))).build();
- final String base64UrlEncodedJson = "{\"array\":\"" + Base64.getUrlEncoder().encodeToString(array) + "\"}";
- assertEquals(base64UrlEncodedJson, jsonb.toJson(byteArrayWrapper));
- ByteArrayWrapper result = jsonb.fromJson(base64UrlEncodedJson, ByteArrayWrapper.class);
- assertArrayEquals(array, result.array);
-
- jsonb = (new JsonBindingBuilder().withConfig(new JsonbConfig().withStrictIJSON(true).withBinaryDataStrategy(BinaryDataStrategy.BASE_64))).build();
- assertEquals(base64UrlEncodedJson, jsonb.toJson(byteArrayWrapper));
- result = jsonb.fromJson(base64UrlEncodedJson, ByteArrayWrapper.class);
- assertArrayEquals(array, result.array);
-
- jsonb = (new JsonBindingBuilder().withConfig(new JsonbConfig().withStrictIJSON(true).withBinaryDataStrategy(BinaryDataStrategy.BASE_64_URL))).build();
- assertEquals(base64UrlEncodedJson, jsonb.toJson(byteArrayWrapper));
- result = jsonb.fromJson(base64UrlEncodedJson, ByteArrayWrapper.class);
- assertArrayEquals(array, result.array);
-
- jsonb = (new JsonBindingBuilder().withConfig(new JsonbConfig().withBinaryDataStrategy(BinaryDataStrategy.BYTE))).build();
- assertEquals("[1,2,3]", jsonb.toJson(array));
- result = jsonb.fromJson("{\"array\":[1,2,3]}", ByteArrayWrapper.class);
- assertArrayEquals(array, result.array);
-
- jsonb = (new JsonBindingBuilder().withConfig(new JsonbConfig().withBinaryDataStrategy(BinaryDataStrategy.BASE_64))).build();
- final String base64EncodedJson = "{\"array\":\"" + Base64.getEncoder().encodeToString(array) + "\"}";
- assertEquals(base64EncodedJson, jsonb.toJson(byteArrayWrapper));
- result = jsonb.fromJson(base64EncodedJson, ByteArrayWrapper.class);
- assertArrayEquals(array, result.array);
-
- jsonb = (new JsonBindingBuilder().withConfig(new JsonbConfig().withBinaryDataStrategy(BinaryDataStrategy.BASE_64_URL))).build();
- assertEquals(base64UrlEncodedJson, jsonb.toJson(byteArrayWrapper));
- result = jsonb.fromJson(base64UrlEncodedJson, ByteArrayWrapper.class);
- assertArrayEquals(array, result.array);
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/typeConvertors/model/BigDecimalWrapper.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/typeConvertors/model/BigDecimalWrapper.java
deleted file mode 100644
index 0a960d8..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/typeConvertors/model/BigDecimalWrapper.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.eclipse.persistence.json.bind.defaultmapping.typeConvertors.model;
-
-import java.math.BigDecimal;
-
-/**
- * Created by David Kral.
- */
-public class BigDecimalWrapper {
-
- public BigDecimal bigDecimal;
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/typeConvertors/model/BigIntegerWrapper.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/typeConvertors/model/BigIntegerWrapper.java
deleted file mode 100644
index 9f5e388..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/typeConvertors/model/BigIntegerWrapper.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.eclipse.persistence.json.bind.defaultmapping.typeConvertors.model;
-
-import java.math.BigInteger;
-
-/**
- * Created by David Kral.
- */
-public class BigIntegerWrapper {
-
- public BigInteger bigInteger;
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/typeConvertors/model/ByteArrayWrapper.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/typeConvertors/model/ByteArrayWrapper.java
deleted file mode 100644
index b7c24f6..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/typeConvertors/model/ByteArrayWrapper.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.eclipse.persistence.json.bind.defaultmapping.typeConvertors.model;
-
-/**
- * Created by David Kral.
- */
-public class ByteArrayWrapper {
-
- public byte[] array;
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/typeConvertors/model/CalendarWrapper.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/typeConvertors/model/CalendarWrapper.java
deleted file mode 100644
index 9058c14..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/typeConvertors/model/CalendarWrapper.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package org.eclipse.persistence.json.bind.defaultmapping.typeConvertors.model;
-
-import java.util.Calendar;
-
-/**
- * Created by David Kral.
- */
-public class CalendarWrapper {
-
- public Calendar calendar;
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/typeConvertors/model/StringWrapper.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/typeConvertors/model/StringWrapper.java
deleted file mode 100644
index 998e8f5..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/defaultmapping/typeConvertors/model/StringWrapper.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.eclipse.persistence.json.bind.defaultmapping.typeConvertors.model;
-
-/**
- * Created by David Kral.
- */
-public class StringWrapper {
-
- public String string;
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/ClassParserTest.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/ClassParserTest.java
deleted file mode 100644
index c7a15c0..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/ClassParserTest.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal;
-
-import org.eclipse.persistence.json.bind.defaultmapping.modifiers.model.FieldModifiersClass;
-import org.eclipse.persistence.json.bind.defaultmapping.modifiers.model.MethodModifiersClass;
-import org.eclipse.persistence.json.bind.internal.cdi.DefaultConstructorCreator;
-import org.eclipse.persistence.json.bind.model.ClassModel;
-import org.eclipse.persistence.json.bind.model.JsonbAnnotatedElement;
-import org.junit.Before;
-import org.junit.Test;
-
-import javax.json.bind.JsonbConfig;
-import javax.json.spi.JsonProvider;
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.function.Consumer;
-
-import static org.junit.Assert.*;
-
-/**
- * Test for ClassParser component.
- *
- * @author Roman Grigoriadi
- */
-public class ClassParserTest {
-
- private ClassParser classParser;
-
- private JsonbContext jsonbContext;
-
- private AnnotationIntrospector introspector;
-
- @Before
- public void before() {
- jsonbContext = new JsonbContext(new JsonbConfig(), JsonProvider.provider());
- classParser = new ClassParser(jsonbContext);
- introspector = new AnnotationIntrospector(jsonbContext);
- }
-
- @Test
- public void testDefaultMappingFieldModifiers() {
- final JsonbAnnotatedElement<Class<?>> clsElement = introspector.collectAnnotations(FieldModifiersClass.class);
- ClassModel model = new ClassModel(FieldModifiersClass.class, introspector.introspectCustomization(clsElement), null, null);
- classParser.parseProperties(model, clsElement);
- assertTrue(model.getPropertyModel("finalString").isReadable());
- assertFalse(model.getPropertyModel("finalString").isWritable());
- assertFalse(model.getPropertyModel("staticString").isReadable());
- assertFalse(model.getPropertyModel("staticString").isWritable());
- assertFalse(model.getPropertyModel("transientString").isReadable());
- assertFalse(model.getPropertyModel("transientString").isWritable());
-
- }
-
- @Test
- public void testDefaultMappingMethodModifiers() {
- final JsonbAnnotatedElement<Class<?>> clsElement = introspector.collectAnnotations(MethodModifiersClass.class);
- ClassModel model = new ClassModel(FieldModifiersClass.class, introspector.introspectCustomization(clsElement), null, null);
- classParser.parseProperties(model, clsElement);
- assertFalse(model.getPropertyModel("publicFieldWithPrivateMethods").isReadable());
- assertFalse(model.getPropertyModel("publicFieldWithPrivateMethods").isWritable());
- assertTrue(model.getPropertyModel("publicFieldWithoutMethods").isReadable());
- assertTrue(model.getPropertyModel("publicFieldWithoutMethods").isWritable());
- assertTrue(model.getPropertyModel("getterWithoutFieldValue").isReadable());
- assertTrue(model.getPropertyModel("getterWithoutFieldValue").isWritable());
-
-
- MethodModifiersClass object = new MethodModifiersClass();
- final AtomicReference<String> accepted = new AtomicReference<>();
- Consumer<String> withoutFieldConsumer = accepted::set;
- object.setSetterWithoutFieldConsumer(withoutFieldConsumer);
- model.getPropertyModel("getterWithoutFieldValue").setValue(object, "ACCEPTED_VALUE");
- assertEquals("ACCEPTED_VALUE", accepted.get());
- }
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/ReflectionUtilsTest.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/ReflectionUtilsTest.java
deleted file mode 100644
index f26370a..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/ReflectionUtilsTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-package org.eclipse.persistence.json.bind.internal;
-
-import org.junit.Test;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Type;
-import java.util.List;
-import java.util.Map;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-/**
- * @author Roman Grigoriadi
- */
-public class ReflectionUtilsTest {
-
- public static class Types<T> {
-
- public List<String> resolvedParameterizedField;
-
- public List<Map<Integer, String>> resolvedNestedParameterizedField;
-
- public String resolvedStr;
-
- public List<T> unresovledParameterizedField;
-
- public List<Map<Integer, T>> unresovledNestedParameterizedField;
-
- public T unresolvedField;
-
- public List<?> unresolvedWildcardField;
- }
-
-
- @Test
- public void testIsTypeResolved() {
- Types<String> types = new Types<String>();
- assertTrue(ReflectionUtils.isResolvedType(getFieldType("resolvedParameterizedField")));
- assertTrue(ReflectionUtils.isResolvedType(getFieldType("resolvedNestedParameterizedField")));
- assertTrue(ReflectionUtils.isResolvedType(getFieldType("resolvedStr")));
- assertFalse(ReflectionUtils.isResolvedType(getFieldType("unresovledParameterizedField")));
- assertFalse(ReflectionUtils.isResolvedType(getFieldType("unresovledNestedParameterizedField")));
- assertFalse(ReflectionUtils.isResolvedType(getFieldType("unresolvedField")));
- assertFalse(ReflectionUtils.isResolvedType(getFieldType("unresolvedWildcardField")));
- }
-
- private Type getFieldType(String fieldName) {
- try {
- Field field = Types.class.getField(fieldName);
- return field.getGenericType();
- } catch (NoSuchFieldException e) {
- throw new RuntimeException(e);
- }
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/AdaptedPojo.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/AdaptedPojo.java
deleted file mode 100644
index b2890d5..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/AdaptedPojo.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.cdi;
-
-import javax.json.bind.annotation.JsonbTypeAdapter;
-
-/**
- * @author Roman Grigoriadi
- */
-
-public class AdaptedPojo {
-
- @JsonbTypeAdapter(CdiDependentAdapter.class)
- public String adaptedValue1 = "1111";
-
- @JsonbTypeAdapter(CdiDependentAdapter.class)
- public String adaptedValue2 = "1001";
-
- @JsonbTypeAdapter(NonCdiAdapter.class)
- public String adaptedValue3 = "1010";
-
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/CalledMethods.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/CalledMethods.java
deleted file mode 100644
index 0e934e3..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/CalledMethods.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.cdi;
-
-import javax.enterprise.context.ApplicationScoped;
-import javax.enterprise.event.Observes;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Mockito like method call counter for CDI beans.
- *
- * @author Roman Grigoriadi
- */
-@ApplicationScoped
-public class CalledMethods {
-
- /**
- * Maps method name to called count.
- */
- private Map<String, Integer> results = new HashMap<>();
-
- /**
- * Returns if method was called.
- * @param methodName
- * @return
- */
- public boolean isCalled(String methodName) {
- return results.containsKey(methodName);
- }
-
- public void registerCall(@Observes MethodCalledEvent methodCalledEvent) {
- results.compute(methodCalledEvent.getMethdoName(), (s, c) -> c == null ? 1 : c + 1);
- }
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/CdiDependentAdapter.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/CdiDependentAdapter.java
deleted file mode 100644
index 2cff6f8..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/CdiDependentAdapter.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.cdi;
-
-import javax.enterprise.context.ApplicationScoped;
-import javax.inject.Inject;
-import javax.json.bind.adapter.JsonbAdapter;
-
-/**
- * Test scope adapter for testing CDI injection and cleanup.
- *
- * @author Roman Grigoriadi
- */
-@ApplicationScoped
-public class CdiDependentAdapter implements JsonbAdapter<String, Integer> {
-
- @Inject
- private CdiTestService cdiTestService;
-
- @Inject
- @Hello2
- private IHelloService helloService;
-
- @Override
- public Integer adaptToJson(String obj) throws Exception {
- cdiTestService.runService();
- helloService.sayHello();
- return Integer.valueOf(obj);
- }
-
- @Override
- public String adaptFromJson(Integer obj) throws Exception {
- return String.valueOf(obj);
- }
-
- public CdiTestService getCdiTestService() {
- return cdiTestService;
- }
-
- public IHelloService getHelloService() {
- return helloService;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/CdiInjectionTest.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/CdiInjectionTest.java
deleted file mode 100644
index b5978da..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/CdiInjectionTest.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.cdi;
-
-import org.junit.Test;
-
-import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.inject.spi.BeanManager;
-import javax.enterprise.inject.spi.CDI;
-import javax.json.bind.Jsonb;
-import javax.json.bind.JsonbBuilder;
-import javax.json.bind.JsonbConfig;
-import javax.json.bind.config.PropertyVisibilityStrategy;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-import static org.junit.Assert.*;
-
-/**
- * @author Roman Grigoriadi
- */
-public class CdiInjectionTest {
-
- private CalledMethods calledMethods;
-
- @Test
- public void testInjectionAndCleanup() throws Exception {
- WeldManager weldManager = new WeldManager();
- weldManager.startWeld(CalledMethods.class, CdiTestService.class, HelloService1.class, HelloService2.class);
-
- Jsonb jsonb = JsonbBuilder.create();
- final String result = jsonb.toJson(new AdaptedPojo());
- jsonb.close();
- assertEquals("{\"adaptedValue1\":1111,\"adaptedValue2\":1001,\"adaptedValue3\":1010}", result);
-
- //HelloService1 is @ApplicationScoped
- assertTrue(getCalledMethods().isCalled(HelloService1.class.getName() + ".sayHello"));
- assertFalse(getCalledMethods().isCalled(HelloService1.class.getName() + ".preDestroy"));
-
- //HelloService2 is @Dependent
- assertTrue(getCalledMethods().isCalled(HelloService2.class.getName() + ".sayHello"));
- assertTrue(getCalledMethods().isCalled(HelloService2.class.getName() + ".preDestroy"));
-
- //CdiTestService is @ApplicationScoped
- assertTrue(getCalledMethods().isCalled(CdiTestService.class.getName() + ".runService"));
- assertFalse(getCalledMethods().isCalled(CdiTestService.class.getName() + ".preDestroy"));
-// getCalledMethods().printCalled();
-
-
- weldManager.shutdownWeld();
-
- assertTrue(getCalledMethods().isCalled(CdiTestService.class.getName() + ".preDestroy"));
- assertTrue(getCalledMethods().isCalled(HelloService1.class.getName() + ".preDestroy"));
-
-// getCalledMethods().printCalled();
- }
-
- @Test
- public void testNonCdiEnvironment() {
- JsonbConfig config = new JsonbConfig();
- //allow only field with adapter that doesn't has cdi dependencies.
- config.withPropertyVisibilityStrategy(new PropertyVisibilityStrategy() {
- @Override
- public boolean isVisible(Field field) {
- return "adaptedValue3".equals(field.getName());
- }
-
- @Override
- public boolean isVisible(Method method) {
- return false;
- }
- });
- Jsonb jsonb = JsonbBuilder.create(config);
- final String result = jsonb.toJson(new AdaptedPojo());
- assertEquals("{\"adaptedValue3\":1010}", result);
- }
-
- private CalledMethods getCalledMethods() {
- if (calledMethods == null) {
- final BeanManager beanManager = CDI.current().getBeanManager();
- final Bean<?> resolve = beanManager.resolve(beanManager.getBeans(CalledMethods.class));
- calledMethods = (CalledMethods) beanManager.getReference(resolve, CalledMethods.class, beanManager.createCreationalContext(resolve));
- }
- return calledMethods;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/CdiTestService.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/CdiTestService.java
deleted file mode 100644
index 7553e46..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/CdiTestService.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.cdi;
-
-import javax.annotation.PreDestroy;
-import javax.enterprise.context.ApplicationScoped;
-import javax.enterprise.event.Event;
-import javax.inject.Inject;
-
-/**
- * CDI test service
- * @author Roman Grigoriadi
- */
-@ApplicationScoped
-public class CdiTestService {
-
- @Inject
- private Event<MethodCalledEvent> calledEvent;
-
- @Inject
- @Hello1
- private IHelloService helloService;
-
- public CdiTestService() {
- }
-
- public void runService() {
- helloService.sayHello();
- calledEvent.fire(new MethodCalledEvent(getClass().getName() + ".runService"));
- }
-
- @PreDestroy
- public void preDestroy() {
- calledEvent.fire(new MethodCalledEvent(getClass().getName() + ".preDestroy"));
- }
-
- public IHelloService getHelloService() {
- return helloService;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/Hello1.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/Hello1.java
deleted file mode 100644
index 48f9112..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/Hello1.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.cdi;
-
-import javax.enterprise.inject.Default;
-import javax.inject.Qualifier;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * @author Roman Grigoriadi
- */
-@Default
-@Qualifier
-@Target({ElementType.TYPE, ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD})
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Hello1 {
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/Hello2.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/Hello2.java
deleted file mode 100644
index de9abca..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/Hello2.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.cdi;
-
-import javax.enterprise.inject.Default;
-import javax.inject.Qualifier;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * @author Roman Grigoriadi
- */
-@Default
-@Qualifier
-@Target({ElementType.TYPE, ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD})
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Hello2 {
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/HelloService1.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/HelloService1.java
deleted file mode 100644
index 73b4cd0..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/HelloService1.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.cdi;
-
-import javax.annotation.PreDestroy;
-import javax.enterprise.context.ApplicationScoped;
-import javax.enterprise.event.Event;
-import javax.inject.Inject;
-
-/**
- * @author Roman Grigoriadi
- */
-@Hello1
-@ApplicationScoped
-public class HelloService1 implements IHelloService {
-
- @Inject
- private Event<MethodCalledEvent> calledEvent;
-
- @Override
- public void sayHello() {
- calledEvent.fire(new MethodCalledEvent(getClass().getName() + ".sayHello"));
- }
-
- @PreDestroy
- public void preDestroy() {
- calledEvent.fire(new MethodCalledEvent(getClass().getName() + ".preDestroy"));
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/HelloService2.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/HelloService2.java
deleted file mode 100644
index 26d5444..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/HelloService2.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.cdi;
-
-import javax.annotation.PreDestroy;
-import javax.enterprise.context.Dependent;
-import javax.enterprise.event.Event;
-import javax.inject.Inject;
-
-/**
- * Dependant scoped bean, should be destroyed with its wrapper bean.
- *
- * @author Roman Grigoriadi
- */
-@Hello2
-@Dependent
-public class HelloService2 implements IHelloService {
-
- @Inject
- private Event<MethodCalledEvent> calledEvent;
-
- @Override
- public void sayHello() {
- calledEvent.fire(new MethodCalledEvent(getClass().getName() + ".sayHello"));
- }
-
- @PreDestroy
- public void preDestroy() {
- calledEvent.fire(new MethodCalledEvent(getClass().getName() + ".preDestroy"));
- }
-
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/IHelloService.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/IHelloService.java
deleted file mode 100644
index 00d405f..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/IHelloService.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.cdi;
-
-/**
- * @author Roman Grigoriadi
- */
-public interface IHelloService {
-
- void sayHello();
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/MethodCalledEvent.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/MethodCalledEvent.java
deleted file mode 100644
index 6bf7070..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/MethodCalledEvent.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.cdi;
-
-/**
- * @author Roman Grigoriadi
- */
-public class MethodCalledEvent {
-
- private final String methdoName;
-
- public MethodCalledEvent(String methdoName) {
- this.methdoName = methdoName;
- }
-
- public String getMethdoName() {
- return methdoName;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/MockJndiContext.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/MockJndiContext.java
deleted file mode 100644
index 705c1cd..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/MockJndiContext.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.cdi;
-
-import javax.naming.*;
-import java.util.Hashtable;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * @author Roman Grigoriadi
- */
-public class MockJndiContext implements Context {
- private static final ConcurrentHashMap<String, Object> objects = new ConcurrentHashMap<>();
-
- @Override
- public Object lookup(Name name) throws NamingException {
- return null;
- }
-
- @Override
- public Object lookup(String name) throws NamingException {
- final Object o = objects.get(name);
- if (o == null) {
- throw new NamingException("No object found under: "+name);
- }
- return o;
- }
-
- @Override
- public void bind(Name name, Object obj) throws NamingException {
-
- }
-
- @Override
- public void bind(String name, Object obj) throws NamingException {
- objects.put(name, obj);
- }
-
- @Override
- public void rebind(Name name, Object obj) throws NamingException {
-
- }
-
- @Override
- public void rebind(String name, Object obj) throws NamingException {
-
- }
-
- @Override
- public void unbind(Name name) throws NamingException {
-
- }
-
- @Override
- public void unbind(String name) throws NamingException {
- objects.remove(name);
- }
-
- @Override
- public void rename(Name oldName, Name newName) throws NamingException {
-
- }
-
- @Override
- public void rename(String oldName, String newName) throws NamingException {
-
- }
-
- @Override
- public NamingEnumeration<NameClassPair> list(Name name) throws NamingException {
- return null;
- }
-
- @Override
- public NamingEnumeration<NameClassPair> list(String name) throws NamingException {
- return null;
- }
-
- @Override
- public NamingEnumeration<Binding> listBindings(Name name) throws NamingException {
- return null;
- }
-
- @Override
- public NamingEnumeration<Binding> listBindings(String name) throws NamingException {
- return null;
- }
-
- @Override
- public void destroySubcontext(Name name) throws NamingException {
-
- }
-
- @Override
- public void destroySubcontext(String name) throws NamingException {
-
- }
-
- @Override
- public Context createSubcontext(Name name) throws NamingException {
- return null;
- }
-
- @Override
- public Context createSubcontext(String name) throws NamingException {
- return null;
- }
-
- @Override
- public Object lookupLink(Name name) throws NamingException {
- return null;
- }
-
- @Override
- public Object lookupLink(String name) throws NamingException {
- return null;
- }
-
- @Override
- public NameParser getNameParser(Name name) throws NamingException {
- return null;
- }
-
- @Override
- public NameParser getNameParser(String name) throws NamingException {
- return null;
- }
-
- @Override
- public Name composeName(Name name, Name prefix) throws NamingException {
- return null;
- }
-
- @Override
- public String composeName(String name, String prefix) throws NamingException {
- return null;
- }
-
- @Override
- public Object addToEnvironment(String propName, Object propVal) throws NamingException {
- return null;
- }
-
- @Override
- public Object removeFromEnvironment(String propName) throws NamingException {
- return null;
- }
-
- @Override
- public Hashtable<?, ?> getEnvironment() throws NamingException {
- return null;
- }
-
- @Override
- public void close() throws NamingException {
-
- }
-
- @Override
- public String getNameInNamespace() throws NamingException {
- return null;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/MockJndiContextFactory.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/MockJndiContextFactory.java
deleted file mode 100644
index c84ebe7..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/MockJndiContextFactory.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.cdi;
-
-import javax.naming.Context;
-import javax.naming.NamingException;
-import javax.naming.spi.InitialContextFactory;
-import java.util.Hashtable;
-
-/**
- * @author Roman Grigoriadi
- */
-public class MockJndiContextFactory implements InitialContextFactory {
- @Override
- public Context getInitialContext(Hashtable<?, ?> environment) throws NamingException {
- return new MockJndiContext();
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/NonCdiAdapter.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/NonCdiAdapter.java
deleted file mode 100644
index 12ef562..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/NonCdiAdapter.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.cdi;
-
-import javax.json.bind.adapter.JsonbAdapter;
-
-/**
- * @author Roman Grigoriadi
- */
-public class NonCdiAdapter implements JsonbAdapter<String, Integer> {
- @Override
- public Integer adaptToJson(String obj) throws Exception {
- return Integer.valueOf(obj);
- }
-
- @Override
- public String adaptFromJson(Integer obj) throws Exception {
- return String.valueOf(obj);
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/WeldManager.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/WeldManager.java
deleted file mode 100644
index b6f02b9..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/cdi/WeldManager.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.cdi;
-
-import org.jboss.weld.environment.se.Weld;
-import org.jboss.weld.environment.se.WeldContainer;
-
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-
-/**
- * Starts and Shutdowns Weld container, for CDI testing purposes.
- *
- * @author Roman Grigoriadi
- */
-public class WeldManager {
-
- private Weld weld;
-
- private InitialContext initialContext;
-
-
- public void startWeld(Class... scannedClasses) throws NamingException {
- weld = new Weld().beanClasses(scannedClasses).disableDiscovery();
- WeldContainer container = weld.initialize();
- initialContext = new InitialContext();
- initialContext.bind(JsonbComponentInstanceCreatorFactory.BEAN_MANAGER_NAME, container.getBeanManager());
- }
-
- public void shutdownWeld() throws NamingException {
- weld.shutdown();
- initialContext.unbind(JsonbComponentInstanceCreatorFactory.BEAN_MANAGER_NAME);
- }
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/concurrent/JsonProcessingResult.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/concurrent/JsonProcessingResult.java
deleted file mode 100644
index bebae5c..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/concurrent/JsonProcessingResult.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.concurrent;
-
-/**
- * A result produced by marshalling or unmarshalling operation called on jsonb.
- * @param <T> For marshalling its String, for unmarshalling Customer.
- */
-class JsonProcessingResult<T> {
- private final T result;
-
- private final String dispatcherThreadName;
-
- private final String jobId;
-
- public JsonProcessingResult(T result, String dispatcherThreadName, String jobId) {
- this.result = result;
- this.dispatcherThreadName = dispatcherThreadName;
- this.jobId = jobId;
- }
-
- public T getResult() {
- return result;
- }
-
- public String getDispatcherThreadName() {
- return dispatcherThreadName;
- }
-
- public String getJobId() {
- return jobId;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/concurrent/MarshallerTask.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/concurrent/MarshallerTask.java
deleted file mode 100644
index 2904279..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/concurrent/MarshallerTask.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.concurrent;
-
-import org.eclipse.persistence.json.bind.defaultmapping.specific.model.Customer;
-
-import javax.json.bind.Jsonb;
-import java.util.concurrent.Callable;
-import java.util.concurrent.CountDownLatch;
-
-/**
- * Runs JSON marshalling, returns Json result.
- */
-class MarshallerTask implements Callable<JsonProcessingResult<MarshallerTaskResult>> {
-
- private final Jsonb jsonb;
- private final String jobId;
- private final MultiTenancyTest.ConfigurationType configurationType;
- private final CountDownLatch latch;
- private final Customer customer;
-
- public MarshallerTask(CountDownLatch latch, MultiTenancyTest.ConfigurationType jsonbConfiguration, String jobId, Customer customer) {
- this.jsonb = jsonbConfiguration.getJsonbInstance();
- this.jobId = jobId;
- this.configurationType = jsonbConfiguration;
- this.latch = latch;
- this.customer = customer;
- }
-
- @Override
- public JsonProcessingResult<MarshallerTaskResult> call() throws Exception {
- try {
- latch.await();
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- }
- //marshalling will produce wrong json result if JsonbConfig in ThreadLocal JsonbContext will not match expected result
- String json = jsonb.toJson(customer);
- return new JsonProcessingResult<>(new MarshallerTaskResult(json, configurationType), Thread.currentThread().getName(), jobId);
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/concurrent/MarshallerTaskResult.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/concurrent/MarshallerTaskResult.java
deleted file mode 100644
index fd5abc8..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/concurrent/MarshallerTaskResult.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.concurrent;
-
-/**
- * Wraps a resulted JSON string with jsonb configuration type, to know against which json to check result.
- */
-class MarshallerTaskResult {
- private final String producedJson;
- private final MultiTenancyTest.ConfigurationType configurationType;
-
- public MarshallerTaskResult(String producedJson, MultiTenancyTest.ConfigurationType configurationType) {
- this.producedJson = producedJson;
- this.configurationType = configurationType;
- }
-
- public String getProducedJson() {
- return producedJson;
- }
-
- public MultiTenancyTest.ConfigurationType getConfigurationType() {
- return configurationType;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/concurrent/MultiTenancyTest.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/concurrent/MultiTenancyTest.java
deleted file mode 100644
index 5ab00b5..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/concurrent/MultiTenancyTest.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.concurrent;
-
-import org.eclipse.persistence.json.bind.defaultmapping.specific.CustomerTest;
-import org.eclipse.persistence.json.bind.defaultmapping.specific.model.Customer;
-import org.junit.Before;
-import org.junit.Test;
-
-import javax.json.bind.Jsonb;
-import javax.json.bind.JsonbBuilder;
-import javax.json.bind.JsonbConfig;
-import javax.json.bind.config.PropertyNamingStrategy;
-import javax.json.bind.config.PropertyVisibilityStrategy;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.concurrent.*;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.logging.Logger;
-
-import static junit.framework.TestCase.assertEquals;
-
-/**
- * Tests consistency along sharing instances of Jsonb with different JsonbConfig between threads.
- * Tests simulates web server like environment, where threads dispatching http requests are pooled and reused.
- *
- * Each of jsonb instances has different JsonbConfig, forcing to produce / parse
- * different JSON string during marshalling to / unmarshalling from json.
- *
- * If ThreadLocal JsonbContext will be inconsistently shared between pooled threads
- * this test should fail while testing results of calls to shared jsonb instances marshalling / unmarshalling methods.
- *
- * @author Roman Grigoriadi
- */
-public class MultiTenancyTest extends CustomerTest {
-
- private static Logger logger = Logger.getLogger(MultiTenancyTest.class.getName());
-
- /**
- * Expected JSON for defaultJsonBinding instance, default key names.
- */
- private static final String DEFAULT_CONFIG_JSON_STRING = "{\"addresses\":[{\"street\":{\"name\":\"Zoubkova\",\"number\":111},\"town\":\"Prague\"}],\"age\":33,\"integers\":[0,1],\"listOfListsOfIntegers\":[[0,1,2],[0,1,2],[0,1,2]],\"name\":\"MULTI_TENANCY_TEST\",\"stringIntegerMap\":{\"first\":1,\"second\":2},\"strings\":[\"green\",\"yellow\"]}";
-
- /**
- * Expected JSON for customizedJsonBinding instance, configured with LOWER_CASE_WITH_UNDERSCORES property naming strategy key names and also skips some properties according to custom PropertyVisibilityStrategy.
- */
- private static final String CUSTOMIZED_CONFIG_JSON_STRING = "{\"addresses\":[{\"street\":{\"name\":\"Zoubkova\",\"number\":111},\"town\":\"Prague\"}],\"age\":33,\"list_of_lists_of_integers\":[[0,1,2],[0,1,2],[0,1,2]],\"name\":\"MULTI_TENANCY_TEST\",\"string_integer_map\":{\"first\":1,\"second\":2}}";
-
- /**
- * A size of thread pool. Should be lesser than TOTAL_JOB_COUNT, so that threads are reused for different tasks,
- * causing more likeness to fail ThreadLocal state managing.
- */
- private static final int THREAD_COUNT = 35;
- /**
- * A total count of marshalling / unmarshalling operations.
- */
- private static final int TOTAL_JOB_COUNT = 2000;
-
- /**
- * After results of marshalling / unmarshalling are checked this count is incremented.
- * When test finishes, this count is required to be equal to TOTAL_JOB_COUNT.
- */
- private final AtomicLong resultsCheckedCount = new AtomicLong();
-
- /**
- * Latch firing first THREAD_COUNT tasks instantly.
- */
- private final static CountDownLatch fireJsonbProcessing = new CountDownLatch(1);
-
- private static final Jsonb defaultJsonBinding;
- private static final Jsonb customizedJsonBinding;
-
- public enum ConfigurationType {
- DEFAULT(defaultJsonBinding, DEFAULT_CONFIG_JSON_STRING),
- CUSTOMIZED(customizedJsonBinding, CUSTOMIZED_CONFIG_JSON_STRING);
-
- ConfigurationType(Jsonb jsonbInstance, String expectedJson) {
- this.jsonbInstance = jsonbInstance;
- this.expectedJson = expectedJson;
- }
-
- private Jsonb jsonbInstance;
- private String expectedJson;
-
- public Jsonb getJsonbInstance() {
- return jsonbInstance;
- }
-
- public String getExpectedJson() {
- return expectedJson;
- }
- }
-
- /**
- * Thread pool for JSONB processing.
- */
- private ExecutorService jsonbProcessingThreadPool;
- private CompletionService<JsonProcessingResult<MarshallerTaskResult>> marshallingCompletion;
- private CompletionService<JsonProcessingResult<Customer>> unmarshallingCompletion;
-
- /**
- * Executor for checking results.
- */
- private ExecutorService resultCheckService;
-
- /**
- * Jsonb instances configuration initialisation.
- */
- static {
- JsonbConfig defaultConfig = new JsonbConfig();
-
- JsonbConfig customizedConfig = new JsonbConfig();
- customizedConfig.setProperty(JsonbConfig.PROPERTY_NAMING_STRATEGY, PropertyNamingStrategy.LOWER_CASE_WITH_UNDERSCORES);
- customizedConfig.setProperty(JsonbConfig.PROPERTY_VISIBILITY_STRATEGY, new PropertyVisibilityStrategy() {
- @Override
- public boolean isVisible(Field field) {
- final String name = field.getName();
- return !(name.equals("strings") || name.equals("integers"));
- }
-
- @Override
- public boolean isVisible(Method method) {
- final String name = method.getName();
- return !(name.equals("getStrings") || name.equals("getIntegers"));
- }
- });
-
-
- defaultJsonBinding = JsonbBuilder.create(defaultConfig);
- customizedJsonBinding = JsonbBuilder.create(customizedConfig);
- }
-
- @Before
- public void setUp() throws Exception {
- jsonbProcessingThreadPool = Executors.newFixedThreadPool(THREAD_COUNT);
- marshallingCompletion = new ExecutorCompletionService<>(jsonbProcessingThreadPool);
- unmarshallingCompletion = new ExecutorCompletionService<>(jsonbProcessingThreadPool);
- resultCheckService = Executors.newFixedThreadPool(2);
- }
-
- @Test
- public void testDataConsistency() throws Exception {
- submitJsonbProcessingTasks();
- fireJsonbProcessing.countDown();
- submitResultCheckingTasks();
-
-
- jsonbProcessingThreadPool.shutdown();
- jsonbProcessingThreadPool.awaitTermination(1000, TimeUnit.MILLISECONDS);
- resultCheckService.shutdown();
- resultCheckService.awaitTermination(5000, TimeUnit.MILLISECONDS);
-
- //Final check, that successful task result check count matches count of tasks that were submitted.
- assertEquals(TOTAL_JOB_COUNT, resultsCheckedCount.get());
- }
-
- /**
- * Picks marshalling / unmarshalling results from completion service queue and check if they
- * are equal their expected prototypes.
- *
- * If ThreadLocal JsonbContext is incorrectly shared between pooled threads, configuration of jsonb instances
- * would be stale and results will not match.
- */
- private void submitResultCheckingTasks() {
- resultCheckService.execute(new ResultChecker<MarshallerTaskResult>(marshallingCompletion) {
- @Override
- protected void checkResult(JsonProcessingResult<MarshallerTaskResult> result) {
- MarshallerTaskResult marshallerResult = result.getResult();
- //actual check, produced json by marshaller is equal to expected by configuration, which triggered marshalling task.
- assertEquals(marshallerResult.getConfigurationType().getExpectedJson(), marshallerResult.getProducedJson());
- resultsCheckedCount.incrementAndGet();
- logger.fine(String.format("Job %-32s dispatched by thread %-16s completed successfully.", result.getJobId(), result.getDispatcherThreadName()));
- }
- });
-
- resultCheckService.execute(new ResultChecker<Customer>(unmarshallingCompletion) {
- @Override
- protected void checkResult(JsonProcessingResult<Customer> result) {
- //actual check, unmarshalled json result have all expected values.
- //if JsonbConfig is stale, key names will not match, and this assert will not pass.
- assertCustomerValues(result.getResult(), "MULTI_TENANCY_TEST");
- resultsCheckedCount.incrementAndGet();
- logger.fine(String.format("Job %-32s dispatched by thread %-16s completed successfully.", result.getJobId(), result.getDispatcherThreadName()));
- }
- });
- }
-
- /**
- * Chooses shared jsonb instance, either with default or customized key names
- * and submits marshaller an unmarshaller task for it.
- */
- private void submitJsonbProcessingTasks() {
- for(int i = 0; i< TOTAL_JOB_COUNT; i+=2) {
- boolean even = (i % 4 == 0);
- ConfigurationType jsonbConfiguration = even ? ConfigurationType.DEFAULT : ConfigurationType.CUSTOMIZED;
-
- final String unmarshallerJobId = jsonbConfiguration.name() + "_Unmarshaller_ID_" + i;
- final UnmarshallerTask task = new UnmarshallerTask(fireJsonbProcessing, jsonbConfiguration.getExpectedJson(), jsonbConfiguration.getJsonbInstance(), unmarshallerJobId);
- unmarshallingCompletion.submit(task);
-
- final String marshallerJobId = jsonbConfiguration.name() + "_Marshaller_ID_" + i;
- final MarshallerTask marshallerTask = new MarshallerTask(fireJsonbProcessing, jsonbConfiguration, marshallerJobId, createCustomer("MULTI_TENANCY_TEST"));
- marshallingCompletion.submit(marshallerTask);
- }
- }
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/concurrent/ResultChecker.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/concurrent/ResultChecker.java
deleted file mode 100644
index b83ce84..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/concurrent/ResultChecker.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.concurrent;
-
-import java.util.concurrent.CompletionService;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-
-/**
- * Checks result of marshalling / unmarshalling operation.
- */
-abstract class ResultChecker<T> implements Runnable {
-
- private final CompletionService<JsonProcessingResult<T>> completionService;
-
- public ResultChecker(CompletionService<JsonProcessingResult<T>> completionService) {
- this.completionService = completionService;
- }
-
- /**
- * Polls Callable results from CompletionService result queue and checks validity.
- */
- @Override
- public void run() {
- Future<JsonProcessingResult<T>> resultFuture;
- try {
- while ((resultFuture = completionService.poll(500, TimeUnit.MILLISECONDS)) != null) {
- checkResult(resultFuture.get());
- }
- } catch (InterruptedException | ExecutionException e) {
- throw new RuntimeException(e);
- }
- }
-
- protected abstract void checkResult(JsonProcessingResult<T> result);
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/concurrent/UnmarshallerTask.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/concurrent/UnmarshallerTask.java
deleted file mode 100644
index 863a08a..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/concurrent/UnmarshallerTask.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.concurrent;
-
-import org.eclipse.persistence.json.bind.defaultmapping.specific.model.Customer;
-
-import javax.json.bind.Jsonb;
-import java.util.concurrent.Callable;
-import java.util.concurrent.CountDownLatch;
-
-/**
- * Runs Jsonb unmarshaller, returns result.
- */
-class UnmarshallerTask implements Callable<JsonProcessingResult<Customer>> {
-
- private final String json;
-
- private final Jsonb jsonb;
-
- private final String jobId;
-
- private final CountDownLatch latch;
-
- public UnmarshallerTask(CountDownLatch latch, String json, Jsonb jsonb, String jobId) {
- this.json = json;
- this.jsonb = jsonb;
- this.jobId = jobId;
- this.latch = latch;
- }
-
- @Override
- public JsonProcessingResult<Customer> call() throws Exception {
- latch.await();
- //unmarshalling will fail if JsonbConfig in ThreadLocal JsonbContext will not match expected json
- Customer customer = jsonb.fromJson(json, Customer.class);
- return new JsonProcessingResult<>(customer, Thread.currentThread().getName(), jobId);
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/naming/NamingPojo.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/naming/NamingPojo.java
deleted file mode 100644
index 076d209..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/naming/NamingPojo.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.naming;
-
-/**
- * @author Roman Grigoriadi
- */
-public class NamingPojo {
-
- public NamingPojo() {
- }
-
- public NamingPojo(String upperCasedProperty, String _startingWithUnderscoreProperty, String CAPS_UNDERSCORE_PROPERTY) {
- this.upperCasedProperty = upperCasedProperty;
- this._startingWithUnderscoreProperty = _startingWithUnderscoreProperty;
- this.CAPS_UNDERSCORE_PROPERTY = CAPS_UNDERSCORE_PROPERTY;
- }
-
- public String upperCasedProperty;
- public String _startingWithUnderscoreProperty;
- public String CAPS_UNDERSCORE_PROPERTY;
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/naming/PropertyNamingStrategyTest.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/naming/PropertyNamingStrategyTest.java
deleted file mode 100644
index 8a5cbb8..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/internal/naming/PropertyNamingStrategyTest.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.internal.naming;
-
-import org.junit.Test;
-
-import javax.json.bind.Jsonb;
-import javax.json.bind.JsonbBuilder;
-import javax.json.bind.JsonbConfig;
-import javax.json.bind.config.PropertyNamingStrategy;
-
-import static org.junit.Assert.assertEquals;
-
-/**
- * Tests naming strategies.
- *
- * @author Roman Grigoriadi
- */
-public class PropertyNamingStrategyTest {
-
- private final NamingPojo pojo = new NamingPojo("abc", "def", "ghi");
-
- @Test
- public void testLowerCase() throws Exception {
- PropertyNamingStrategy strategy = new LowerCaseWithUnderscoresStrategy();
- assertEquals("camel_case_property", strategy.translateName("camelCaseProperty"));
- assertEquals("camelcase_property", strategy.translateName("CamelcaseProperty"));
- assertEquals("camel_case_property", strategy.translateName("CamelCaseProperty"));
- assertEquals("_camel_case_property", strategy.translateName("_camelCaseProperty"));
- assertEquals("_camel_case_property", strategy.translateName("_CamelCaseProperty"));
-
- Jsonb jsonb = JsonbBuilder.create(new JsonbConfig().withPropertyNamingStrategy(PropertyNamingStrategy.LOWER_CASE_WITH_UNDERSCORES));
- String lowercaseUnderscoresJson = "{\"_starting_with_underscore_property\":\"def\",\"caps_underscore_property\":\"ghi\",\"upper_cased_property\":\"abc\"}";
- assertEquals(lowercaseUnderscoresJson, jsonb.toJson(pojo));
- NamingPojo result = jsonb.fromJson(lowercaseUnderscoresJson, NamingPojo.class);
- assertResult(result);
-
- }
-
- @Test
- public void testLowerDashes() throws Exception {
- PropertyNamingStrategy strategy = new LowerCaseWithDashesStrategy();
- assertEquals("camel-case-property", strategy.translateName("camelCaseProperty"));
- assertEquals("camelcase-property", strategy.translateName("CamelcaseProperty"));
- assertEquals("camel-case-property", strategy.translateName("CamelCaseProperty"));
- assertEquals("-camel-case-property", strategy.translateName("-camelCaseProperty"));
- assertEquals("-camel-case-property", strategy.translateName("-CamelCaseProperty"));
-
- Jsonb jsonb = JsonbBuilder.create(new JsonbConfig().withPropertyNamingStrategy(PropertyNamingStrategy.LOWER_CASE_WITH_DASHES));
- String lowercaseDashesJson = "{\"_starting-with-underscore-property\":\"def\",\"caps_underscore_property\":\"ghi\",\"upper-cased-property\":\"abc\"}";
- assertEquals(lowercaseDashesJson, jsonb.toJson(pojo));
- NamingPojo result = jsonb.fromJson(lowercaseDashesJson, NamingPojo.class);
- assertResult(result);
- }
-
- @Test
- public void testUpperCase() {
- PropertyNamingStrategy upperCaseStrat = new UpperCamelCaseStrategy();
- assertEquals("UpperCamelCase", upperCaseStrat.translateName("upperCamelCase"));
- assertEquals("UpperCamelCase", upperCaseStrat.translateName("UpperCamelCase"));
-
- Jsonb jsonb = JsonbBuilder.create(new JsonbConfig().withPropertyNamingStrategy(PropertyNamingStrategy.UPPER_CAMEL_CASE));
- String upperCased = "{\"CAPS_UNDERSCORE_PROPERTY\":\"ghi\",\"UpperCasedProperty\":\"abc\",\"_startingWithUnderscoreProperty\":\"def\"}";
- assertEquals(upperCased, jsonb.toJson(pojo));
- NamingPojo result = jsonb.fromJson(upperCased, NamingPojo.class);
- assertResult(result);
- }
-
- @Test
- public void testUpperCaseWithSpaces() {
- PropertyNamingStrategy upperCaseWithSpacesStrat = new UpperCamelCaseWithSpacesStrategy();
- assertEquals("Upper Camel Case", upperCaseWithSpacesStrat.translateName("upperCamelCase"));
- assertEquals("Upper Camel Case", upperCaseWithSpacesStrat.translateName("UpperCamelCase"));
-
- Jsonb jsonb = JsonbBuilder.create(new JsonbConfig().withPropertyNamingStrategy(PropertyNamingStrategy.UPPER_CAMEL_CASE_WITH_SPACES));
- String upperCased = "{\"CAPS_UNDERSCORE_PROPERTY\":\"ghi\",\"Upper Cased Property\":\"abc\",\"_starting With Underscore Property\":\"def\"}";
- assertEquals(upperCased, jsonb.toJson(pojo));
- NamingPojo result = jsonb.fromJson(upperCased, NamingPojo.class);
- assertResult(result);
- }
-
- @Test
- public void testCaseInsensitive() {
-
- Jsonb jsonb = JsonbBuilder.create(new JsonbConfig().withPropertyNamingStrategy(PropertyNamingStrategy.CASE_INSENSITIVE));
- String upperCased = "{\"CAPS_UNDERSCORE_PROPERTY\":\"ghi\",\"_startingWithUnderscoreProperty\":\"def\",\"upperCasedProperty\":\"abc\"}";
- assertEquals(upperCased, jsonb.toJson(pojo));
- NamingPojo result = jsonb.fromJson("{\"caPS_unDERscore_prOPERty\":\"ghi\",\"_startingwithUndERSCorePrOPERTy\":\"def\",\"upPERCASedProPerty\":\"abc\"}", NamingPojo.class);
- assertResult(result);
- }
-
- @Test
- public void testCustom() {
- Jsonb jsonb = JsonbBuilder.create(new JsonbConfig().withPropertyNamingStrategy(new PropertyNamingStrategy() {
- @Override
- public String translateName(String propertyName) {
- return propertyName + "_" + propertyName.toUpperCase();
- }
- }));
-
- String custom = "{\"CAPS_UNDERSCORE_PROPERTY_CAPS_UNDERSCORE_PROPERTY\":\"ghi\",\"_startingWithUnderscoreProperty__STARTINGWITHUNDERSCOREPROPERTY\":\"def\",\"upperCasedProperty_UPPERCASEDPROPERTY\":\"abc\"}";
- assertEquals(custom, jsonb.toJson(pojo));
- NamingPojo result = jsonb.fromJson(custom, NamingPojo.class);
- assertResult(result);
- }
-
- private void assertResult(NamingPojo result) {
- assertEquals("abc", result.upperCasedProperty);
- assertEquals("def", result._startingWithUnderscoreProperty);
- assertEquals("ghi", result.CAPS_UNDERSCORE_PROPERTY);
- }
-
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/logger/JsonbLoggerFormatter.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/logger/JsonbLoggerFormatter.java
deleted file mode 100644
index 911c8b3..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/logger/JsonbLoggerFormatter.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.logger;
-
-import java.util.logging.LogRecord;
-
-/**
- * @author Roman Grigoriadi
- */
-public class JsonbLoggerFormatter extends java.util.logging.Formatter {
- @Override
- public String format(LogRecord record) {
- return String.format("%-8s",record.getLevel()) + " => " + record.getMessage()+"\n";
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/SerializersTest.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/SerializersTest.java
deleted file mode 100644
index 547320f..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/SerializersTest.java
+++ /dev/null
@@ -1,272 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.serializers;
-
-import org.eclipse.persistence.json.bind.adapters.PolymorphismAdapterTest;
-import org.eclipse.persistence.json.bind.serializers.model.AnnotatedWithSerializerType;
-import org.eclipse.persistence.json.bind.serializers.model.Box;
-import org.eclipse.persistence.json.bind.serializers.model.BoxWithAnnotations;
-import org.eclipse.persistence.json.bind.serializers.model.Crate;
-import org.eclipse.persistence.json.bind.serializers.model.CrateDeserializer;
-import org.eclipse.persistence.json.bind.serializers.model.CrateDeserializerWithConversion;
-import org.eclipse.persistence.json.bind.serializers.model.CrateInner;
-import org.eclipse.persistence.json.bind.serializers.model.CrateJsonObjectDeserializer;
-import org.eclipse.persistence.json.bind.serializers.model.CrateSerializer;
-import org.eclipse.persistence.json.bind.serializers.model.CrateSerializerWithConversion;
-import org.eclipse.persistence.json.bind.serializers.model.PolymorphicDeserializer;
-import org.junit.Test;
-
-import javax.json.bind.Jsonb;
-import javax.json.bind.JsonbBuilder;
-import javax.json.bind.JsonbConfig;
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-/**
- * @author Roman Grigoriadi
- */
-public class SerializersTest {
-
- @Test
- public void testClassLevelAnnotation() {
- Crate crate = new Crate();
- crate.crateBigDec = BigDecimal.TEN;
- crate.crateStr = "crateStr";
-
- crate.annotatedType = new AnnotatedWithSerializerType();
- crate.annotatedType.value = "abc";
- crate.annotatedTypeOverridenOnProperty = new AnnotatedWithSerializerType();
- crate.annotatedTypeOverridenOnProperty.value = "def";
- final Jsonb jsonb = JsonbBuilder.create();
- String expected = "{\"annotatedType\":{\"valueField\":\"replaced value\"},\"annotatedTypeOverridenOnProperty\":{\"valueField\":\"overridden value\"},\"crateBigDec\":10,\"crate_str\":\"crateStr\"}";
-
- assertEquals(expected, jsonb.toJson(crate));
-
- Crate result = jsonb.fromJson(expected, Crate.class);
- assertEquals("replaced value", result.annotatedType.value);
- assertEquals("overridden value", result.annotatedTypeOverridenOnProperty.value);
-
- }
-
- @Test
- public void testPolymorphicDeserializer() {
- JsonbConfig config = new JsonbConfig().withDeserializers(new PolymorphicDeserializer());
- Jsonb jsonb = JsonbBuilder.create(config);
-
- String json = "{\"className\":\"org.eclipse.persistence.json.bind.adapters.PolymorphismAdapterTest$Dog\",\"pojo\":{\"name\":\"Uberdog\",\"dogProperty\":\"dog property\"}}";
- PolymorphismAdapterTest.Animal animal = jsonb.fromJson(json, PolymorphismAdapterTest.Animal.class);
- assertTrue(animal instanceof PolymorphismAdapterTest.Dog);
- assertEquals("Uberdog", animal.name);
- assertEquals("dog property", ((PolymorphismAdapterTest.Dog) animal).dogProperty);
- }
-
- /**
- * Tests JSONB deserialization of arbitrary type invoked from a Deserializer.
- */
- @Test
- public void testDeserialzierDeserializationByType() {
- JsonbConfig config = new JsonbConfig().withDeserializers(new CrateDeserializer());
- Jsonb jsonb = JsonbBuilder.create(config);
-
- Box box = createPojoWithDates();
-
- String expected = "{\"boxStr\":\"Box string\",\"crate\":{\"crateInner\":{\"crateInnerBigDec\":10,\"crate_inner_str\":\"Single inner\",\"date\":\"14.05.2015 || 11:10:01\"},\"crateInnerList\":[{\"crateInnerBigDec\":10,\"crate_inner_str\":\"List inner 0\"},{\"crateInnerBigDec\":10,\"crate_inner_str\":\"List inner 1\"}],\"date\":\"2015-05-14T11:10:01\"},\"secondBoxStr\":\"Second box string\"}";
-
- Box result = jsonb.fromJson(expected, Box.class);
-
- //deserialized by deserializationContext.deserialize(Class c)
- assertEquals(box.crate.crateInner.crateInnerBigDec, result.crate.crateInner.crateInnerBigDec);
- assertEquals(box.crate.crateInner.crateInnerStr, result.crate.crateInner.crateInnerStr);
-
- assertEquals("List inner 0", result.crate.crateInnerList.get(0).crateInnerStr);
- assertEquals("List inner 1", result.crate.crateInnerList.get(1).crateInnerStr);
-
- //set by deserializer statically
- assertEquals(new BigDecimal("123"), result.crate.crateBigDec);
- assertEquals("abc", result.crate.crateStr);
-
- }
-
- /**
- * Tests JSONB serialization of arbitrary type invoked from a Serializer.
- */
- @Test
- public void testSerializerSerializationOfType() {
- JsonbConfig config = new JsonbConfig().withSerializers(new CrateSerializer());
- Jsonb jsonb = JsonbBuilder.create(config);
- String expected = "{\"boxStr\":\"Box string\",\"crate\":{\"crateStr\":\"REPLACED crate str\",\"crateInner\":{\"crateInnerBigDec\":10,\"crate_inner_str\":\"Single inner\"},\"crateInnerList\":[{\"crateInnerBigDec\":10,\"crate_inner_str\":\"List inner 0\"},{\"crateInnerBigDec\":10,\"crate_inner_str\":\"List inner 1\"}],\"crateBigDec\":54321},\"secondBoxStr\":\"Second box string\"}";
- Box pojo = createPojo();
-
- assertEquals(expected, jsonb.toJson(pojo));
-
- Box result = jsonb.fromJson(expected, Box.class);
- assertEquals(new BigDecimal("54321"), result.crate.crateBigDec);
- //result.crate.crateStr is mapped to crate_str by jsonb property
- assertNull(result.crate.crateStr);
- assertEquals(pojo.crate.crateInner.crateInnerStr, result.crate.crateInner.crateInnerStr);
- assertEquals(pojo.crate.crateInner.crateInnerBigDec, result.crate.crateInner.crateInnerBigDec);
- }
-
- /**
- * Tests jsonb type conversion, including property customization.
- */
- @Test
- public void testDeserializersUsingConversion() {
- JsonbConfig config = new JsonbConfig().withDeserializers(new CrateDeserializerWithConversion());
- Jsonb jsonb = JsonbBuilder.create(config);
-
- String json = "{\"boxStr\":\"Box string\",\"crate\":{\"date-converted\":\"2015-05-14T11:10:01\",\"crateStr\":\"REPLACED crate str\",\"crateInner\":{\"crateInnerBigDec\":10,\"crate_inner_str\":\"Single inner\",\"date\":\"14.05.2015 || 11:10:01\"},\"crateBigDec\":54321},\"secondBoxStr\":\"Second box string\"}";
- Box result = jsonb.fromJson(json, Box.class);
- final Date expected = getExpectedDate();
- assertEquals(expected, result.crate.date);
- assertEquals("Box string", result.boxStr);
- assertEquals("Second box string", result.secondBoxStr);
- }
-
- @Test
- public void testCrateJsonObjectDeserialzer() {
- JsonbConfig config = new JsonbConfig().withDeserializers(new CrateJsonObjectDeserializer());
- Jsonb jsonb = JsonbBuilder.create(config);
- String expected = "{\"boxStr\":\"Box string\",\"crate\":{\"date-converted\":\"2015-05-14T11:10:01\",\"crateStr\":\"REPLACED crate str\",\"crateInner\":{\"crateInnerBigDec\":10,\"crateInnerStr\":\"Single inner\"},\"crateInnerList\":[{\"crateInnerBigDec\":10,\"crate_inner_str\":\"List inner 0\"},{\"crateInnerBigDec\":10,\"crate_inner_str\":\"List inner 1\"}],\"crateBigDec\":54321},\"secondBoxStr\":\"Second box string\"}";
- Box result = jsonb.fromJson(expected, Box.class);
- assertEquals(new BigDecimal("54321"), result.crate.crateBigDec);
- assertEquals("REPLACED crate str", result.crate.crateStr);
- assertEquals("Single inner", result.crate.crateInner.crateInnerStr);
- assertEquals(BigDecimal.TEN, result.crate.crateInner.crateInnerBigDec);
- }
-
- private Date getExpectedDate() {
- return new Calendar.Builder().setDate(2015, 4, 14).setTimeOfDay(11, 10, 1).build().getTime();
- }
-
- @Test
- public void testSerializationUsingConversion() {
- JsonbConfig config = new JsonbConfig().withSerializers(new CrateSerializerWithConversion());
- Jsonb jsonb = JsonbBuilder.create(config);
-
- //TODO fix / uncomment after keyname argument will be added to JsonbSerializer
- String json = "{\"boxStr\":\"Box string\",\"crate\":{\"crateStr\":\"REPLACED crate str\",\"crateInner\":{\"crateInnerBigDec\":10,\"crate_inner_str\":\"Single inner\",\"date\":\"14.05.2015 || 11:10:01\"},\"crateInnerList\":[{\"crateInnerBigDec\":10,\"crate_inner_str\":\"List inner 0\"},{\"crateInnerBigDec\":10,\"crate_inner_str\":\"List inner 1\"}],\"crateBigDec\":54321,\"date-converted\":\"2015-05-14T11:10:01\"},\"secondBoxStr\":\"Second box string\"}";
- assertEquals(json, jsonb.toJson(createPojoWithDates()));
- }
-
- @Test
- public void testAnnotations() {
- final Jsonb jsonb = JsonbBuilder.create();
- BoxWithAnnotations box = new BoxWithAnnotations();
- box.boxStr = "Box string";
- box.secondBoxStr = "Second box string";
- box.crate = new Crate();
- box.crate.date = getExpectedDate();
- box.crate.crateInner = createCrateInner("Single inner");
-
- box.crate.crateInnerList = new ArrayList<>();
- box.crate.crateInnerList.add(createCrateInner("List inner 0"));
- box.crate.crateInnerList.add(createCrateInner("List inner 1"));
-
- //TODO fix / uncomment after keyname argument will be added to JsonbSerializer
-// String expected = "{\"boxStr\":\"Box string\",\"crate\":{\"crateStr\":\"REPLACED crate str\",\"crateInner\":{\"crateInnerBigDec\":10,\"crate_inner_str\":\"Single inner\"},\"crateInnerList\":[{\"crateInnerBigDec\":10,\"crate_inner_str\":\"List inner 0\"},{\"crateInnerBigDec\":10,\"crate_inner_str\":\"List inner 1\"}],\"crateBigDec\":54321,\"date-converted\":\"2015-05-14T11:10:01\"},\"secondBoxStr\":\"Second box string\"}";
- String expected = "{\"boxStr\":\"Box string\",\"crate\":{\"crateStr\":\"REPLACED crate str\",\"crateInner\":{\"crateInnerBigDec\":10,\"crate_inner_str\":\"Single inner\"},\"crateInnerList\":[{\"crateInnerBigDec\":10,\"crate_inner_str\":\"List inner 0\"},{\"crateInnerBigDec\":10,\"crate_inner_str\":\"List inner 1\"}],\"crateBigDec\":54321,\"date-converted\":\"2015-05-14T11:10:01\"},\"secondBoxStr\":\"Second box string\"}";
-
- assertEquals(expected, jsonb.toJson(box));
-
- BoxWithAnnotations result = jsonb.fromJson(expected, BoxWithAnnotations.class);
-
- //deserialized by deserializationContext.deserialize(Class c)
- assertEquals(box.crate.crateInner.crateInnerBigDec, result.crate.crateInner.crateInnerBigDec);
- assertEquals(box.crate.crateInner.crateInnerStr, result.crate.crateInner.crateInnerStr);
-
- assertEquals(2L, result.crate.crateInnerList.size());
- assertEquals("List inner 0", result.crate.crateInnerList.get(0).crateInnerStr);
- assertEquals("List inner 1", result.crate.crateInnerList.get(1).crateInnerStr);
-
- //set by deserializer statically
- assertEquals(new BigDecimal("123"), result.crate.crateBigDec);
- assertEquals("abc", result.crate.crateStr);
- }
-
- @Test
- public void testAnnotationsOverride() {
- JsonbConfig config = new JsonbConfig().withDeserializers(new CrateJsonObjectDeserializer()).withSerializers(new CrateSerializer());
- Jsonb jsonb = JsonbBuilder.create(config);
-
- BoxWithAnnotations box = new BoxWithAnnotations();
- box.boxStr = "Box string";
- box.secondBoxStr = "Second box string";
- box.crate = new Crate();
- box.crate.crateInner = createCrateInner("Single inner");
- box.crate.date = getExpectedDate();
-
- box.crate.crateInnerList = new ArrayList<>();
- box.crate.crateInnerList.add(createCrateInner("List inner 0"));
- box.crate.crateInnerList.add(createCrateInner("List inner 1"));
-
- //TODO fix / uncomment after keyname argument will be added to JsonbSerializer
- String expected = "{\"boxStr\":\"Box string\",\"crate\":{\"crateStr\":\"REPLACED crate str\",\"crateInner\":{\"crateInnerBigDec\":10,\"crate_inner_str\":\"Single inner\"},\"crateInnerList\":[{\"crateInnerBigDec\":10,\"crate_inner_str\":\"List inner 0\"},{\"crateInnerBigDec\":10,\"crate_inner_str\":\"List inner 1\"}],\"crateBigDec\":54321,\"date-converted\":\"2015-05-14T11:10:01\"},\"secondBoxStr\":\"Second box string\"}";
-
- assertEquals(expected, jsonb.toJson(box));
-
- BoxWithAnnotations result = jsonb.fromJson(expected, BoxWithAnnotations.class);
-
- //deserialized by deserializationContext.deserialize(Class c)
- assertEquals(box.crate.crateInner.crateInnerBigDec, result.crate.crateInner.crateInnerBigDec);
- assertEquals(box.crate.crateInner.crateInnerStr, result.crate.crateInner.crateInnerStr);
-
- assertEquals(2L, result.crate.crateInnerList.size());
- assertEquals("List inner 0", result.crate.crateInnerList.get(0).crateInnerStr);
- assertEquals("List inner 1", result.crate.crateInnerList.get(1).crateInnerStr);
-
- //set by deserializer statically
- assertEquals(new BigDecimal("123"), result.crate.crateBigDec);
- assertEquals("abc", result.crate.crateStr);
- }
-
- private Box createPojoWithDates() {
- Date date = getExpectedDate();
- Box box = createPojo();
- box.crate.date = date;
- box.crate.crateInner.date = date;
- return box;
- }
-
- private Box createPojo() {
- Box box = new Box();
- box.boxStr = "Box string";
- box.crate = new Crate();
- box.secondBoxStr = "Second box string";
-
-
- box.crate.crateInner = createCrateInner("Single inner");
-
- box.crate.crateInnerList = new ArrayList<>();
- box.crate.crateInnerList.add(createCrateInner("List inner 0"));
- box.crate.crateInnerList.add(createCrateInner("List inner 1"));
-
- return box;
- }
-
- private CrateInner createCrateInner(String name) {
- final CrateInner crateInner = new CrateInner();
- crateInner.crateInnerStr = name;
- crateInner.crateInnerBigDec = BigDecimal.TEN;
- return crateInner;
- }
-
-
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/model/AnnotatedWithSerializerType.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/model/AnnotatedWithSerializerType.java
deleted file mode 100644
index f8fc3e3..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/model/AnnotatedWithSerializerType.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.serializers.model;
-
-import javax.json.bind.annotation.JsonbTypeDeserializer;
-import javax.json.bind.annotation.JsonbTypeSerializer;
-
-/**
- * @author Roman Grigoriadi
- */
-@JsonbTypeSerializer(AnnotatedWithSerializerTypeSerializer.class)
-@JsonbTypeDeserializer(AnnotatedWithSerialzierTypeDeserializer.class)
-public class AnnotatedWithSerializerType {
-
- public String value;
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/model/AnnotatedWithSerializerTypeSerializer.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/model/AnnotatedWithSerializerTypeSerializer.java
deleted file mode 100644
index a5421d5..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/model/AnnotatedWithSerializerTypeSerializer.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.serializers.model;
-
-import javax.json.bind.serializer.JsonbSerializer;
-import javax.json.bind.serializer.SerializationContext;
-import javax.json.stream.JsonGenerator;
-
-/**
- * @author Roman Grigoriadi
- */
-public class AnnotatedWithSerializerTypeSerializer implements JsonbSerializer<AnnotatedWithSerializerType> {
-
- @Override
- public void serialize(AnnotatedWithSerializerType obj, JsonGenerator generator, SerializationContext ctx) {
- generator.writeStartObject();
- generator.write("valueField", "replaced value");
- generator.writeEnd();
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/model/AnnotatedWithSerializerTypeSerializerOverride.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/model/AnnotatedWithSerializerTypeSerializerOverride.java
deleted file mode 100644
index 966d15c..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/model/AnnotatedWithSerializerTypeSerializerOverride.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.serializers.model;
-
-import javax.json.bind.serializer.JsonbSerializer;
-import javax.json.bind.serializer.SerializationContext;
-import javax.json.stream.JsonGenerator;
-
-/**
- * @author Roman Grigoriadi
- */
-public class AnnotatedWithSerializerTypeSerializerOverride implements JsonbSerializer<AnnotatedWithSerializerType> {
-
- @Override
- public void serialize(AnnotatedWithSerializerType obj, JsonGenerator generator, SerializationContext ctx) {
- generator.writeStartObject();
- generator.write("valueField", "overridden value");
- generator.writeEnd();
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/model/AnnotatedWithSerialzierTypeDeserializer.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/model/AnnotatedWithSerialzierTypeDeserializer.java
deleted file mode 100644
index 8ab6eda..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/model/AnnotatedWithSerialzierTypeDeserializer.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.serializers.model;
-
-import javax.json.bind.serializer.DeserializationContext;
-import javax.json.bind.serializer.JsonbDeserializer;
-import javax.json.stream.JsonParser;
-import java.lang.reflect.Type;
-
-/**
- * @author Roman Grigoriadi
- */
-public class AnnotatedWithSerialzierTypeDeserializer implements JsonbDeserializer<AnnotatedWithSerializerType> {
- /**
- * Deserialize an object from JSON.
- * Cursor of JsonParser is at START_OBJECT.
- *
- * @param parser Json parser
- * @param ctx Deserialization context
- * @param rtType type of returned object
- * @return deserialized instance
- */
- @Override
- public AnnotatedWithSerializerType deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) {
- AnnotatedWithSerializerType result = new AnnotatedWithSerializerType();
- parser.next(); parser.next();
- result.value = parser.getString();
- return result;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/model/Box.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/model/Box.java
deleted file mode 100644
index d193eaa..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/model/Box.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.serializers.model;
-
-/**
- * @author Roman Grigoriadi
- */
-public class Box {
-
- public String boxStr;
-
- public Crate crate;
-
- public String secondBoxStr;
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/model/BoxWithAnnotations.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/model/BoxWithAnnotations.java
deleted file mode 100644
index ee4a111..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/model/BoxWithAnnotations.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.serializers.model;
-
-import javax.json.bind.annotation.JsonbTypeDeserializer;
-import javax.json.bind.annotation.JsonbTypeSerializer;
-
-/**
- * @author Roman Grigoriadi
- */
-public class BoxWithAnnotations {
-
- public String boxStr;
-
- @JsonbTypeSerializer(CrateSerializerWithConversion.class)
- @JsonbTypeDeserializer(CrateDeserializer.class)
- public Crate crate;
-
-
- public String secondBoxStr;
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/model/Crate.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/model/Crate.java
deleted file mode 100644
index 2069c12..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/model/Crate.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.serializers.model;
-
-import javax.json.bind.annotation.JsonbDateFormat;
-import javax.json.bind.annotation.JsonbProperty;
-import javax.json.bind.annotation.JsonbTypeSerializer;
-import java.math.BigDecimal;
-import java.util.Date;
-import java.util.List;
-
-/**
- * @author Roman Grigoriadi
- */
-public class Crate {
-
- @JsonbProperty("crate_str")
- public String crateStr;
-
- public CrateInner crateInner;
-
- public List<CrateInner> crateInnerList;
-
- public BigDecimal crateBigDec;
-
- @JsonbDateFormat("dd.MM.yyy ^ HH:mm:ss")
- public Date date;
-
- public AnnotatedWithSerializerType annotatedType;
-
- @JsonbTypeSerializer(AnnotatedWithSerializerTypeSerializerOverride.class)
- public AnnotatedWithSerializerType annotatedTypeOverridenOnProperty;
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/model/CrateDeserializer.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/model/CrateDeserializer.java
deleted file mode 100644
index 2645c32..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/model/CrateDeserializer.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.serializers.model;
-
-import org.eclipse.persistence.json.bind.TestTypeToken;
-
-import javax.json.bind.serializer.DeserializationContext;
-import javax.json.bind.serializer.JsonbDeserializer;
-import javax.json.stream.JsonParser;
-import java.lang.reflect.Type;
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Date;
-
-
-public class CrateDeserializer implements JsonbDeserializer<Crate> {
-
- @Override
- public Crate deserialize(JsonParser jsonParser, DeserializationContext ctx, Type rtType) {
- Crate crate = new Crate();
- crate.crateStr = "abc";
- crate.crateBigDec = new BigDecimal("123");
-
- while (jsonParser.hasNext()) {
- JsonParser.Event next = jsonParser.next();
- if (next.equals(JsonParser.Event.KEY_NAME) && jsonParser.getString().equals("crateInner")) {
- //invokes JSONB processing for a CrateInner as a root type with "shared" instance of JsonParser
- crate.crateInner = ctx.deserialize(CrateInner.class, jsonParser);
- continue;
- }
- if (next.equals(JsonParser.Event.KEY_NAME) && jsonParser.getString().equals("crateInnerList")) {
- //invokes JSONB processing for a CrateInner as a root type with "shared" instance of JsonParser
- crate.crateInnerList = ctx.deserialize(new TestTypeToken<ArrayList<CrateInner>>(){}.getType(), jsonParser);
- continue;
- }
- if (next.equals(JsonParser.Event.KEY_NAME) && jsonParser.getString().equals("date")) {
- //move to value
- jsonParser.next();
- //don't have context of processing here, no annotation customizations applied.
-// crate.date = ctx.convertDefault(Date.class, jsonParser.getString());
- ctx.deserialize(Date.class, jsonParser);
- }
-
- }
-
- return crate;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/model/CrateDeserializerWithConversion.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/model/CrateDeserializerWithConversion.java
deleted file mode 100644
index 621c43b..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/model/CrateDeserializerWithConversion.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.serializers.model;
-
-import javax.json.bind.serializer.DeserializationContext;
-import javax.json.bind.serializer.JsonbDeserializer;
-import javax.json.stream.JsonParser;
-import java.lang.reflect.Type;
-import java.util.Date;
-
-/**
- * @author Roman Grigoriadi
- */
-public class CrateDeserializerWithConversion implements JsonbDeserializer<Crate> {
-
- @Override
- public Crate deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) {
- Crate result = new Crate();
- while (parser.hasNext()) {
- final JsonParser.Event next = parser.next();
- if (next.equals(JsonParser.Event.KEY_NAME) && parser.getString().equals("date-converted")) {
- parser.next();
- result.date = ctx.deserialize(Date.class, parser);
- break;
- }
- }
- return result;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/model/CrateInner.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/model/CrateInner.java
deleted file mode 100644
index 875e27f..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/model/CrateInner.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.serializers.model;
-
-import javax.json.bind.annotation.JsonbDateFormat;
-import javax.json.bind.annotation.JsonbProperty;
-import java.math.BigDecimal;
-import java.util.Date;
-
-/**
- * @author Roman Grigoriadi
- */
-@JsonbDateFormat("dd.MM.yyyy || HH:mm:ss")
-public class CrateInner {
-
- @JsonbProperty("crate_inner_str")
- public String crateInnerStr;
-
- public BigDecimal crateInnerBigDec;
-
- public Date date;
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/model/CrateJsonObjectDeserializer.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/model/CrateJsonObjectDeserializer.java
deleted file mode 100644
index 6966c4f..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/model/CrateJsonObjectDeserializer.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.serializers.model;
-
-import javax.json.JsonObject;
-import javax.json.bind.serializer.DeserializationContext;
-import javax.json.bind.serializer.JsonbDeserializer;
-import javax.json.stream.JsonParser;
-import java.lang.reflect.Type;
-
-/**
- * @author Roman Grigoriadi
- */
-public class CrateJsonObjectDeserializer implements JsonbDeserializer<Crate> {
-
- /**
- * Deserialize an object from JSON.
- * Cursor of JsonParser is at START_OBJECT.
- *
- * @param parser Json parser
- * @param ctx Deserialization context
- * @param rtType type of returned object
- * @return deserialized instance
- */
- @Override
- public Crate deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) {
- JsonObject crateJsonObject = ctx.deserialize(JsonObject.class, parser);
- Crate crate = new Crate();
- crate.crateInner = new CrateInner();
- crate.crateInner.crateInnerStr = crateJsonObject.getJsonObject("crateInner").getString("crateInnerStr");
- crate.crateInner.crateInnerBigDec = crateJsonObject.getJsonObject("crateInner").getJsonNumber("crateInnerBigDec").bigDecimalValue();
- crate.crateStr = crateJsonObject.getString("crateStr");
- crate.crateBigDec = crateJsonObject.getJsonNumber("crateBigDec").bigDecimalValue();
- return crate;
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/model/CrateSerializer.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/model/CrateSerializer.java
deleted file mode 100644
index 37c7c90..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/model/CrateSerializer.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.serializers.model;
-
-import javax.json.bind.serializer.JsonbSerializer;
-import javax.json.bind.serializer.SerializationContext;
-import javax.json.stream.JsonGenerator;
-import java.math.BigDecimal;
-
-/**
- * @author Roman Grigoriadi
- */
-public class CrateSerializer implements JsonbSerializer<Crate> {
-
- @Override
- public void serialize(Crate obj, JsonGenerator generator, SerializationContext ctx) {
- generator.writeStartObject();
- generator.write("crateStr", "REPLACED crate str");
- ctx.serialize("crateInner", obj.crateInner, generator);
- ctx.serialize("crateInnerList", obj.crateInnerList, generator);
- generator.write("crateBigDec", new BigDecimal("54321"));
- generator.writeEnd();
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/model/CrateSerializerWithConversion.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/model/CrateSerializerWithConversion.java
deleted file mode 100644
index de3900b..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/model/CrateSerializerWithConversion.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.serializers.model;
-
-import javax.json.bind.serializer.SerializationContext;
-import javax.json.stream.JsonGenerator;
-import java.math.BigDecimal;
-
-/**
- * @author Roman Grigoriadi
- */
-public class CrateSerializerWithConversion extends CrateSerializer {
-
- @Override
- public void serialize(Crate obj, JsonGenerator generator, SerializationContext ctx) {
- generator.writeStartObject();
- generator.write("crateStr", "REPLACED crate str");
- ctx.serialize("crateInner", obj.crateInner, generator);
- ctx.serialize("crateInnerList", obj.crateInnerList, generator);
- generator.write("crateBigDec", new BigDecimal("54321"));
- ctx.serialize("date-converted", obj.date, generator);
- generator.writeEnd();
- }
-}
diff --git a/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/model/PolymorphicDeserializer.java b/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/model/PolymorphicDeserializer.java
deleted file mode 100644
index 0e1c04f..0000000
--- a/jsonb/src/test/java/org/eclipse/persistence/json/bind/serializers/model/PolymorphicDeserializer.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- * which accompanies this distribution.
- * The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- * and the Eclipse Distribution License is available at
- * http://www.eclipse.org/org/documents/edl-v10.php.
- *
- * Contributors:
- * Roman Grigoriadi
- ******************************************************************************/
-
-package org.eclipse.persistence.json.bind.serializers.model;
-
-import org.eclipse.persistence.json.bind.adapters.PolymorphismAdapterTest;
-
-import javax.json.bind.serializer.DeserializationContext;
-import javax.json.bind.serializer.JsonbDeserializer;
-import javax.json.stream.JsonParser;
-import java.lang.reflect.Type;
-
-/**
- * @author Roman Grigoriadi
- */
-public class PolymorphicDeserializer implements JsonbDeserializer<PolymorphismAdapterTest.Animal> {
- @Override
- public PolymorphismAdapterTest.Animal deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) {
- Class<? extends PolymorphismAdapterTest.Animal> clazz = null;
-
- while (parser.hasNext()) {
- final JsonParser.Event next = parser.next();
- if (next == JsonParser.Event.KEY_NAME && parser.getString().equals("className")) {
- parser.next();
- try {
- clazz = (Class<? extends PolymorphismAdapterTest.Animal>)Thread.currentThread().getContextClassLoader().loadClass(parser.getString());
- } catch (ClassNotFoundException e) {
- throw new RuntimeException(e);
- }
- }
- if (next == JsonParser.Event.KEY_NAME && parser.getString().equals("pojo")) {
- return ctx.deserialize(clazz, parser); //--- REENTRANT CALL---
- }
- }
- throw new IllegalStateException("animal not found!");
- }
-}
diff --git a/jsonb/src/test/resources/META-INF/beans.xml b/jsonb/src/test/resources/META-INF/beans.xml
deleted file mode 100644
index 606280d..0000000
--- a/jsonb/src/test/resources/META-INF/beans.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- ~ Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
- ~ This program and the accompanying materials are made available under the
- ~ terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
- ~ which accompanies this distribution.
- ~ The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
- ~ and the Eclipse Distribution License is available at
- ~ http://www.eclipse.org/org/documents/edl-v10.php.
- ~
- ~ Contributors:
- ~ Roman Grigoriadi
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
-
-<beans xmlns="http://java.sun.com/xml/ns/javaee" />
diff --git a/jsonb/src/test/resources/jndi.properties b/jsonb/src/test/resources/jndi.properties
deleted file mode 100644
index cb7f589..0000000
--- a/jsonb/src/test/resources/jndi.properties
+++ /dev/null
@@ -1,14 +0,0 @@
-################################################################################
-# Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
-# This program and the accompanying materials are made available under the
-# terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
-# which accompanies this distribution.
-# The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
-# and the Eclipse Distribution License is available at
-# http://www.eclipse.org/org/documents/edl-v10.php.
-#
-# Contributors:
-# Roman Grigoriadi
-################################################################################
-
-java.naming.factory.initial=org.eclipse.persistence.json.bind.internal.cdi.MockJndiContextFactory
\ No newline at end of file
diff --git a/jsonb/src/test/resources/logging.properties b/jsonb/src/test/resources/logging.properties
deleted file mode 100644
index 9838029..0000000
--- a/jsonb/src/test/resources/logging.properties
+++ /dev/null
@@ -1,18 +0,0 @@
-################################################################################
-# Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
-# This program and the accompanying materials are made available under the
-# terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
-# which accompanies this distribution.
-# The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
-# and the Eclipse Distribution License is available at
-# http://www.eclipse.org/org/documents/edl-v10.php.
-#
-# Contributors:
-# Roman Grigoriadi
-################################################################################
-
-handlers=java.util.logging.ConsoleHandler
-.level=INFO
-
-java.util.logging.ConsoleHandler.level=INFO
-java.util.logging.ConsoleHandler.formatter=org.eclipse.persistence.json.bind.logger.JsonbLoggerFormatter
\ No newline at end of file
diff --git a/jsonb/src/test/resources/messages_cs.properties b/jsonb/src/test/resources/messages_cs.properties
deleted file mode 100644
index 5c7b5a6..0000000
--- a/jsonb/src/test/resources/messages_cs.properties
+++ /dev/null
@@ -1,18 +0,0 @@
-################################################################################
-# Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
-# This program and the accompanying materials are made available under the
-# terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
-# which accompanies this distribution.
-# The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
-# and the Eclipse Distribution License is available at
-# http://www.eclipse.org/org/documents/edl-v10.php.
-#
-# Contributors:
-# Roman Grigoriadi
-# David Kral
-################################################################################
-
-processFromJson = Zpracovávám třídu: {0} z jsonu za použití convertoru: {1}
-processToJson = Zpracovávám třídu: {0} do jsonu za použití convertoru: {1}
-
-diacriticsTest=p\u0159\u00edli\u0161,\u017elu\u0165ou\u010dk\u00fd,k\u016f\u0148,\u00fap\u011bl,\u010f\u00e1belsk\u00e9,\u00f3dy