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

org.jvnet.hyperjaxb3.annotation.util.AnnotationUtils Maven / Gradle / Ivy

package org.jvnet.hyperjaxb3.annotation.util;

import java.lang.annotation.Annotation;
import java.util.Collection;

import org.jvnet.annox.model.XAnnotation;
import org.jvnet.annox.model.XAnnotationField;
import org.jvnet.annox.parser.XAnnotationFieldParser;

public class AnnotationUtils {

	@SuppressWarnings("unchecked")
	public static  XAnnotationField create(final String name,
			final T value) {
		if (value == null) {
			return null;
		} else {

			try {
				return XAnnotationFieldParser.GENERIC.construct(name, value,
						value.getClass());
			} catch (Exception ex) {
				throw new RuntimeException(ex);
			}
		}
	}

	public static  XAnnotationField create(
			final String name, final XAnnotation[] value,
			Class annotationClass) {
		if (value == null) {
			return null;
		} else {
			return new XAnnotationField.XAnnotationArray(name, value,
					annotationClass);
		}
	}

	public static  XAnnotationField create(final String name,
			final T[] value) {
		if (value == null) {
			return null;
		} else {
			try {
				return XAnnotationFieldParser.GENERIC.construct(name, value,
						value.getClass());
			} catch (Exception ex) {
				throw new RuntimeException(ex);
			}
		}
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy