java.lang.Package.getAnnotations()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(113)

本文整理了Java中java.lang.Package.getAnnotations()方法的一些代码示例,展示了Package.getAnnotations()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Package.getAnnotations()方法的具体详情如下:
包路径:java.lang.Package
类名称:Package
方法名:getAnnotations

Package.getAnnotations介绍

[英]Returns an array of this package's annotations.
[中]返回此包的注释数组。

代码示例

代码示例来源:origin: robovm/robovm

/**
 * Returns an array of this package's declared annotations. Package annotations aren't
 * inherited, so this is equivalent to {@link #getAnnotations}.
 */
public Annotation[] getDeclaredAnnotations() {
  return getAnnotations();
}

代码示例来源:origin: robovm/robovm

/**
 * Returns the annotation associated with the specified annotation type and
 * this package, if present.
 *
 * @param annotationType
 *            the annotation type to look for.
 * @return an instance of {@link Annotation} or {@code null}.
 * @see java.lang.reflect.AnnotatedElement#getAnnotation(java.lang.Class)
 */
@SuppressWarnings("unchecked")
public <A extends Annotation> A getAnnotation(Class<A> annotationType) {
  for (Annotation annotation : getAnnotations()) {
    if (annotationType.isInstance(annotation)) {
      return (A) annotation;
    }
  }
  return null;
}

代码示例来源:origin: org.codehaus.groovy/groovy

setAnnotationMetaData(classNode.getTypeClass().getPackage().getAnnotations(), packageNode);

代码示例来源:origin: com.bugvm/bugvm-rt

/**
 * Returns an array of this package's declared annotations. Package annotations aren't
 * inherited, so this is equivalent to {@link #getAnnotations}.
 */
public Annotation[] getDeclaredAnnotations() {
  return getAnnotations();
}

代码示例来源:origin: MobiVM/robovm

/**
 * Returns an array of this package's declared annotations. Package annotations aren't
 * inherited, so this is equivalent to {@link #getAnnotations}.
 */
public Annotation[] getDeclaredAnnotations() {
  return getAnnotations();
}

代码示例来源:origin: ibinti/bugvm

/**
 * Returns an array of this package's declared annotations. Package annotations aren't
 * inherited, so this is equivalent to {@link #getAnnotations}.
 */
public Annotation[] getDeclaredAnnotations() {
  return getAnnotations();
}

代码示例来源:origin: org.apache.cxf/cxf-rt-frontend-jaxws

av0.visitEnd();
if (clz.getPackage() != null && clz.getPackage().getAnnotations() != null) {
  for (Annotation ann : clz.getPackage().getAnnotations()) {
    if (ann instanceof XmlJavaTypeAdapters) {
      av0 = cw.visitAnnotation("Ljavax/xml/bind/annotation/adapters/XmlJavaTypeAdapters;", true);

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

/**
 * Returns an array of this package's declared annotations. Package annotations aren't
 * inherited, so this is equivalent to {@link #getAnnotations}.
 */
public Annotation[] getDeclaredAnnotations() {
  return getAnnotations();
}

代码示例来源:origin: com.gluonhq/robovm-rt

/**
 * Returns an array of this package's declared annotations. Package annotations aren't
 * inherited, so this is equivalent to {@link #getAnnotations}.
 */
public Annotation[] getDeclaredAnnotations() {
  return getAnnotations();
}

代码示例来源:origin: FlexoVM/flexovm

/**
 * Returns an array of this package's declared annotations. Package annotations aren't
 * inherited, so this is equivalent to {@link #getAnnotations}.
 */
public Annotation[] getDeclaredAnnotations() {
  return getAnnotations();
}

代码示例来源:origin: stackoverflow.com

import java.lang.annotation.Annotation;

public class PackageAnnotationsTest {

  public static void main(String[] args) {
    Package myPackage = AClassInMyPackage.class.getPackage();
    Annotation[] myPackageAnnotations = myPackage.getAnnotations();
    System.out.println("Available annotations for package : " + myPackage.getName());
    for(Annotation a : myPackageAnnotations) {
      System.out.println("\t * " + a.annotationType());
    }
  }
}

代码示例来源:origin: codecentric/cxf-spring-boot-starter

public static <T> String getNamespaceUriFromJaxbClass(Class<T> jaxbClass) throws BootStarterCxfException {
  for(Annotation annotation: jaxbClass.getPackage().getAnnotations()){
    if(annotation.annotationType() == XmlSchema.class){
      return ((XmlSchema)annotation).namespace();
    }
  }
  throw new BootStarterCxfException("namespaceUri not found -> Is it really a JAXB-Class, thats used to call the method?");
}

代码示例来源:origin: jonashackt/soap-spring-boot-cxf

public static <T> String getNamespaceUriFromJaxbClass(Class<T> jaxbClass) throws BusinessException {
  for(Annotation annotation: jaxbClass.getPackage().getAnnotations()){
    if(annotation.annotationType() == XmlSchema.class){
      return ((XmlSchema)annotation).namespace();
    }
  }
  throw new BusinessException("namespaceUri not found -> Is it really a JAXB-Class, thats used to call the method?");
}

代码示例来源:origin: org.wicketstuff/wicket-ki-security

public <T extends Component> KiSecurityConstraint checkInvalidInstantiation( final Class<T> componentClass )
{
 KiSecurityConstraint fail = checkInvalidInstantiation( componentClass.getAnnotations(), KiAction.INSTANTIATE );
 if( fail == null ) {
  fail = checkInvalidInstantiation( componentClass.getPackage().getAnnotations(), KiAction.INSTANTIATE );
 }
 return fail;
}

代码示例来源:origin: org.wicketstuff/wicket-shiro

public <T extends Component> ShiroSecurityConstraint checkInvalidInstantiation(
  final Class<T> componentClass)
{
  ShiroSecurityConstraint fail = checkInvalidInstantiation(componentClass.getAnnotations(),
    ShiroAction.INSTANTIATE);
  if (fail == null)
    fail = checkInvalidInstantiation(componentClass.getPackage().getAnnotations(),
      ShiroAction.INSTANTIATE);
  return fail;
}

代码示例来源:origin: jonashackt/tutorial-soap-spring-boot-cxf

public static <T> String getNamespaceUriFromJaxbClass(Class<T> jaxbClass) throws InternalBusinessException {
  for(Annotation annotation: jaxbClass.getPackage().getAnnotations()){
    if(annotation.annotationType() == XmlSchema.class){
      return ((XmlSchema)annotation).namespace();
    }
  }
  throw new InternalBusinessException("namespaceUri not found -> Is it really a JAXB-Class, thats used to call the method?");
}

代码示例来源:origin: org.wicketstuff/wicket-ki-security

public boolean isActionAuthorized(final Component component, final Action action) {
 
 KiAction _action = (action.getName().equals( Action.RENDER ) ) 
  ? KiAction.RENDER : KiAction.ENABLE;
 
 Class<? extends Component> clazz = component.getClass();
 KiSecurityConstraint fail = checkInvalidInstantiation( clazz.getAnnotations(), _action );
 if( fail == null ) {
  fail = checkInvalidInstantiation( clazz.getPackage().getAnnotations(), _action );
 }
 return fail == null;
}

代码示例来源:origin: org.wicketstuff/wicket-shiro

/**
 * {@inheritDoc}
 */
public boolean isActionAuthorized(final Component component, final Action action)
{
  final ShiroAction _action = action.getName().equals(Action.RENDER) ? ShiroAction.RENDER
    : ShiroAction.ENABLE;
  final Class<? extends Component> clazz = component.getClass();
  ShiroSecurityConstraint fail = checkInvalidInstantiation(clazz.getAnnotations(), _action);
  if (fail == null)
    fail = checkInvalidInstantiation(clazz.getPackage().getAnnotations(), _action);
  return fail == null;
}

代码示例来源:origin: org.apache.johnzon/johnzon-mapper

public static <T extends Annotation> T getAnnotation(final Package pck, final Class<T> api) {
  final T annotation = pck.getAnnotation(api);
  if (annotation != null) {
    return annotation;
  }
  return findMeta(pck.getAnnotations(), api);
}

代码示例来源:origin: apache/johnzon

public static <T extends Annotation> T getAnnotation(final Package pck, final Class<T> api) {
  final T annotation = pck.getAnnotation(api);
  if (annotation != null) {
    return annotation;
  }
  return findMeta(pck.getAnnotations(), api);
}

相关文章