Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,25 @@ protected JsonBindingException couldNotSerialize(Throwable e) {

public static class MethodAccessor extends PropertyAccessor {
protected final Method _getter;
protected boolean accessible = true;

public MethodAccessor(String name, Method getter, Type type, Class<?> concreteClass) {
super(name, type, getter.getDeclaringClass(), concreteClass, getter.getAnnotations(), getter.getModifiers());
this._getter = getter;
if (!_getter.isAccessible()) {
_getter.setAccessible(true);
try{
_getter.setAccessible(true);
}
catch(Exception e){
accessible = false;
}
}
}

@Override
public Object access(final Object target) {
try {
return _getter.invoke(target);
return accessible ? _getter.invoke(target) : null;
} catch (IllegalArgumentException e) {
throw couldNotAccess(e);
} catch (IllegalAccessException e) {
Expand All @@ -84,19 +90,25 @@ int priority() {

public static class FieldAccessor extends PropertyAccessor {
protected final Field _field;
protected boolean accessible = true;

public FieldAccessor(String name, Field field, Type type, Class<?> concreteClass) {
super(name, type, field.getDeclaringClass(), concreteClass, field.getAnnotations(), field.getModifiers());
this._field = field;
if (!_field.isAccessible()) {
_field.setAccessible(true);
try{
_field.setAccessible(true);
}
catch(Exception e){
accessible = false;
}
}
}

@Override
public Object access(final Object target) {
try {
return _field.get(target);
return accessible ? _field.get(target) : null;
} catch (IllegalArgumentException e) {
throw couldNotAccess(e);
} catch (IllegalAccessException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,27 @@ protected JsonBindingException couldNotDeserialize(Throwable e) {

public static class MethodMutator extends PropertyMutator {
protected final Method _setter;
protected boolean accessible = true;

public MethodMutator(String name, Method setter, Type type, Class<?> concreteClass) {
super(name, type, setter.getDeclaringClass(), concreteClass, setter.getAnnotations(), setter.getModifiers());
this._setter = setter;
if (!_setter.isAccessible()) {
_setter.setAccessible(true);
try{
_setter.setAccessible(true);
}
catch(Exception e){
accessible = false;
}
}
}

@Override
public void mutate(Object target, Object value) {
try {
_setter.invoke(target, value);
if(accessible){
_setter.invoke(target, value);
}
} catch (IllegalArgumentException e) {
throw couldNotMutate(e);
} catch (IllegalAccessException e) {
Expand All @@ -87,19 +95,27 @@ public int priority() {

public static class FieldMutator extends PropertyMutator {
protected final Field _field;
protected boolean accessible = true;

public FieldMutator(String name, Field field, Type type, Class<?> concreteClass) {
super(name, type, field.getDeclaringClass(), concreteClass, field.getAnnotations(), field.getModifiers());
this._field = field;
if (!_field.isAccessible()) {
_field.setAccessible(true);
try{
_field.setAccessible(true);
}
catch(Exception e){
accessible = false;
}
}
}

@Override
public void mutate(Object target, Object value) {
try {
_field.set(target, value);
if(accessible){
_field.set(target, value);
}
} catch (IllegalArgumentException e) {
throw couldNotMutate(e);
} catch (IllegalAccessException e) {
Expand Down