Java 8 AnnotatedElement - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 AnnotatedElement class.

This code example shows how to use the following methods:getAnnotation
        processRequiresAuthentication(controller.getClass().getAnnotation(RequiresAuthentication.class), requirements);
        processRequiresRoles(controller.getClass().getAnnotation(RequiresRoles.class), requirements);
        processRequiresPermissions(controller.getClass().getAnnotation(RequiresPermissions.class), requirements);
 
        // grab local requirements from action 
        processRequiresGuest(annotatedElement.getAnnotation(RequiresGuest.class), requirements);
        processRequiresUser(annotatedElement.getAnnotation(RequiresUser.class), requirements);
        processRequiresAuthentication(annotatedElement.getAnnotation(RequiresAuthentication.class), requirements);
        processRequiresRoles(annotatedElement.getAnnotation(RequiresRoles.class), requirements);
        processRequiresPermissions(annotatedElement.getAnnotation(RequiresPermissions.class), requirements);
 
        requirementsPerAction.put(fqActionName, new ActionRequirement(
            fqActionName,
            requirements.values().toArray(new RequirementConfiguration[requirements.size()])
        )); 
    } 
 
    private void processRequiresAuthentication(RequiresAuthentication annotation, Map<Requirement, RequirementConfiguration> requirements) {
        if (annotation == null) return;
        requirements.remove(Requirement.GUEST);
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getAnnotation
        return LOWER_CAMEL.to(LOWER_UNDERSCORE, name);
    } 
 
    public static List<ScalarImplementationHeader> fromAnnotatedElement(AnnotatedElement annotated)
    { 
        ScalarFunction scalarFunction = annotated.getAnnotation(ScalarFunction.class);
        ScalarOperator scalarOperator = annotated.getAnnotation(ScalarOperator.class);
        Description descriptionAnnotation = annotated.getAnnotation(Description.class);
 
        ImmutableList.Builder<ScalarImplementationHeader> builder = ImmutableList.builder();
 
        Optional<String> description = Optional.empty();
        if (descriptionAnnotation != null) {
            description = Optional.of(descriptionAnnotation.value());
        } 
 
        if (scalarFunction != null) {
            String baseName = scalarFunction.value().isEmpty() ? camelToSnake(annotatedName(annotated)) : scalarFunction.value();
            builder.add(new ScalarImplementationHeader(baseName, new ScalarHeader(description, scalarFunction.hidden(), scalarFunction.deterministic())));
 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getAnnotation
            this.annotation = checkNotNull(annotation, "annotation");
            checkForRuntimeRetention(annotation.annotationType());
        } 
 
        public boolean matches(AnnotatedElement element) {
            Annotation fromElement = element.getAnnotation(annotation.annotationType());
            return fromElement != null && annotation.equals(fromElement);
        } 
 
        @Override 
        public boolean equals(Object other) { 
            return other instanceof AnnotatedWith 
                    && ((AnnotatedWith) other).annotation.equals(annotation);
        } 
 
        @Override 
        public int hashCode() { 
            return 37 * annotation.hashCode();
        } 
 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getAnnotation
    @Override 
    public Object resolve(Injectee injectee, ServiceHandle<?> root) {
        AnnotatedElement parent = injectee.getParent();
        String beanName = null;
        if(parent != null) {
            Qualifier an = parent.getAnnotation(Qualifier.class);
            if(an != null) {
                beanName = an.value();
            } 
        } 
        return getBeanFromSpringContext(beanName, injectee.getRequiredType());
    } 
 
    private Object getBeanFromSpringContext(String beanName, Type beanType) {
        Class<?> bt = getClassFromType(beanType);
        if(beanName != null) {
            return ctx.getBean(beanName, bt);
        } 
        Map<String, ?> beans = ctx.getBeansOfType(bt);
        if(beans == null || beans.size() != 1) {
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:isAnnotationPresent
        assertSame(this.resourceResolver, result);
    } 
 
    @Test
    public void testResource() { 
        Object result = this.injector.getValue(this.resource, null, Resource.class, this.annotatedElement, null);
        assertNull(result); 
 
        when(annotatedElement.isAnnotationPresent(SlingObject.class)).thenReturn(true);
        result = this.injector.getValue(this.resource, null, Resource.class, this.annotatedElement, null);
        assertSame(resource, result);
    } 
 
    @Test
    public void testRequest() { 
        Object result = this.injector.getValue(this.resource, null, SlingHttpServletResponse.class,
                this.annotatedElement, null);
        assertNull(result); 
    } 
 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:isAnnotationPresent
        assertSame(this.resourceResolver, result);
    } 
 
    @Test
    public void testResource() { 
        Object result = this.injector.getValue(this.request, null, Resource.class, this.annotatedElement, null);
        assertNull(result); 
 
        when(annotatedElement.isAnnotationPresent(SlingObject.class)).thenReturn(true);
        result = this.injector.getValue(this.request, null, Resource.class, this.annotatedElement, null);
        assertSame(resource, result);
    } 
 
    @Test
    public void testRequest() { 
        Object result = this.injector.getValue(this.request, null, SlingHttpServletRequest.class,
                this.annotatedElement, null);
        assertSame(this.request, result);
 
        result = this.injector.getValue(this.request, null, HttpServletRequest.class, this.annotatedElement, null);
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getAnnotation
        return (methodLevel != null) ? methodLevel : classLevel;
    } 
 
    private Annotation getAuthAnnotation(AnnotatedElement element) {
        Annotation ann = null;
        ann = element.getAnnotation(DenyAll.class);
        if (ann == null) {
            ann = element.getAnnotation(RolesAllowed.class);
        } 
        if (ann == null) {
            ann = element.getAnnotation(PermitAll.class);
        } 
        return ann;
    } 
 
    /** 
     * A class is secured if either the class or one of its methods is secured. 
     * An AnnotatedElement is secured if @RolesAllowed or @DenyAll is present. 
     *  
     * @param clazz 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getAnnotation
	 * Return the method/constructor annotation of the given type, if available. 
	 * @param annotationType the annotation type to look for 
	 * @return the annotation object, or {@code null} if not found 
	 */ 
	public <T extends Annotation> T getMethodAnnotation(Class<T> annotationType) {
		return getAnnotatedElement().getAnnotation(annotationType);
	} 
 
	/** 
	 * Return the annotations associated with the specific method/constructor parameter. 
	 */ 
	public Annotation[] getParameterAnnotations() {
		if (this.parameterAnnotations == null) {
			Annotation[][] annotationArray = (this.method != null ?
					this.method.getParameterAnnotations() : this.constructor.getParameterAnnotations());
			if (this.parameterIndex >= 0 && this.parameterIndex < annotationArray.length) {
				this.parameterAnnotations = annotationArray[this.parameterIndex];
			} 
			else { 
				this.parameterAnnotations = new Annotation[0];
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getAnnotation, isAnnotationPresent
 
	@Override 
	public FieldBridge provideFieldBridge(ExtendedBridgeProviderContext context) {
		FieldBridge bridge = null;
		AnnotatedElement annotatedElement = context.getAnnotatedElement();
		if ( annotatedElement.isAnnotationPresent( Spatial.class ) ) {
			Spatial spatialAnn = annotatedElement.getAnnotation( Spatial.class );
			try { 
				bridge = buildSpatialBridge( spatialAnn, null, null );
			} 
			catch (Exception e) {
				throw LOG.unableToInstantiateSpatial( context.getMemberName(), e );
			} 
			if ( bridge == null ) {
				throw LOG.unableToInstantiateSpatial( context.getMemberName(), null );
			} 
		} 
		return bridge;
	} 
 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:isAnnotationPresent
      return null; 
    } 
  } 
 
  private static boolean isGUITest(@Nonnull AnnotatedElement annotatedElement) {
    return annotatedElement.isAnnotationPresent(GUITest.class);
  } 
 
  private GUITestFinder() {} 
} 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Java 8 AnnotatedElement Methods: