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

com.g2forge.alexandria.java.annotation.SimpleAnnotatedElement Maven / Gradle / Ivy

There is a newer version: 0.0.18
Show newest version
package com.g2forge.alexandria.java.annotation;

import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
import java.util.Arrays;

import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
public class SimpleAnnotatedElement implements AnnotatedElement {
	protected final Annotation[] annotations;

	@SuppressWarnings("unchecked")
	@Override
	public  T getAnnotation(Class annotationClass) {
		for (Annotation element : annotations) {
			if (annotationClass.isInstance(element)) return (T) element;
		}
		return null;
	}

	@Override
	public Annotation[] getAnnotations() {
		return Arrays.copyOf(annotations, annotations.length);
	}

	@Override
	public Annotation[] getDeclaredAnnotations() {
		return getAnnotations();
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy