@Override public String toString() { boolean isFirst = true; StringBuilder definitionBuilder = new StringBuilder("@").append(name).append("( "); if (elements != null && elements.size() > 0) { for (Element element : elements) { if (!isFirst) { definitionBuilder.append(", "); } else { isFirst = false; } definitionBuilder.append(element.toString()); } } if (annotations != null && annotations.size() > 0) { for (Annotation annotation : annotations) { if (!isFirst) { definitionBuilder.append(", "); } else { isFirst = false; } definitionBuilder.append(annotation.toString()); } } definitionBuilder.append(")"); return definitionBuilder.toString(); }
@Override public String toString() { boolean isFirst = true; StringBuilder definitionBuilder = new StringBuilder("@").append(name).append("( "); if (elements != null && elements.size() > 0) { for (Element element : elements) { if (!isFirst) { definitionBuilder.append(", "); } else { isFirst = false; } definitionBuilder.append(element.toString()); } } if (annotations != null && annotations.size() > 0) { for (Annotation annotation : annotations) { if (!isFirst) { definitionBuilder.append(", "); } else { isFirst = false; } definitionBuilder.append(annotation.toString()); } } definitionBuilder.append(")"); return definitionBuilder.toString(); }
/** * Generates AnnotationConfig String for the given Siddhi Annotation * @param annotation Siddhi Annotation * @return String representing the Annotation */ public String generateAnnotationConfig(Annotation annotation) { StringBuilder annotationConfig = new StringBuilder(); annotationConfig.append("@"); annotationConfig.append(annotation.getName()); annotationConfig.append("("); List<String> annotationMembers = new ArrayList<>(); for (Element element : annotation.getElements()) { annotationMembers.add(element.toString()); } for (Annotation innerAnnotation : annotation.getAnnotations()) { annotationMembers.add(generateAnnotationConfig(innerAnnotation)); } annotationConfig.append(String.join(", ", annotationMembers)); annotationConfig.append(")"); preserveCodeSegment(annotation); return annotationConfig.toString(); }
/** * Generates config for a Mapper * @param mapAnnotation Siddhi annotation that contains details of a Siddhi Mapper * @return MapperConfig object * @throws DesignGenerationException Error while generating MapperConfig */ private MapperConfig generateMapperConfig(Annotation mapAnnotation) throws DesignGenerationException { String type = null; List<String> options = new ArrayList<>(); for (Element element : mapAnnotation.getElements()) { if (element.getKey().equalsIgnoreCase(TYPE)) { type = element.getValue(); } else { options.add(element.toString()); } } if (type == null) { throw new DesignGenerationException("Unable to find 'type' of the mapper"); } MapperPayloadOrAttribute payloadOrAttribute = null; if (!mapAnnotation.getAnnotations().isEmpty()) { payloadOrAttribute = generateMapperPayloadOrAttributes(mapAnnotation.getAnnotations().get(0)); } MapperConfig mapperConfig = new MapperConfig(type, options, payloadOrAttribute); preserveAndBindCodeSegment(mapAnnotation, mapperConfig); return mapperConfig; }
type = element.getValue(); } else { options.add(element.toString());