Here you can find the source of getAnnotationDeep(Annotation from, Class extends Annotation> toFind)
Parameter | Description |
---|---|
from | the annotation to search from. |
toFind | the annotation to find. |
public static Annotation getAnnotationDeep(Annotation from, Class<? extends Annotation> toFind)
//package com.java2s; /**/*from w w w .jav a2 s .co m*/ * Copyright (c) 2013-2015 by The SeedStack authors. All rights reserved. * * This file is part of SeedStack, An enterprise-oriented full development stack. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ import java.lang.annotation.Annotation; public class Main { public static final String JAVA_LANG = "java.lang"; /** * This method is looking for the annotation class toFind from the annoFrom * annotation instance. It will reach recursively until the annotation is * found. * * @param from the annotation to search from. * @param toFind the annotation to find. * @return the found annotation or null if nothing found. */ public static Annotation getAnnotationDeep(Annotation from, Class<? extends Annotation> toFind) { if (from.annotationType().equals(toFind)) { return from; } else { for (Annotation anno : from.annotationType().getAnnotations()) { if (!anno.annotationType().getPackage().getName().startsWith(JAVA_LANG)) { return getAnnotationDeep(anno, toFind); } } } return null; } }