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

net.sf.aguacate.check.impl.CheckNullOrEmpty Maven / Gradle / Ivy

There is a newer version: 0.10.9
Show newest version
package net.sf.aguacate.check.impl;

import java.util.Collection;
import java.util.Map;

import net.sf.aguacate.check.Check;

public class CheckNullOrEmpty implements Check {

	@Override
	public boolean test(Object value) {
		if (value == null) {
			return true;
		} else {
			if (value instanceof Map) {
				return ((Map) value).isEmpty();
			} else {
				if (value instanceof Collection) {
					return ((Collection) value).isEmpty();
				} else {
					Class klass = value.getClass();
					if (String.class == klass) {
						return ((String) value).isEmpty();
					} else {
						throw new IllegalArgumentException(klass.getName());
					}
				}
			}
		}
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy