Skip to content

Commit

Permalink
Rebased onto the current master
Browse files Browse the repository at this point in the history
Signed-off-by: David Kral <david.k.kral@oracle.com>
  • Loading branch information
Verdent committed Oct 21, 2019
1 parent 68b1fb9 commit 9c46eff
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 34 deletions.
8 changes: 0 additions & 8 deletions src/main/java/org/eclipse/yasson/YassonJsonb.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public interface YassonJsonb extends javax.json.bind.Jsonb {
* @param <T> Type of the content tree's root object.
* @return the newly created root object of the java content tree
* @throws JsonbException If any unexpected error(s) occur(s) during deserialization.
* @throws NullPointerException If any of the parameters is {@code null}.
*/
<T> T fromJson(JsonParser jsonParser, Class<T> type) throws JsonbException;

Expand All @@ -53,7 +52,6 @@ public interface YassonJsonb extends javax.json.bind.Jsonb {
* @param <T> Type of the content tree's root object.
* @return the newly created root object of the java content tree
* @throws JsonbException If any unexpected error(s) occur(s) during deserialization.
* @throws NullPointerException If any of the parameters is {@code null}.
*/
<T> T fromJson(JsonParser jsonParser, Type runtimeType) throws JsonbException;

Expand All @@ -66,7 +64,6 @@ public interface YassonJsonb extends javax.json.bind.Jsonb {
* @param <T> Type of the content tree's root object.
* @return the newly created root object of the java content tree
* @throws JsonbException If any unexpected error(s) occur(s) during conversion.
* @throws NullPointerException If any of the parameters is {@code null}.
*/
<T> T fromJsonStructure(JsonStructure jsonStructure, Class<T> type) throws JsonbException;

Expand All @@ -79,7 +76,6 @@ public interface YassonJsonb extends javax.json.bind.Jsonb {
* @param <T> Type of the content tree's root object.
* @return the newly created root object of the java content tree
* @throws JsonbException If any unexpected error(s) occur(s) during deserialization.
* @throws NullPointerException If any of the parameters is {@code null}.
*/
<T> T fromJsonStructure(JsonStructure jsonStructure, Type runtimeType) throws JsonbException;

Expand All @@ -92,7 +88,6 @@ public interface YassonJsonb extends javax.json.bind.Jsonb {
* on a completion for further interaction.
* @throws JsonbException If any unexpected problem occurs during the
* serialization.
* @throws NullPointerException If any of the parameters is {@code null}.
* @since JSON Binding 1.0
*/
void toJson(Object object, JsonGenerator jsonGenerator) throws JsonbException;
Expand All @@ -107,7 +102,6 @@ public interface YassonJsonb extends javax.json.bind.Jsonb {
* on a completion for further interaction.
* @throws JsonbException If any unexpected problem occurs during the
* serialization.
* @throws NullPointerException If any of the parameters is {@code null}.
* @since JSON Binding 1.0
*/
void toJson(Object object, Type runtimeType, JsonGenerator jsonGenerator) throws JsonbException;
Expand All @@ -119,7 +113,6 @@ public interface YassonJsonb extends javax.json.bind.Jsonb {
* @return The {@link JsonStructure} serialized from java content tree.
* @throws JsonbException If any unexpected problem occurs during the
* serialization.
* @throws NullPointerException If any of the parameters is {@code null}.
* @since JSON Binding 1.0
*/
JsonStructure toJsonStructure(Object object) throws JsonbException;
Expand All @@ -132,7 +125,6 @@ public interface YassonJsonb extends javax.json.bind.Jsonb {
* @return The {@link JsonStructure} serialized from java content tree.
* @throws JsonbException If any unexpected problem occurs during the
* serialization.
* @throws NullPointerException If any of the parameters is {@code null}.
* @since JSON Binding 1.0
*/
JsonStructure toJsonStructure(Object object, Type runtimeType) throws JsonbException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,6 @@ private <T extends Annotation> T findAnnotation(Annotation[] declaredAnnotations
* Finds annotations incompatible with {@link JsonbTransient} annotation.
*
* @param target target to check
* @throws JsonbException If incompatible annotation is found.
*/
@SuppressWarnings("unchecked")
public void checkTransientIncompatible(JsonbAnnotatedElement<?> target) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@
******************************************************************************/
package org.eclipse.yasson.internal.model;


import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.InvocationTargetException;
import java.lang.IllegalAccessException;
import java.lang.reflect.Method;
import java.util.Objects;

import javax.json.bind.config.PropertyVisibilityStrategy;
import javax.json.bind.JsonbException;
import javax.json.bind.config.PropertyVisibilityStrategy;

/**
* Property value propagation by reflection.
Expand All @@ -46,16 +44,17 @@ public ReflectionPropagation(Property property, PropertyVisibilityStrategy strat
*/
@Override
protected void acceptMethod(Method method, OperationMode mode) {
Objects.requireNonNull(method);
Objects.requireNonNull(method);

switch (mode) {
case GET:
getValueCommand = method::invoke;
break;
case SET:
setValueCommand = method::invoke;
break;
default: throw new IllegalStateException("Unknown mode");
case GET:
getValueCommand = method::invoke;
break;
case SET:
setValueCommand = method::invoke;
break;
default:
throw new IllegalStateException("Unknown mode");
}
}

Expand All @@ -64,32 +63,33 @@ protected void acceptMethod(Method method, OperationMode mode) {
*/
@Override
protected void acceptField(Field field, OperationMode mode) {
Objects.requireNonNull(field);
Objects.requireNonNull(field);

switch (mode) {
case GET:
getValueCommand = field::get;
break;
case SET:
setValueCommand = field::set;
break;
default: throw new IllegalStateException("Unknown mode");
case GET:
getValueCommand = field::get;
break;
case SET:
setValueCommand = field::set;
break;
default:
throw new IllegalStateException("Unknown mode");
}
}

/**
* Sets a value with reflection on {@link java.lang.reflect.Field field} or {@link java.lang.reflect.Method setter}.
*
* @param object object to invoke set value on, not null.
* @param value object to be set, nullable.
* @param value object to be set, nullable.
* @throws JsonbException if reflection fails.
*/
@Override
void setValue(Object object, Object value) {
Objects.requireNonNull(object);
Objects.requireNonNull(object);

try {
setValueCommand.setValue(object, value);
setValueCommand.setValue(object, value);
} catch (InvocationTargetException | IllegalAccessException e) {
throw new JsonbException("Error getting value on: " + object, e);
}
Expand All @@ -99,12 +99,12 @@ void setValue(Object object, Object value) {
* Get a value with reflection on {@link java.lang.reflect.Field field} or {@link java.lang.reflect.Method getter}.
*
* @param object object to invoke get value on, not null.
* @throws JsonbException if reflection fails.
* @return value
* @throws JsonbException if reflection fails.
*/
@Override
Object getValue(Object object) {
Objects.requireNonNull(object);
Objects.requireNonNull(object);

try {
return getValueCommand.getValue(object);
Expand Down

0 comments on commit 9c46eff

Please sign in to comment.