com.yodlee.sdk.api.validators.ApiValidator Maven / Gradle / Ivy
/**
* Copyright (c) 2019 Yodlee, Inc. All Rights Reserved.
*
* Licensed under the MIT License. See LICENSE file in the project root for license information.
*/
package com.yodlee.sdk.api.validators;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import javax.validation.ConstraintViolation;
import javax.validation.executable.ExecutableValidator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.yodlee.api.model.AbstractModelComponent;
import com.yodlee.api.model.validator.Problem;
import com.yodlee.api.model.validator.Validator.APIModelValidatorFactory;
import com.yodlee.sdk.api.AbstractApi;
import com.yodlee.sdk.api.exception.ApiException;
import com.yodlee.sdk.api.util.ApiUtils;
import com.yodlee.sdk.context.ContextType;
public class ApiValidator {
private static final long MAX_ID = 99999999999L;
private static final Logger LOGGER = LoggerFactory.getLogger(ApiValidator.class);
private ApiValidator() {}
public static List validate(AbstractModelComponent modelComponent) {
final List problems = new ArrayList<>();
return modelComponent == null ? problems : modelComponent.validate();
}
public static List validate(Object o, String methodName, Class>[] types, Object... vars) {
final ExecutableValidator executablesValidator =
APIModelValidatorFactory.SINGLE_INSTANCE.getValidator().forExecutables();
final List problems = new ArrayList<>();
try {
final Set> violations =
executablesValidator.validateParameters(o, o.getClass().getMethod(methodName, types), vars);
for (Iterator> iterator = violations.iterator(); iterator.hasNext();) {
ConstraintViolation
© 2015 - 2025 Weber Informatics LLC | Privacy Policy