com.fasterxml.jackson.databind.JsonSerializer.usesObjectId()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(8.3k)|赞(0)|评价(0)|浏览(83)

本文整理了Java中com.fasterxml.jackson.databind.JsonSerializer.usesObjectId()方法的一些代码示例,展示了JsonSerializer.usesObjectId()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JsonSerializer.usesObjectId()方法的具体详情如下:
包路径:com.fasterxml.jackson.databind.JsonSerializer
类名称:JsonSerializer
方法名:usesObjectId

JsonSerializer.usesObjectId介绍

[英]Method that can be called to see whether this serializer instance will use Object Id to handle cyclic references.
[中]方法,以查看此序列化程序实例是否将使用对象Id来处理循环引用。

代码示例

代码示例来源:origin: redisson/redisson

  1. /**
  2. * Method called to handle a direct self-reference through this property.
  3. * Method can choose to indicate an error by throwing
  4. * {@link JsonMappingException}; fully handle serialization (and return
  5. * true); or indicate that it should be serialized normally (return false).
  6. * <p>
  7. * Default implementation will throw {@link JsonMappingException} if
  8. * {@link SerializationFeature#FAIL_ON_SELF_REFERENCES} is enabled; or
  9. * return <code>false</code> if it is disabled.
  10. *
  11. * @return True if method fully handled self-referential value; false if not
  12. * (caller is to handle it) or {@link JsonMappingException} if there
  13. * is no way handle it
  14. */
  15. protected boolean _handleSelfReference(Object bean, JsonGenerator gen,
  16. SerializerProvider prov, JsonSerializer<?> ser)
  17. throws JsonMappingException {
  18. if (prov.isEnabled(SerializationFeature.FAIL_ON_SELF_REFERENCES)
  19. && !ser.usesObjectId()) {
  20. // 05-Feb-2013, tatu: Usually a problem, but NOT if we are handling
  21. // object id; this may be the case for BeanSerializers at least.
  22. // 13-Feb-2014, tatu: another possible ok case: custom serializer
  23. // (something
  24. // OTHER than {@link BeanSerializerBase}
  25. if (ser instanceof BeanSerializerBase) {
  26. prov.reportBadDefinition(getType(), "Direct self-reference leading to cycle");
  27. }
  28. }
  29. return false;
  30. }

代码示例来源:origin: com.fasterxml.jackson.datatype/jackson-datatype-hibernate3

  1. @Override
  2. public boolean usesObjectId() {
  3. return _serializer.usesObjectId();
  4. }

代码示例来源:origin: FasterXML/jackson-datatype-hibernate

  1. @Override
  2. public boolean usesObjectId() {
  3. return _serializer.usesObjectId();
  4. }

代码示例来源:origin: FasterXML/jackson-datatype-hibernate

  1. @Override
  2. public boolean usesObjectId() {
  3. return _serializer.usesObjectId();
  4. }

代码示例来源:origin: com.fasterxml.jackson.datatype/jackson-datatype-hibernate5

  1. @Override
  2. public boolean usesObjectId() {
  3. return _serializer.usesObjectId();
  4. }

代码示例来源:origin: com.fasterxml.jackson.datatype/jackson-datatype-hibernate4

  1. @Override
  2. public boolean usesObjectId() {
  3. return _serializer.usesObjectId();
  4. }

代码示例来源:origin: FasterXML/jackson-datatype-hibernate

  1. @Override
  2. public boolean usesObjectId() {
  3. return _serializer.usesObjectId();
  4. }

代码示例来源:origin: com.fasterxml.jackson.core/com.springsource.com.fasterxml.jackson.core.jackson-databind

  1. protected void _handleSelfReference(Object bean, JsonSerializer<?> ser)
  2. throws JsonMappingException
  3. {
  4. /* 05-Feb-2012, tatu: Usually a problem, but NOT if we are handling
  5. * object id; this may be the case for BeanSerializers at least.
  6. */
  7. if (ser.usesObjectId()) {
  8. return;
  9. }
  10. throw new JsonMappingException("Direct self-reference leading to cycle");
  11. }

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-analytics

  1. protected void _handleSelfReference(Object bean, JsonSerializer<?> ser)
  2. throws JsonMappingException
  3. {
  4. /* 05-Feb-2012, tatu: Usually a problem, but NOT if we are handling
  5. * object id; this may be the case for BeanSerializers at least.
  6. */
  7. if (ser.usesObjectId()) {
  8. return;
  9. }
  10. throw new JsonMappingException("Direct self-reference leading to cycle");
  11. }

代码示例来源:origin: sosoapi/framework

  1. protected void _handleSelfReference(Object bean, JsonSerializer<?> ser)
  2. throws JsonMappingException
  3. {
  4. /* 05-Feb-2012, tatu: Usually a problem, but NOT if we are handling
  5. * object id; this may be the case for BeanSerializers at least.
  6. */
  7. if (ser.usesObjectId()) {
  8. return;
  9. }
  10. throw new JsonMappingException("Direct self-reference leading to cycle");
  11. }

代码示例来源:origin: com.eclipsesource.jaxrs/jersey-all

  1. /**
  2. * Method called to handle a direct self-reference through this property.
  3. * Method can choose to indicate an error by throwing {@link JsonMappingException};
  4. * fully handle serialization (and return true); or indicate that it should be
  5. * serialized normally (return false).
  6. *<p>
  7. * Default implementation will throw {@link JsonMappingException} if
  8. * {@link SerializationFeature#FAIL_ON_SELF_REFERENCES} is enabled;
  9. * or return <code>false</code> if it is disabled.
  10. *
  11. * @return True if method fully handled self-referential value; false if not (caller
  12. * is to handle it) or {@link JsonMappingException} if there is no way handle it
  13. */
  14. protected boolean _handleSelfReference(Object bean, JsonGenerator gen, SerializerProvider prov, JsonSerializer<?> ser)
  15. throws JsonMappingException {
  16. if (prov.isEnabled(SerializationFeature.FAIL_ON_SELF_REFERENCES)
  17. && !ser.usesObjectId()) {
  18. // 05-Feb-2013, tatu: Usually a problem, but NOT if we are handling
  19. // object id; this may be the case for BeanSerializers at least.
  20. // 13-Feb-2014, tatu: another possible ok case: custom serializer (something
  21. // OTHER than {@link BeanSerializerBase}
  22. if (ser instanceof BeanSerializerBase) {
  23. throw new JsonMappingException("Direct self-reference leading to cycle");
  24. }
  25. }
  26. return false;
  27. }

代码示例来源:origin: hstaudacher/osgi-jax-rs-connector

  1. /**
  2. * Method called to handle a direct self-reference through this property.
  3. * Method can choose to indicate an error by throwing {@link JsonMappingException};
  4. * fully handle serialization (and return true); or indicate that it should be
  5. * serialized normally (return false).
  6. *<p>
  7. * Default implementation will throw {@link JsonMappingException} if
  8. * {@link SerializationFeature#FAIL_ON_SELF_REFERENCES} is enabled;
  9. * or return <code>false</code> if it is disabled.
  10. *
  11. * @return True if method fully handled self-referential value; false if not (caller
  12. * is to handle it) or {@link JsonMappingException} if there is no way handle it
  13. */
  14. protected boolean _handleSelfReference(Object bean, JsonGenerator gen, SerializerProvider prov, JsonSerializer<?> ser)
  15. throws JsonMappingException {
  16. if (prov.isEnabled(SerializationFeature.FAIL_ON_SELF_REFERENCES)
  17. && !ser.usesObjectId()) {
  18. // 05-Feb-2013, tatu: Usually a problem, but NOT if we are handling
  19. // object id; this may be the case for BeanSerializers at least.
  20. // 13-Feb-2014, tatu: another possible ok case: custom serializer (something
  21. // OTHER than {@link BeanSerializerBase}
  22. if (ser instanceof BeanSerializerBase) {
  23. throw new JsonMappingException("Direct self-reference leading to cycle");
  24. }
  25. }
  26. return false;
  27. }

代码示例来源:origin: Nextdoor/bender

  1. /**
  2. * Method called to handle a direct self-reference through this property.
  3. * Method can choose to indicate an error by throwing
  4. * {@link JsonMappingException}; fully handle serialization (and return
  5. * true); or indicate that it should be serialized normally (return false).
  6. * <p>
  7. * Default implementation will throw {@link JsonMappingException} if
  8. * {@link SerializationFeature#FAIL_ON_SELF_REFERENCES} is enabled; or
  9. * return <code>false</code> if it is disabled.
  10. *
  11. * @return True if method fully handled self-referential value; false if not
  12. * (caller is to handle it) or {@link JsonMappingException} if there
  13. * is no way handle it
  14. */
  15. protected boolean _handleSelfReference(Object bean, JsonGenerator gen,
  16. SerializerProvider prov, JsonSerializer<?> ser)
  17. throws JsonMappingException {
  18. if (prov.isEnabled(SerializationFeature.FAIL_ON_SELF_REFERENCES)
  19. && !ser.usesObjectId()) {
  20. // 05-Feb-2013, tatu: Usually a problem, but NOT if we are handling
  21. // object id; this may be the case for BeanSerializers at least.
  22. // 13-Feb-2014, tatu: another possible ok case: custom serializer
  23. // (something
  24. // OTHER than {@link BeanSerializerBase}
  25. if (ser instanceof BeanSerializerBase) {
  26. prov.reportMappingProblem("Direct self-reference leading to cycle");
  27. }
  28. }
  29. return false;
  30. }

代码示例来源:origin: com.jwebmp.jackson.core/jackson-databind

  1. /**
  2. * Method called to handle a direct self-reference through this property.
  3. * Method can choose to indicate an error by throwing
  4. * {@link JsonMappingException}; fully handle serialization (and return
  5. * true); or indicate that it should be serialized normally (return false).
  6. * <p>
  7. * Default implementation will throw {@link JsonMappingException} if
  8. * {@link SerializationFeature#FAIL_ON_SELF_REFERENCES} is enabled; or
  9. * return <code>false</code> if it is disabled.
  10. *
  11. * @return True if method fully handled self-referential value; false if not
  12. * (caller is to handle it) or {@link JsonMappingException} if there
  13. * is no way handle it
  14. */
  15. protected boolean _handleSelfReference(Object bean, JsonGenerator gen,
  16. SerializerProvider prov, JsonSerializer<?> ser)
  17. throws JsonMappingException {
  18. if (prov.isEnabled(SerializationFeature.FAIL_ON_SELF_REFERENCES)
  19. && !ser.usesObjectId()) {
  20. // 05-Feb-2013, tatu: Usually a problem, but NOT if we are handling
  21. // object id; this may be the case for BeanSerializers at least.
  22. // 13-Feb-2014, tatu: another possible ok case: custom serializer
  23. // (something
  24. // OTHER than {@link BeanSerializerBase}
  25. if (ser instanceof BeanSerializerBase) {
  26. prov.reportBadDefinition(getType(), "Direct self-reference leading to cycle");
  27. }
  28. }
  29. return false;
  30. }

相关文章