2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model;
11 import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Annotation.Parameter;
13 class AnnotationSerializer {
15 static String toString(Annotation annotation) {
16 StringBuilder builder = new StringBuilder();
18 builder.append(annotation.getName());
19 if (!annotation.getParams().isEmpty()) {
21 for (Parameter param : annotation.getParams()) {
22 builder.append(param.getKey());
23 builder.append(" = ");
24 builder.append(fixString(param.getValue()));
27 builder.setCharAt(builder.length() - 2, ')');
30 return builder.toString();
33 private static String fixString(String value) {
34 // TODO replace with compress single line if possible
35 return value.replaceAll("\\r\\n|\\r|\\n", " ").replaceAll(" +", " ");