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

com.github.marcoblos.mastercardmpgssdk.validator.MastercardValidator Maven / Gradle / Ivy

package com.github.marcoblos.mastercardmpgssdk.validator;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.function.Predicate;

import com.github.marcoblos.mastercardmpgssdk.model.MastercardAPIRequest;
import com.github.marcoblos.mastercardmpgssdk.model.MastercardError;
import com.github.marcoblos.mastercardmpgssdk.model.MastercardResponse;

/**
 * 
 * @author marcoblos 2018-02-22
 *
 */
public abstract class MastercardValidator {

	public MastercardResponse validate(MastercardAPIRequest request) {
		List errors = new ArrayList<>();

		getPredicates().forEach((field, predicate) -> {
			if (!predicate.test(request)) {
				errors.add(new MastercardError(field));
			}
		});
		return new MastercardResponse(errors);
	}

	protected abstract HashMap> getPredicates();

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy