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.api.JmxAttribute;
13 public class ModuleFieldSerializer {
16 public static String toString(ModuleField moduleField) {
17 StringBuilder builder = new StringBuilder();
19 builder.append("public static final ");
20 builder.append(JmxAttribute.class.getCanonicalName());
22 builder.append(moduleField.getName());
23 builder.append("JmxAttribute = new ");
24 builder.append(JmxAttribute.class.getCanonicalName());
25 builder.append("(\"");
26 builder.append(moduleField.getAttributeName());
27 builder.append("\");");
30 builder.append(" private ");
31 moduleField.getModifiers().forEach(mod -> builder.append(mod).append(" "));
32 builder.append(moduleField.getType()).append(" ");
33 builder.append(moduleField.getName());
34 if (moduleField.getNullableDefault() != null) {
35 builder.append(" = ").append(moduleField.getNullableDefault());
39 if (moduleField.isDependent()) {
40 String comment = moduleField.getDependency().isMandatory() ? "mandatory"
42 builder.append(" // ").append(comment);
48 return builder.toString();