package com.github.aureliano.damihilogs.validation;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;

import com.github.aureliano.damihilogs.annotation.validation.NotNull;
import com.github.aureliano.damihilogs.config.IConfiguration;
import com.github.aureliano.damihilogs.helper.ReflectionHelper;

public class NotNullValidator implements IValidator {

	public NotNullValidator() {
		super();
	}

	@Override
	public ConstraintViolation validate(IConfiguration configuration, Method method, Annotation annotation) {
		String property = ReflectionHelper.getSimpleAccessMethodName(method);
		Object returnedValue = ReflectionHelper.callMethod(configuration, method.getName(), null, null);
		
		if (returnedValue == null) {
			String message = ((NotNull) annotation).message();
			return new ConstraintViolation()
				.withValidator(NotNull.class)
				.withMessage(message.replaceFirst("\\?", property));
		}
		
		return null;
		
		/*for (Method method : methods) {
			Annotation[] annotations = method.getAnnotations();
			for (Annotation annotation : annotations) {
				if (annotation.annotationType().equals(NotNull.class)) {
					Object returnedValue = ReflectionHelper.callMethod(configuration, method.getName(), null, null);
					if (returnedValue == null) {
						String message = ((NotNull) annotation).message();
						validation.add(new ConstraintViolation()
							.withValidator(NotNull.class)
							.withMessage(message.replaceFirst("\\?", ));
					}
				}
			}
		}
		
		return validation;*/
	}
}
@@ -946,587 +946,8 @@
 ll;%0A
-%09%09%0A%09%09/*for (Method method : methods) %7B%0A%09%09%09Annotation%5B%5D annotations = method.getAnnotations();%0A%09%09%09for (Annotation annotation : annotations) %7B%0A%09%09%09%09if (annotation.annotationType().equals(NotNull.class)) %7B%0A%09%09%09%09%09Object returnedValue = ReflectionHelper.callMethod(configuration, method.getName(), null, null);%0A%09%09%09%09%09if (returnedValue == null) %7B%0A%09%09%09%09%09%09String message = ((NotNull) annotation).message();%0A%09%09%09%09%09%09validation.add(new ConstraintViolation()%0A%09%09%09%09%09%09%09.withValidator(NotNull.class)%0A%09%09%09%09%09%09%09.withMessage(message.replaceFirst(%22%5C%5C?%22, ));%0A%09%09%09%09%09%7D%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D%0A%09%09%0A%09%09return validation;*/%0A
 %09%7D%0A%7D

Remove commented code.