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

com.neotys.neoload.model.validation.constraintvalidators.RequiredValidator Maven / Gradle / Ivy

package com.neotys.neoload.model.validation.constraintvalidators;

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

import javax.validation.ConstraintValidatorContext;

import com.neotys.neoload.model.validation.constraints.RequiredCheck;

/**
 * @deprecated As of v3, replaced by an associated class from v3 version.
 */
@Deprecated
public final class RequiredValidator extends AbstractConstraintValidator {
	@Override
	public boolean isValid(final Object object, final ConstraintValidatorContext context) {
		if (object == null) return false;
		
		if (object instanceof CharSequence) {
			return object.toString().trim().length() > 0;
		}
		
		if (object instanceof Collection) {
			return !((Collection) object).isEmpty();
		}
		
		if (object instanceof Map) {
			return !((Map) object).isEmpty();
		}
		
		return true;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy