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


import com.poseidon.annotation.NotNullArgs;
import com.poseidon.exception.NotNullException;
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.Method;
package com.poseidon.advices;



/**
 * Esta classe ira processar a annotation @NotNull em toda a aplicacao.
 * @author ahrons
 * @see NoNullArgs
 */
@Component
@Aspect
public class NotNullArgsProcessAdvice {

	/**
	 * Este metodo ira fazer o processamento da annotation @NotNull
	 * @param joinPoint
	 * @see NotNullArgs
	 */
	@Before("execution(* com.poseidon.*..*(..))")
	public void logServiceAccess(JoinPoint joinPoint) {

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

		NotNullArgs annotation = method.getAnnotation(NotNullArgs.class);

		if (annotation == null) {
			return;
		}

		String[] nullArgs = annotation.nullArgs();

		Object[] args = joinPoint.getArgs();

		checkForNullArgs(nullArgs, args);

	}

	private void checkForNullArgs(String[] nullArgs, Object[] args) {
		for (int i = 0; i < args.length; i++) {
			if (!validatePositionArgs(i, nullArgs)) {
				if (args[i] == null) {
// Path: src/main/java/com/poseidon/exception/NotNullException.java
// public class NotNullException extends PoseidonException {
// 
// 	public NotNullException(String message) {
// 		super(message);
// 
// 	}
// 
// }


// Path: src/main/java/com/poseidon/advices/NotNullArgsProcessAdvice.java
import com.poseidon.annotation.NotNullArgs;
import com.poseidon.exception.NotNullException;
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.Method;

package com.poseidon.advices;



/**
 * Esta classe ira processar a annotation @NotNull em toda a aplicacao.
 * @author ahrons
 * @see NoNullArgs
 */
@Component
@Aspect
public class NotNullArgsProcessAdvice {

	/**
	 * Este metodo ira fazer o processamento da annotation @NotNull
	 * @param joinPoint
	 * @see NotNullArgs
	 */
	@Before("execution(* com.poseidon.*..*(..))")
	public void logServiceAccess(JoinPoint joinPoint) {

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

		NotNullArgs annotation = method.getAnnotation(NotNullArgs.class);

		if (annotation == null) {
			return;
		}

		String[] nullArgs = annotation.nullArgs();

		Object[] args = joinPoint.getArgs();

		checkForNullArgs(nullArgs, args);

	}

	private void checkForNullArgs(String[] nullArgs, Object[] args) {
		for (int i = 0; i < args.length; i++) {
			if (!validatePositionArgs(i, nullArgs)) {
				if (args[i] == null) {
					throw new NotNullException("argumento null, numero da ordem de declracao no metodo: " + i);