/** * Gets a list of {@link AnnotationValue} for the given member. * * @param member The member * @param type The type * @param <T> The type * @throws IllegalStateException If no member is available that conforms to the given name and type * @return The result */ public @Nonnull final <T extends Annotation> List<AnnotationValue<T>> getAnnotations(String member, Class<T> type) { AnnotationValue[] values = get(member, AnnotationValue[].class).orElse(null); if (ArrayUtils.isNotEmpty(values)) { List<AnnotationValue<T>> list = new ArrayList<>(values.length); String typeName = type.getName(); for (AnnotationValue value : values) { if (value == null) { continue; } if (value.getAnnotationName().equals(typeName)) { //noinspection unchecked list.add(value); } } return list; } return Collections.emptyList(); }
private void addRepeatableInternal(String annotationName, String member, io.micronaut.core.annotation.AnnotationValue annotationValue, Map<String, Map<CharSequence, Object>> allAnnotations) { if (repeated == null) { repeated = new HashMap<>(2); } repeated.put(annotationName, annotationValue.getAnnotationName()); Map<CharSequence, Object> values = allAnnotations.computeIfAbsent(annotationName, s -> new HashMap<>()); Object v = values.get(member); if (v != null) { if (v.getClass().isArray()) { Object[] array = (Object[]) v; List newValues = new ArrayList(array.length + 1); newValues.addAll(Arrays.asList(array)); newValues.add(annotationValue); values.put(member, newValues); } else if (v instanceof Collection) { ((Collection) v).add(annotationValue); } } else { ArrayList<Object> newValues = new ArrayList<>(2); newValues.add(annotationValue); values.put(member, newValues); } }
private void addRepeatableInternal(String annotationName, String member, io.micronaut.core.annotation.AnnotationValue annotationValue, Map<String, Map<CharSequence, Object>> allAnnotations) { if (repeated == null) { repeated = new HashMap<>(2); } repeated.put(annotationName, annotationValue.getAnnotationName()); Map<CharSequence, Object> values = allAnnotations.computeIfAbsent(annotationName, s -> new HashMap<>()); Object v = values.get(member); if (v != null) { if (v.getClass().isArray()) { Object[] array = (Object[]) v; List newValues = new ArrayList(array.length + 1); newValues.addAll(Arrays.asList(array)); newValues.add(annotationValue); values.put(member, newValues); } else if (v instanceof Collection) { ((Collection) v).add(annotationValue); } } else { ArrayList<Object> newValues = new ArrayList<>(2); newValues.add(annotationValue); values.put(member, newValues); } }
/** * Default constructor. * * @param environment The environment * @param target The target */ EnvironmentAnnotationValue(Environment environment, AnnotationValue<A> target) { super(target, AnnotationMetadataSupport.getDefaultValues(target.getAnnotationName()), EnvironmentConvertibleValuesMap.of( environment, target.getValues() )); }
/** * Default constructor. * * @param environment The environment * @param target The target */ EnvironmentAnnotationValue(Environment environment, AnnotationValue<A> target) { super(target, AnnotationMetadataSupport.getDefaultValues(target.getAnnotationName()), EnvironmentConvertibleValuesMap.of( environment, target.getValues() )); }
if (o instanceof AnnotationValue) { AnnotationValue av = (AnnotationValue) o; String mappedAnnotationName = av.getAnnotationName();
if (o instanceof AnnotationValue) { AnnotationValue av = (AnnotationValue) o; String mappedAnnotationName = av.getAnnotationName();
} else if (value instanceof io.micronaut.core.annotation.AnnotationValue) { io.micronaut.core.annotation.AnnotationValue data = (io.micronaut.core.annotation.AnnotationValue) value; String annotationName = data.getAnnotationName(); Map<CharSequence, Object> values = data.getValues(); Type annotationValueType = Type.getType(io.micronaut.core.annotation.AnnotationValue.class);
} else if (value instanceof io.micronaut.core.annotation.AnnotationValue) { io.micronaut.core.annotation.AnnotationValue data = (io.micronaut.core.annotation.AnnotationValue) value; String annotationName = data.getAnnotationName(); Map<CharSequence, Object> values = data.getValues(); Type annotationValueType = Type.getType(io.micronaut.core.annotation.AnnotationValue.class);