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

org.joo.libra.text.IsEmptyPredicate Maven / Gradle / Ivy

There is a newer version: 2.1.2
Show newest version
package org.joo.libra.text;

import java.util.Collection;

import org.joo.libra.PredicateContext;
import org.joo.libra.common.CompositionPredicate;
import org.joo.libra.common.HasValue;

public class IsEmptyPredicate extends CompositionPredicate {

	private HasValue value;

	public IsEmptyPredicate(HasValue value) {
		this.value = value;
	}

	@SuppressWarnings("rawtypes")
	@Override
	public boolean satisfiedBy(PredicateContext context) {
		Object rawValue = value.getValue(context);
		if (rawValue == null) return true;
		if (rawValue instanceof String) {
			return rawValue.toString().isEmpty();
		}
		if (rawValue instanceof Collection) {
			return ((Collection)rawValue).isEmpty();
		}
		return false;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy