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

com.silentgo.core.aop.MethodAdviser Maven / Gradle / Ivy

There is a newer version: 0.0.49
Show newest version
package com.silentgo.core.aop;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

/**
 * Project : silentgo
 * com.silentgo.core.aop
 *
 *         

* @author teddyzhu * Created by teddyzhu on 16/7/27. */ public class MethodAdviser { private String methodName; private String className; private Method method; private MethodParam[] params; private List> anTypes = new ArrayList<>(); private List annotations = new ArrayList<>(); public String getMethodName() { return methodName; } public Method getName() { return method; } public MethodParam[] getParams() { return params; } public MethodAdviser(String className, String name, Method method, MethodParam[] params, List annotations) { this.methodName = name; this.className = className; this.method = method; this.params = params; this.annotations = annotations; anTypes = new ArrayList<>(); annotations.forEach(annotation -> anTypes.add(annotation.annotationType())); } public String getClassName() { return className; } public List getAnnotations() { return annotations; } public boolean existAnnotation(Class clz) { return anTypes.contains(clz); } @SuppressWarnings("unchecked") public T getAnnotation(Class tClass) { Optional optional = annotations.stream().filter(annotation -> annotation.annotationType().equals(tClass)).findFirst(); if (optional.isPresent()) return (T) optional.get(); else return null; } public Method getMethod() { return method; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy