这段代码看起来很少有逻辑上的内容,各种赋值,不是很懂,估计与其他地方有关系,暂做记录
org.b3log.latke.ioc.annotated.AbstractAnnotatedCallableImpl
import org.b3log.latke.util.CollectionUtils; public abstract class AbstractAnnotatedCallableImpl<T> implements AnnotatedCallable<T> { private Member member; private List<AnnotatedParameter<T>> parameters; public AbstractAnnotatedCallableImpl(final Member member) { this.member = member; parameters = new ArrayList<AnnotatedParameter<T>>(); Type[] parameterTypes = null; Annotation[][] parameterAnnotations = null; if (member instanceof Method) { parameterTypes = ((Method) member).getGenericParameterTypes(); parameterAnnotations = ((Method) member).getParameterAnnotations(); } else if (member instanceof Constructor) { parameterTypes = ((Constructor) member).getGenericParameterTypes(); parameterAnnotations = ((Constructor) member).getParameterAnnotations(); } for (int i = 0; i < parameterTypes.length; i++) { final Type parameter = parameterTypes[i]; final Annotation[] annotations = parameterAnnotations[i]; final Set<Annotation> annotationSet = CollectionUtils.arrayToSet(annotations); final AnnotatedParameter<T> annotatedParameter = new AnnotatedParameterImpl<T>(this, parameter, i, annotationSet); this.parameters.add(annotatedParameter); } } @Override public AnnotatedType<T> getDeclaringType() { throw new UnsupportedOperationException("Not supported yet."); } @Override public List<AnnotatedParameter<T>> getParameters() { return parameters; } @Override public boolean isStatic() { return Modifier.isStatic(member.getModifiers()); } //getJavaMember? see:> https://docs.oracle.com/javaee/7/api/toc.htm public Member getMember() { return member; } }
org.b3log.latke.ioc.annotated.AnnotatedConstructorImpl
import javax.enterprise.inject.spi.AnnotatedConstructor; public class AnnotatedConstructorImpl<T> extends AbstractAnnotatedCallableImpl<T> implements AnnotatedConstructor<T> { public AnnotatedConstructorImpl(final Constructor<T> constructor) { super(constructor); } @Override public Constructor<T> getJavaMember() { return (Constructor) getMember(); } @Override public <T extends Annotation> T getAnnotation(final Class<T> annotationType) { return getJavaMember().getAnnotation(annotationType); } @Override public Set<Annotation> getAnnotations() { return new HashSet<Annotation>(Arrays.asList(getJavaMember().getAnnotations())); } @Override public boolean isAnnotationPresent(final Class<? extends Annotation> annotationType) { return getJavaMember().isAnnotationPresent(annotationType); } @Override public Type getBaseType() { throw new UnsupportedOperationException("Not supported yet."); } @Override public Set<Type> getTypeClosure() { throw new UnsupportedOperationException("Not supported yet."); } }
org.b3log.latke.ioc.annotated.AnnotatedFieldImpl
import javax.enterprise.inject.spi.AnnotatedField; import javax.enterprise.inject.spi.AnnotatedType; public class AnnotatedFieldImpl<T> implements AnnotatedField<T> { private Field field; public AnnotatedFieldImpl(final Field field) { this.field = field; } @Override public Field getJavaMember() { return field; } @Override public AnnotatedType<T> getDeclaringType() { throw new UnsupportedOperationException("Not supported yet."); } @Override public boolean isStatic() { return Modifier.isStatic(field.getModifiers()); } @Override public Type getBaseType() { return field.getGenericType(); } @Override public <T extends Annotation> T getAnnotation(final Class<T> annotationType) { return field.getAnnotation(annotationType); } @Override @SuppressWarnings("unchecked") public Set<Annotation> getAnnotations() { return new HashSet<Annotation>(Arrays.asList(field.getAnnotations())); } @Override public boolean isAnnotationPresent( final Class<? extends Annotation> annotationType) { return field.isAnnotationPresent(annotationType); } @Override public String toString() { return field.getName(); } @Override public Set<Type> getTypeClosure() { throw new UnsupportedOperationException("Not supported yet."); } }
org.b3log.latke.ioc.annotated.AnnotatedMethodImpl
import javax.enterprise.inject.spi.AnnotatedMethod; import javax.enterprise.inject.spi.AnnotatedType; public class AnnotatedMethodImpl<T> extends AbstractAnnotatedCallableImpl<T> implements AnnotatedMethod<T> { public AnnotatedMethodImpl(final Method method) { super(method); } @Override public Method getJavaMember() { return (Method) getMember(); } @Override public AnnotatedType<T> getDeclaringType() { throw new UnsupportedOperationException("Not supported yet."); } @Override public <T extends Annotation> T getAnnotation(final Class<T> annotationType) { throw new UnsupportedOperationException("Not supported yet."); } @Override public Set<Annotation> getAnnotations() { throw new UnsupportedOperationException("Not supported yet."); } @Override public boolean isAnnotationPresent(final Class<? extends Annotation> annotationType) { throw new UnsupportedOperationException("Not supported yet."); } @Override public String toString() { return getJavaMember().getName(); } @Override public Type getBaseType() { throw new UnsupportedOperationException("Not supported yet."); } @Override public Set<Type> getTypeClosure() { throw new UnsupportedOperationException("Not supported yet."); } }
org.b3log.latke.ioc.annotated.AnnotatedParameterImpl
import javax.enterprise.inject.spi.AnnotatedCallable; import javax.enterprise.inject.spi.AnnotatedParameter; public class AnnotatedParameterImpl<T> implements AnnotatedParameter<T> { private AnnotatedCallable<T> annotatedCallable; private Type parameter; private int position; private Set<Annotation> annotations; public AnnotatedParameterImpl(final AnnotatedCallable<T> annotatedCallable, final Type parameter, final int position, final Set<Annotation> annotations) { this.parameter = parameter; this.position = position; this.annotations = annotations; this.annotatedCallable = annotatedCallable; } @Override public int getPosition() { return position; } @Override public AnnotatedCallable<T> getDeclaringCallable() { return annotatedCallable; } @Override public Type getBaseType() { return parameter; } @Override public <T extends Annotation> T getAnnotation(final Class<T> annotationType) { return ((Class<T>) parameter).getAnnotation(annotationType); } @Override public Set<Annotation> getAnnotations() { return annotations; } @Override public boolean isAnnotationPresent(final Class<? extends Annotation> annotationType) { return ((Class<T>) parameter).isAnnotationPresent(annotationType); } @Override public String toString() { return parameter.toString() + ", position=" + position; } @Override public Set<Type> getTypeClosure() { throw new UnsupportedOperationException("Not supported yet."); } }
欢迎来到这里!
我们正在构建一个小众社区,大家在这里相互信任,以平等 • 自由 • 奔放的价值观进行分享交流。最终,希望大家能够找到与自己志同道合的伙伴,共同成长。
注册 关于