All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.beosign.snakeyamlanno.skip.SkipIfEmpty Maven / Gradle / Ivy

Go to download

This is the snakeyaml-anno library by github.com/beosign/snakeyaml-anno - released so we can use it on Maven Central. It otherwise has no changes.

The newest version!
package de.beosign.snakeyamlanno.skip;

import java.util.List;
import java.util.Map;

import org.yaml.snakeyaml.introspector.Property;
import org.yaml.snakeyaml.nodes.Tag;

/**
 * Skips the property while dumping if one of the following conditions is true.
 * 
    *
  • the value is an empty collection
  • *
  • the value is an empty map
  • *
  • the value is an empty String (length 0)
  • *
* * @author florian */ public class SkipIfEmpty implements SkipAtDumpPredicate { private static final SkipIfEmpty instance = new SkipIfEmpty(); /** * Returns the singleton instance. * * @return singleton */ public static SkipIfEmpty getInstance() { return instance; } @Override public boolean skip(Object javaBean, Property property, Object propertyValue, Tag customTag) { if (propertyValue instanceof Map) { return ((Map) propertyValue).size() == 0; } if (propertyValue instanceof List) { return ((List) propertyValue).size() == 0; } if (propertyValue instanceof String) { return ((String) propertyValue).length() == 0; } return false; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy