private String getParamName(AnnotationData annotationData) { if (annotationData == null) return null; final Object value = annotationData.getValues().get("value"); if (value == null) { return null; } return value.toString(); }
private String getParamDescription(AnnotationData annotationData) { if (annotationData == null) return null; final Object value = annotationData.getValues().get("description"); if (value == null) { return null; } return value.toString(); }
private Boolean getRequired(AnnotationData annotationData) { if (annotationData == null) return false; final Object value = annotationData.getValues().get("required"); if (value == null) { return false; } return value instanceof Boolean ? ((Boolean) value) : Boolean.valueOf(value.toString()); } }
public static <T> String getClassEventChannelName(ClassMeta<T> classMeta, AnnotationData classAnnotation) { //They could even use enum as we are getting a string value String classEventBusName = classAnnotation != null && classAnnotation.getValues().get("value") != null ? classAnnotation.getValues().get("value").toString() : null; if (Str.isEmpty(classEventBusName) && classAnnotation != null) { classEventBusName = classMeta.longName(); } return classEventBusName; }
static Object getRequestPath(Annotated classMeta, final String name) { final AnnotationData requestMapping = getAnnotationData(classMeta); if (requestMapping != null) { Object value = requestMapping.getValues().get("value"); if (value == null) { value = "/" + name.toLowerCase(); } return value; } else { return "/" + name.toLowerCase(); } }
static String getSummaryFromRequestMapping(Annotated annotated) { final AnnotationData requestMapping = getAnnotationData(annotated); if (requestMapping != null) { Object value = requestMapping.getValues().get("summary"); return value.toString(); } else { return "no summary"; } }
static String getDescriptionFromRequestMapping(Annotated annotated) { final AnnotationData requestMapping = getAnnotationData(annotated); if (requestMapping != null) { Object value = requestMapping.getValues().get("description"); return value.toString(); } else { return "no description"; } }
static String getReturnDescriptionFromRequestMapping(Annotated annotated) { final AnnotationData requestMapping = getAnnotationData(annotated); if (requestMapping != null) { Object value = requestMapping.getValues().get("returnDescription"); return value.toString(); } else { return "no description of return"; } }
private String getDescription(ClassMeta classMeta) { String description = ""; AnnotationData annotationData = classMeta.annotation("Description"); if (annotationData == null) { return ""; } final Map<String, Object> descriptionMap = annotationData.getValues(); if (descriptionMap != null) { if (descriptionMap.containsKey("value")) { description = descriptionMap.get("value").toString(); } } return description; }
private static String readValue(String name, Annotated annotated) { AnnotationData requestMapping = annotated.annotation(name); if (requestMapping != null) { Object value = requestMapping.getValues().get("value"); if (value instanceof String[]) { String[] values = (String[]) value; if (values.length > 0 && values[0] != null && !values[0].isEmpty()) { return values[0]; } } else { return (String) value; } } return null; }
private String getAddress(String name, Annotated annotated) { AnnotationData requestMapping = annotated.annotation(name); if (requestMapping != null) { Object value = requestMapping.getValues().get("value"); if (value instanceof String[]) { String[] values = (String[]) value; if (values.length > 0 && values[0] != null && !values[0].isEmpty()) { return values[0]; } } else { return (String) value; } } return null; }
private void extractEventListenerFromMethod(final Object listener, final MethodAccess methodAccess, final AnnotationData listen, final ServiceQueue serviceQueue) { logger.info("EventManager {} ::extractEventListenerFromMethod :: " + "{} is listening with method {} using annotation data {} ", name, serviceQueue, methodAccess.name(), listen.getValues()); final String channel = listen.getValues().get("value").toString(); if (Str.isEmpty(channel)) { return; } final boolean consume = (boolean) listen.getValues().get("consume"); if (serviceQueue == null) { extractListenerForRegularObject(listener, methodAccess, channel, consume); } else { extractListenerForService(serviceQueue, channel, consume); } }
static String getContentTypeFromRequestMapping(Annotated annotated) { final AnnotationData requestMapping = getAnnotationData(annotated); if (requestMapping != null) { Object value = requestMapping.getValues().get("contentType"); return Conversions.toString(value); } else { return "application/json"; } }
static int getCodeFromRequestMapping(Annotated annotated) { final AnnotationData requestMapping = getAnnotationData(annotated); if (requestMapping != null) { Object value = requestMapping.getValues().get("code"); return Conversions.toInt(value); } else { return -1; } }
private Object getDefaultValue(AnnotationData annotationData, TypeType paramType, Class<?> parameterType) { if (annotationData == null) return null; final Object value = annotationData.getValues().get("defaultValue"); if (value == null) { return null; } /** Support not string objects if we want to create params with stronger typed annotations. */ if (!(value instanceof String)) { return value; } if (value.equals(AnnotationConstants.NOT_SET)) { switch (paramType) { case STRING: return null; case INT: case FLOAT: case DOUBLE: case SHORT: case CHAR: return 0; case BOOLEAN: return false; default: return null; } } return Conversions.coerce(paramType, parameterType, value); }
private String getHttpMethod(@SuppressWarnings("SameParameterValue") String name, Annotated annotated) { AnnotationData requestMapping = annotated.annotation(name); if (requestMapping != null) { Object value = requestMapping.getValues().get("method"); if (value instanceof String[]) { String[] values = (String[]) value; if (values.length > 0 && values[0] != null && !values[0].isEmpty()) { return values[0]; } } if (value instanceof RequestMethod[]) { RequestMethod[] values = (RequestMethod[]) value; if (values.length > 0 && values[0] != null) { return values[0].toString(); } } else { return value.toString(); } } return null; }
public static List<RequestMethod> getRequestMethodsByAnnotated(Annotated annotated) { final AnnotationData requestMapping = getAnnotationData(annotated); if (requestMapping == null) { return Collections.singletonList(RequestMethod.GET); } final Object method = requestMapping.getValues().get("method"); if (method == null) { return Collections.singletonList(RequestMethod.GET); } if (method instanceof RequestMethod[]) { //noinspection UnnecessaryLocalVariable final List<RequestMethod> requestMethods = Arrays.asList(((RequestMethod[]) method)); return requestMethods; } if (method instanceof Object[]) { final Object[] methods = (Object[]) method; if (methods.length == 0) { return Collections.singletonList(RequestMethod.GET); } final List<RequestMethod> requestMethods = new ArrayList<>(methods.length); for (Object object : methods) { requestMethods.add(RequestMethod.valueOf(object.toString())); } return requestMethods; } return Collections.singletonList(RequestMethod.valueOf(method.toString())); }
private <T> Map<String, String> createMethodToChannelMap(final String channelPrefix, final Class<T> eventBusProxyInterface) { final Map<String, String> methodToChannelMap = new ConcurrentHashMap<>(20); final ClassMeta<T> classMeta = classMeta(eventBusProxyInterface); final AnnotationData classAnnotation = classMeta.annotation(AnnotationUtils.EVENT_CHANNEL_ANNOTATION_NAME); final String classEventBusName = AnnotationUtils.getClassEventChannelName(classMeta, classAnnotation); classMeta.methods().forEach(methodAccess -> { AnnotationData methodAnnotation = methodAccess.annotation(AnnotationUtils.EVENT_CHANNEL_ANNOTATION_NAME); String methodEventBusName = methodAnnotation != null && methodAnnotation.getValues().get("value") != null ? methodAnnotation.getValues().get("value").toString() : null; if (Str.isEmpty(methodEventBusName)) { methodEventBusName = methodAccess.name(); } final String channelName = createChannelName(channelPrefix, classEventBusName, methodEventBusName); methodToChannelMap.put(methodAccess.method().toString(), channelName); }); return methodToChannelMap; }
final String name = responseHeaderAnnotation.getValues().get("name").toString(); final String value = responseHeaderAnnotation.getValues().get("value").toString(); responseHeadersMap = new MultiMapImpl<>(); responseHeadersMap.add(name, value); responseHeadersMap = new MultiMapImpl<>(); final Object[] values = (Object[]) responseHeadersAnnotation.getValues().get("value"); AnnotationData annotationData = new AnnotationData((Annotation) object); final String name = annotationData.getValues().get("name").toString(); final String value = annotationData.getValues().get("value").toString(); responseHeadersMap.add(name, value);
final String name = responseHeaderAnnotation.getValues().get("name").toString(); final String value = responseHeaderAnnotation.getValues().get("value").toString(); responseHeadersMap = new MultiMapImpl<>(); final Object[] values = (Object[]) responseHeadersAnnotation.getValues().get("value"); AnnotationData annotationData = new AnnotationData((Annotation) object); final String name = annotationData.getValues().get("name").toString(); final String value = annotationData.getValues().get("value").toString(); responseHeadersMap.add(name, value); final Object noCache1 = getAnnotation.getValues().get("noCache"); if (Conversions.toBoolean(noCache1)) { if (responseHeadersMap.size() == 0) {