Created
February 28, 2020 13:26
-
-
Save vegegoku/6b7339c61f374d054f402214a167e562 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public final class SimpleBeanBeanJsonSerializerImpl extends AbstractBeanJsonSerializer<SimpleBean> { | |
public SimpleBeanBeanJsonSerializerImpl() { | |
} | |
@Override | |
public Class getSerializedType() { | |
return SimpleBean.class; | |
} | |
@Override | |
protected BeanPropertySerializer[] initSerializers() { | |
BeanPropertySerializer[] result = new BeanPropertySerializer[2]; | |
result[0] = new BeanPropertySerializer<SimpleBean, Integer>("id") { | |
@Override | |
protected JsonSerializer<?> newSerializer() { | |
return BaseNumberJsonSerializer.IntegerJsonSerializer.getInstance(); | |
} | |
@Override | |
public Integer getValue(SimpleBean bean, JsonSerializationContext ctx) { | |
return bean.getId(); | |
} | |
}; | |
result[1] = new BeanPropertySerializer<SimpleBean, String>("name") { | |
@Override | |
protected JsonSerializer<?> newSerializer() { | |
return StringJsonSerializer.getInstance(); | |
} | |
@Override | |
public String getValue(SimpleBean bean, JsonSerializationContext ctx) { | |
return bean.getName(); | |
} | |
}; | |
return result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment