Java 8 Annotation - 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 Annotation class.

This code example shows how to use the following methods:toString
        if (isAssisted) {
            result.append("@Assisted");
            result.append(" ");
        } 
        if (bindingAnnotation != null) {
            result.append(bindingAnnotation.toString());
            result.append(" ");
        } 
        result.append(type.toString());
        return result.toString();
    } 
 
    private boolean hasAssistedAnnotation(Annotation[] annotations) {
        for (Annotation annotation : annotations) {
            if (annotation.annotationType().equals(Assisted.class)) {
                return true; 
            } 
        } 
        return false; 
    } 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:annotationType
    private static class AnnotatedWith extends AbstractMatcher<AnnotatedElement>
            implements Serializable {
        private final Annotation annotation;
 
        public AnnotatedWith(Annotation annotation) {
            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);
        } 
 
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:annotationType
        checkQualifier(qualifier, store);
        return QualifierInstance.of(qualifier, store).hashCode();
    } 
 
    private static void checkQualifier(Annotation qualifier, MetaAnnotationStore store) {
        Preconditions.checkNotNull(qualifier);
 
        QualifierModel<?> model = store.getBindingTypeModel(qualifier.annotationType());
        if (model == null || !model.isValid()) {
            throw BeanManagerLogger.LOG.invalidQualifier(qualifier);
        } 
    } 
 
    public static void validateQualifiers(Iterable<Annotation> qualifiers, BeanManager manager, Object definer,
            String nullErrorMessage) {
        if (qualifiers == null) {
            throw MetadataLogger.LOG.qualifiersNull(nullErrorMessage, definer);
        } 
        for (Annotation annotation : qualifiers) {
            if (!manager.isQualifier(annotation.annotationType())) {
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:annotationType
		} 
 
		public AnnotationDescriptor(Class<?> rootDeclaringClass, Class<?> declaringClass,
				Annotation composedAnnotation, T annotation) {
			Assert.notNull(rootDeclaringClass, "rootDeclaringClass must not be null");
			Assert.notNull(annotation, "annotation must not be null");
			this.rootDeclaringClass = rootDeclaringClass;
			this.declaringClass = declaringClass;
			this.composedAnnotation = composedAnnotation;
			this.annotation = annotation;
			this.annotationAttributes = AnnotatedElementUtils.getAnnotationAttributes(
					rootDeclaringClass, annotation.annotationType().getName());
		} 
 
		public Class<?> getRootDeclaringClass() {
			return this.rootDeclaringClass;
		} 
 
		public Class<?> getDeclaringClass() {
			return this.declaringClass;
7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:toString
        if (isAssisted) {
            result.append("@Assisted");
            result.append(" ");
        } 
        if (bindingAnnotation != null) {
            result.append(bindingAnnotation.toString());
            result.append(" ");
        } 
        result.append(type.toString());
        return result.toString();
    } 
 
    private boolean hasAssistedAnnotation(Annotation[] annotations) {
        for (Annotation annotation : annotations) {
            if (annotation.annotationType().equals(Assisted.class)) {
                return true; 
            } 
        } 
        return false; 
    } 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:hashCode, toString
  public void testEqualsHashCodeToString() { 
    Annotation actual = UniqueAnnotations.create(31);
 
    Annotation expected = getClass().getFields()[0].getAnnotations()[0];
 
    assertEquals(expected.toString(), actual.toString());
    assertEquals(expected.hashCode(), actual.hashCode());
    assertEquals(expected, actual);
  } 
} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:getClass
    public Expression createExpression(CamelContext camelContext, Annotation annotation, LanguageAnnotation languageAnnotation, Class<?> expressionReturnType) {
        String beanName = getFromAnnotation(annotation, "ref");
        String method = getFromAnnotation(annotation, "method");
 
        // ref is mandatory 
        ObjectHelper.notEmpty(beanName, "ref", annotation);
 
        // method is optional but provide it as null to the bean expression 
        if (ObjectHelper.isEmpty(method)) {
            method = null;
        } 
 
        return new BeanExpression(beanName, method);
    } 
 
    protected String getFromAnnotation(Annotation annotation, String attribute) {
        try { 
            Method method = annotation.getClass().getMethod(attribute);
            Object value = ObjectHelper.invokeMethod(method, annotation);
            if (value == null) { 

7
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:annotationType, toString
 
  public String getAnnotationName(Key<?> key) {
    Annotation annotation = key.getAnnotation();
    Class<? extends Annotation> annotationType = key.getAnnotationType();
    if (annotation != null) {
      annotationType = annotation.annotationType();
 
      String annotationString = annotation.toString();
      String canonicalName = annotationType.getName();
      String simpleName = annotationType.getSimpleName();
  
      return annotationString.replace(canonicalName, simpleName).replace("()", "");
    } else if (annotationType != null) {
      return "@" + annotationType.getSimpleName();
    } else { 
      return ""; 
    } 
  } 
 
  public String getClassName(Key<?> key) {
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:annotationType
            return "@" + annotationType.getName();
        } 
    } 
 
    static boolean isBindingAnnotation(Annotation annotation) {
        return isBindingAnnotation(annotation.annotationType());
    } 
 
    static boolean isBindingAnnotation( 
            Class<? extends Annotation> annotationType) {
        return annotationType.getAnnotation(BindingAnnotation.class) != null;
    } 
} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:annotationType
        checkWithinObserverNotification(); 
        addSyntheticAnnotation(bindingType, InterceptorBindingTypeLiteral.INSTANCE); 
    } 
 
    private <A extends Annotation> void addSyntheticAnnotation(AnnotatedType<A> annotation, Annotation requiredMetaAnnotation) {
        if (requiredMetaAnnotation != null && !annotation.isAnnotationPresent(requiredMetaAnnotation.annotationType())) {
            // Add required meta annotation 
            annotation = new AnnotatedTypeWrapper<A>(annotation, requiredMetaAnnotation);
        } 
        getBeanManager().getServices().get(ClassTransformer.class).addSyntheticAnnotation(annotation, getBeanManager().getId()); 
        getBeanManager().getServices().get(MetaAnnotationStore.class).clearAnnotationData(annotation.getJavaClass()); 
    } 
} 
6
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Java 8 Annotation Methods: