// Path: src/main/java/com/poseidon/exception/IllegalAnnotationPosition.java
// public class IllegalAnnotationPosition extends PoseidonException {
// 
// 	public IllegalAnnotationPosition(String message) {
// 		super(message);
// 
// 	}
// }
// 
// Path: src/main/java/com/poseidon/exception/ValidateStringException.java
// public class ValidateStringException extends PoseidonException {
// 
// 	public ValidateStringException(String message) {
// 		super(message);
// 
// 	}
// }


import com.poseidon.annotation.ValidateArgs;
import com.poseidon.annotation.ValidateString;
import com.poseidon.exception.IllegalAnnotationPosition;
import com.poseidon.exception.ValidateStringException;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;
import java.lang.reflect.Field;
import java.lang.reflect.Method;

		final MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
		Method method = methodSignature.getMethod();

		if (!method.isAnnotationPresent(ValidateArgs.class)) {
			return;
		}

		Object[] args = joinPoint.getArgs();

		for (int i = 0; i < args.length; i++) {
			Field[] fields = args[i].getClass().getDeclaredFields();
			for (int j = 0; j < fields.length; j++) {
				validateString(args, i, fields, j);
			}
		}
	}

	private void validateString(Object[] args, int i, Field[] fields, int j) {
		if (fields[j].isAnnotationPresent(ValidateString.class)) {
			ValidateString validateString = fields[j].getAnnotation(ValidateString.class);
			if (!fields[j].getType().equals(String.class)) {
				throw new IllegalAnnotationPosition(
						"a annotation ValidateString esta em um atributo que nao eh String.");
			}
			fields[j].setAccessible(true);
			Object object;
			try {
				object = fields[j].get(args[i]);
				if (object.toString().length() < validateString.minLength() || object.toString().length() > validateString.maxLength() ) {
// Path: src/main/java/com/poseidon/exception/IllegalAnnotationPosition.java
// public class IllegalAnnotationPosition extends PoseidonException {
// 
// 	public IllegalAnnotationPosition(String message) {
// 		super(message);
// 
// 	}
// }
// 
// Path: src/main/java/com/poseidon/exception/ValidateStringException.java
// public class ValidateStringException extends PoseidonException {
// 
// 	public ValidateStringException(String message) {
// 		super(message);
// 
// 	}
// }


// Path: src/main/java/com/poseidon/advices/ValidateAdvice.java
import com.poseidon.annotation.ValidateArgs;
import com.poseidon.annotation.ValidateString;
import com.poseidon.exception.IllegalAnnotationPosition;
import com.poseidon.exception.ValidateStringException;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;
import java.lang.reflect.Field;
import java.lang.reflect.Method;


		final MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
		Method method = methodSignature.getMethod();

		if (!method.isAnnotationPresent(ValidateArgs.class)) {
			return;
		}

		Object[] args = joinPoint.getArgs();

		for (int i = 0; i < args.length; i++) {
			Field[] fields = args[i].getClass().getDeclaredFields();
			for (int j = 0; j < fields.length; j++) {
				validateString(args, i, fields, j);
			}
		}
	}

	private void validateString(Object[] args, int i, Field[] fields, int j) {
		if (fields[j].isAnnotationPresent(ValidateString.class)) {
			ValidateString validateString = fields[j].getAnnotation(ValidateString.class);
			if (!fields[j].getType().equals(String.class)) {
				throw new IllegalAnnotationPosition(
						"a annotation ValidateString esta em um atributo que nao eh String.");
			}
			fields[j].setAccessible(true);
			Object object;
			try {
				object = fields[j].get(args[i]);
				if (object.toString().length() < validateString.minLength() || object.toString().length() > validateString.maxLength() ) {
					throw new ValidateStringException("Erro na validacao da string, do atributo:"+fields[j].getName());