@Override public Set<String> apply(DotName name) { ClassInfo annotationClassInfo = index.getClassByName(name); ImmutableSet.Builder<String> builder = ImmutableSet.builder(); if (annotationClassInfo != null) { for (DotName annotationName : annotationClassInfo.annotations().keySet()) { builder.add(annotationName.toString()); } } else { try { Class<?> annotationClass = moduleClassLoader.loadClass(name.toString()); for (Annotation annotation : annotationClass.getDeclaredAnnotations()) { builder.add(annotation.annotationType().getName()); } } catch (ClassNotFoundException e) { WeldLogger.DEPLOYMENT_LOGGER.unableToLoadAnnotation(name.toString()); } } return builder.build(); } }
/** * @param types The initial set of types * @param annotated * @param additionalTypes Types to add to the initial set * @return the set of legal bean types */ public static Set<Type> getLegalBeanTypes(Set<Type> types, Object baseType, Type... additionalTypes) { if (additionalTypes != null && additionalTypes.length > 0) { // Micro-optimization is not possible return omitIllegalBeanTypes(types, baseType).addAll(additionalTypes).build(); } for (Type type : types) { if (Types.isIllegalBeanType(type)) { return omitIllegalBeanTypes(types, baseType).build(); } } return types; }
/** * @param types The initial set of types * @param annotated * @param additionalTypes Types to add to the initial set * @return the set of legal bean types */ public static Set<Type> getLegalBeanTypes(Set<Type> types, Object baseType, Type... additionalTypes) { if (additionalTypes != null && additionalTypes.length > 0) { // Micro-optimization is not possible return omitIllegalBeanTypes(types, baseType).addAll(additionalTypes).build(); } for (Type type : types) { if (Types.isIllegalBeanType(type)) { return omitIllegalBeanTypes(types, baseType).build(); } } return types; }
/** * @param types The initial set of types * @param annotated * @param additionalTypes Types to add to the initial set * @return the set of legal bean types */ public static Set<Type> getLegalBeanTypes(Set<Type> types, Object baseType, Type... additionalTypes) { if (additionalTypes != null && additionalTypes.length > 0) { // Micro-optimization is not possible return omitIllegalBeanTypes(types, baseType).addAll(additionalTypes).build(); } for (Type type : types) { if (Types.isIllegalBeanType(type)) { return omitIllegalBeanTypes(types, baseType).build(); } } return types; }
private Set<Annotation> initQualifiers(Set<Annotation> qualifiers) { if (qualifiers.isEmpty()) { return Bindings.DEFAULT_QUALIFIERS; } Set<Annotation> normalized = new HashSet<Annotation>(qualifiers); normalized.remove(Any.Literal.INSTANCE); normalized.remove(Default.Literal.INSTANCE); if (normalized.isEmpty()) { normalized = Bindings.DEFAULT_QUALIFIERS; } else { ImmutableSet.Builder<Annotation> builder = ImmutableSet.builder(); if (normalized.size() == 1) { if (qualifiers.iterator().next().annotationType().equals(Named.class)) { builder.add(Default.Literal.INSTANCE); } } builder.add(Any.Literal.INSTANCE); builder.addAll(qualifiers); normalized = builder.build(); } return normalized; }
private Set<Annotation> initQualifiers(Set<Annotation> qualifiers) { if (qualifiers.isEmpty()) { return Bindings.DEFAULT_QUALIFIERS; } Set<Annotation> normalized = new HashSet<Annotation>(qualifiers); normalized.remove(Any.Literal.INSTANCE); normalized.remove(Default.Literal.INSTANCE); if (normalized.isEmpty()) { normalized = Bindings.DEFAULT_QUALIFIERS; } else { ImmutableSet.Builder<Annotation> builder = ImmutableSet.builder(); if (normalized.size() == 1) { if (qualifiers.iterator().next().annotationType().equals(Named.class)) { builder.add(Default.Literal.INSTANCE); } } builder.add(Any.Literal.INSTANCE); builder.addAll(qualifiers); normalized = builder.build(); } return normalized; }
@SuppressWarnings("unchecked") public static <T> Set<T> copyOf(Iterable<? extends T> iterable) { Preconditions.checkNotNull(iterable); if (iterable instanceof AbstractImmutableSet<?>) { return (Set<T>) iterable; } if (!iterable.iterator().hasNext()) { return Collections.emptySet(); } return ImmutableSet.<T> builder().addAll(iterable).build(); }
private Set<Annotation> initQualifiers(Set<Annotation> qualifiers) { if (qualifiers.isEmpty()) { return Bindings.DEFAULT_QUALIFIERS; } Set<Annotation> normalized = new HashSet<Annotation>(qualifiers); normalized.remove(Any.Literal.INSTANCE); normalized.remove(Default.Literal.INSTANCE); if (normalized.isEmpty()) { normalized = Bindings.DEFAULT_QUALIFIERS; } else { ImmutableSet.Builder<Annotation> builder = ImmutableSet.builder(); if (normalized.size() == 1) { if (qualifiers.iterator().next().annotationType().equals(Named.class)) { builder.add(Default.Literal.INSTANCE); } } builder.add(Any.Literal.INSTANCE); builder.addAll(qualifiers); normalized = builder.build(); } return normalized; }
private Set<Annotation> initQualifiers(Set<Annotation> qualifiers) { if (qualifiers.isEmpty()) { return Bindings.DEFAULT_QUALIFIERS; } Set<Annotation> normalized = new HashSet<Annotation>(qualifiers); normalized.remove(Any.Literal.INSTANCE); normalized.remove(Default.Literal.INSTANCE); if (normalized.isEmpty()) { normalized = Bindings.DEFAULT_QUALIFIERS; } else { ImmutableSet.Builder<Annotation> builder = ImmutableSet.builder(); if (normalized.size() == 1) { if (qualifiers.iterator().next().annotationType().equals(Named.class)) { builder.add(Default.Literal.INSTANCE); } } builder.add(Any.Literal.INSTANCE); builder.addAll(qualifiers); normalized = builder.build(); } return normalized; }
private Set<Annotation> initQualifiers(Set<Annotation> qualifiers) { if (qualifiers.isEmpty()) { return Bindings.DEFAULT_QUALIFIERS; } Set<Annotation> normalized = new HashSet<Annotation>(qualifiers); normalized.remove(Any.Literal.INSTANCE); normalized.remove(Default.Literal.INSTANCE); if (normalized.isEmpty()) { normalized = Bindings.DEFAULT_QUALIFIERS; } else { ImmutableSet.Builder<Annotation> builder = ImmutableSet.builder(); if (normalized.size() == 1) { if (qualifiers.iterator().next().annotationType().equals(Named.class)) { builder.add(Default.Literal.INSTANCE); } } builder.add(Any.Literal.INSTANCE); builder.addAll(qualifiers); normalized = builder.build(); } return normalized; }
public static Set<QualifierInstance> of(Set<Annotation> qualifiers, MetaAnnotationStore store) { if (qualifiers.isEmpty()) { return Collections.emptySet(); } final ImmutableSet.Builder<QualifierInstance> ret = ImmutableSet.builder(); for (Annotation a : qualifiers) { ret.add(QualifierInstance.of(a, store)); } return ret.build(); }
@Override public Set<Entry<K, Collection<V>>> entrySet() { ImmutableSet.Builder<Entry<K, Collection<V>>> builder = ImmutableSet.builder(); for (Entry<K, C> entry : map.entrySet()) { builder.add(new MultimapEntry<K, Collection<V>>(entry.getKey(), Multimaps.unmodifiableValueCollection(entry.getValue()))); } return builder.build(); }
public static Set<QualifierInstance> of(Set<Annotation> qualifiers, MetaAnnotationStore store) { if (qualifiers.isEmpty()) { return Collections.emptySet(); } final ImmutableSet.Builder<QualifierInstance> ret = ImmutableSet.builder(); for (Annotation a : qualifiers) { ret.add(QualifierInstance.of(a, store)); } return ret.build(); }
@Override public Set<Entry<K, Collection<V>>> entrySet() { ImmutableSet.Builder<Entry<K, Collection<V>>> builder = ImmutableSet.builder(); for (Entry<K, C> entry : map.entrySet()) { builder.add(new MultimapEntry<K, Collection<V>>(entry.getKey(), Multimaps.unmodifiableValueCollection(entry.getValue()))); } return builder.build(); }