Ejemplo n.º 1
0
 @Override
 protected NodeTuple representJavaBeanProperty(
     Object javaBean, Property property, Object propertyValue, Tag customTag) {
   NodeTuple tuple =
       super.representJavaBeanProperty(javaBean, property, propertyValue, customTag);
   Node valueNode = tuple.getValueNode();
   if (Tag.NULL.equals(valueNode.getTag())) {
     return null; // skip 'null' values
   }
   if (valueNode instanceof CollectionNode) {
     if (Tag.SEQ.equals(valueNode.getTag())) {
       SequenceNode seq = (SequenceNode) valueNode;
       if (seq.getValue().isEmpty()) {
         return null; // skip empty lists
       }
     }
     if (Tag.MAP.equals(valueNode.getTag())) {
       MappingNode seq = (MappingNode) valueNode;
       if (seq.getValue().isEmpty()) {
         return null; // skip empty maps
       }
     }
   }
   return tuple;
 }
Ejemplo n.º 2
0
 protected NodeTuple representJavaBeanProperty(
     Object javaBean, Property property, Object propertyValue, Tag customTag) {
   final NodeTuple tuple =
       super.representJavaBeanProperty(javaBean, property, propertyValue, customTag);
   final Node valueNode = tuple.getValueNode();
   if (valueNode instanceof CollectionNode) {
     // Removed null check
     if (Tag.SEQ.equals(valueNode.getTag())) {
       final SequenceNode seq = (SequenceNode) valueNode;
       if (seq.getValue().isEmpty()) {
         return null; // skip empty lists
       }
     }
     if (Tag.MAP.equals(valueNode.getTag())) {
       final MappingNode seq = (MappingNode) valueNode;
       if (seq.getValue().isEmpty()) {
         return null; // skip empty maps
       }
     }
   }
   return tuple;
 }