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
8 package org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl;
10 import com.google.common.base.Function;
11 import com.google.common.base.Preconditions;
12 import com.google.common.collect.Collections2;
13 import com.google.common.collect.Lists;
14 import com.google.common.collect.Maps;
15 import org.opendaylight.controller.config.api.RuntimeBeanRegistratorAwareModule;
16 import org.opendaylight.controller.config.api.annotations.AbstractServiceInterface;
17 import org.opendaylight.controller.config.api.runtime.RuntimeBean;
18 import org.opendaylight.controller.config.spi.Module;
19 import org.opendaylight.controller.config.yangjmxgenerator.AbstractEntry;
20 import org.opendaylight.controller.config.yangjmxgenerator.ModuleMXBeanEntry;
21 import org.opendaylight.controller.config.yangjmxgenerator.RuntimeBeanEntry;
22 import org.opendaylight.controller.config.yangjmxgenerator.RuntimeBeanEntry.Rpc;
23 import org.opendaylight.controller.config.yangjmxgenerator.ServiceInterfaceEntry;
24 import org.opendaylight.controller.config.yangjmxgenerator.attribute.AbstractDependencyAttribute;
25 import org.opendaylight.controller.config.yangjmxgenerator.attribute.AttributeIfc;
26 import org.opendaylight.controller.config.yangjmxgenerator.attribute.Dependency;
27 import org.opendaylight.controller.config.yangjmxgenerator.attribute.JavaAttribute;
28 import org.opendaylight.controller.config.yangjmxgenerator.attribute.ListAttribute;
29 import org.opendaylight.controller.config.yangjmxgenerator.attribute.ListDependenciesAttribute;
30 import org.opendaylight.controller.config.yangjmxgenerator.attribute.TOAttribute;
31 import org.opendaylight.controller.config.yangjmxgenerator.attribute.TypedAttribute;
32 import org.opendaylight.controller.config.yangjmxgenerator.attribute.VoidAttribute;
33 import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Annotation;
34 import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Annotation.Parameter;
35 import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Constructor;
36 import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Field;
37 import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Header;
38 import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.MethodDeclaration;
39 import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.MethodDefinition;
40 import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.ModuleField;
41 import org.opendaylight.controller.config.yangjmxgenerator.plugin.util.FullyQualifiedNameHelper;
42 import org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil;
43 import org.opendaylight.yangtools.sal.binding.model.api.ParameterizedType;
44 import org.opendaylight.yangtools.sal.binding.model.api.Type;
46 import javax.management.openmbean.SimpleType;
47 import java.util.ArrayList;
48 import java.util.Arrays;
49 import java.util.Collection;
50 import java.util.Collections;
51 import java.util.HashMap;
52 import java.util.List;
54 import java.util.Map.Entry;
56 public class TemplateFactory {
58 public static Map<String, FtlTemplate> getFtlTemplates(
59 ModuleMXBeanEntry entry) {
60 Map<String, FtlTemplate> result = new HashMap<>();
62 result.putAll(TemplateFactory.tOsFromMbe(entry));
65 result.put(entry.getMXBeanInterfaceName() + ".java",
66 TemplateFactory.mXBeanInterfaceTemplateFromMbe(entry));
69 result.put(entry.getAbstractFactoryName() + ".java",
70 TemplateFactory.abstractFactoryTemplateFromMbe(entry));
73 result.put(entry.getAbstractModuleName() + ".java",
74 TemplateFactory.abstractModuleTemplateFromMbe(entry));
79 public static Map<String, FtlTemplate> getFtlStubTemplates(
80 ModuleMXBeanEntry entry) {
81 Map<String, FtlTemplate> result = new HashMap<>();
83 result.put(entry.getStubFactoryName() + ".java",
84 TemplateFactory.stubFactoryTemplateFromMbe(entry));
86 result.put(entry.getStubModuleName() + ".java",
87 TemplateFactory.stubModuleTemplateFromMbe(entry));
91 public static Map<String, FtlTemplate> getFtlTemplates(
92 ServiceInterfaceEntry entry) {
94 Map<String, FtlTemplate> result = new HashMap<>();
95 result.put(entry.getTypeName() + ".java",
96 TemplateFactory.serviceInterfaceFromSie(entry));
102 * Get map of file name as key, FtlFile instance representing runtime mx
103 * bean as value that should be persisted from this instance.
105 public static Map<String, FtlTemplate> getTOAndMXInterfaceFtlFiles(
106 RuntimeBeanEntry entry) {
107 Map<String, FtlTemplate> result = new HashMap<>();
108 { // create GeneralInterfaceFtlFile for runtime MXBean. Attributes will
109 // be transformed to getter methods
110 String mxBeanTypeName = entry.getJavaNameOfRuntimeMXBean();
111 List<String> extendedInterfaces = Arrays.asList(RuntimeBean.class
112 .getCanonicalName());
113 List<MethodDeclaration> methods = new ArrayList<>();
115 // convert attributes to getters
116 for (AttributeIfc attributeIfc : entry.getAttributes()) {
118 returnType = getReturnType(attributeIfc);
119 String getterName = "get"
120 + attributeIfc.getUpperCaseCammelCase();
121 MethodDeclaration getter = new MethodDeclaration(returnType,
122 getterName, Collections.<Field> emptyList());
127 for (Rpc rpc : entry.getRpcs()) {
128 // convert JavaAttribute parameters into fields
129 List<Field> fields = new ArrayList<>();
130 for (JavaAttribute ja : rpc.getParameters()) {
131 Field field = new Field(Collections.<String> emptyList(),
132 ja.getType().getFullyQualifiedName(),
133 ja.getLowerCaseCammelCase(), ja.getNullableDefaultWrappedForCode());
136 MethodDeclaration operation = new MethodDeclaration(
137 getReturnType(rpc.getReturnType()), rpc.getName(), fields);
138 methods.add(operation);
142 GeneralInterfaceTemplate runtimeMxBeanIfc = new GeneralInterfaceTemplate(
143 null, entry.getPackageName(), mxBeanTypeName,
144 extendedInterfaces, methods);
146 result.put(runtimeMxBeanIfc.getTypeDeclaration().getName()
147 + ".java", runtimeMxBeanIfc);
150 result.putAll(TemplateFactory.tOsFromRbe(entry));
155 // FIXME: put into Type.toString
156 static String serializeType(Type type) {
157 if (type instanceof ParameterizedType){
158 ParameterizedType parameterizedType = (ParameterizedType) type;
159 StringBuffer sb = new StringBuffer();
160 sb.append(parameterizedType.getRawType().getFullyQualifiedName());
162 boolean first = true;
163 for(Type parameter: parameterizedType.getActualTypeArguments()) {
169 sb.append(serializeType(parameter));
172 return sb.toString();
174 return type.getFullyQualifiedName();
179 private static String getReturnType(AttributeIfc attributeIfc) {
181 if (attributeIfc instanceof TypedAttribute) {
182 Type type = ((TypedAttribute) attributeIfc).getType();
183 returnType = serializeType(type);
184 } else if (attributeIfc == VoidAttribute.getInstance()) {
187 throw new UnsupportedOperationException(
188 "Attribute not supported: "
189 + attributeIfc.getClass());
194 public static GeneralInterfaceTemplate serviceInterfaceFromSie(
195 ServiceInterfaceEntry sie) {
197 List<String> extendedInterfaces = Lists
198 .newArrayList(AbstractServiceInterface.class.getCanonicalName());
199 if (sie.getBase().isPresent()) {
200 extendedInterfaces.add(sie.getBase().get().getFullyQualifiedName());
204 GeneralInterfaceTemplate sieTemplate = new GeneralInterfaceTemplate(
205 getHeaderFromEntry(sie), sie.getPackageName(),
206 sie.getTypeName(), extendedInterfaces,
207 Lists.<MethodDeclaration> newArrayList());
208 sieTemplate.setJavadoc(sie.getNullableDescription());
210 if (sie.getNullableDescription() != null)
211 sieTemplate.getAnnotations().add(
212 Annotation.createDescriptionAnnotation(sie
213 .getNullableDescription()));
214 sieTemplate.getAnnotations().addAll(Annotation.createSieAnnotations(sie));
219 public static AbstractFactoryTemplate abstractFactoryTemplateFromMbe(
220 ModuleMXBeanEntry mbe) {
221 AbstractFactoryAttributesProcessor attrProcessor = new AbstractFactoryAttributesProcessor();
222 attrProcessor.processAttributes(mbe.getAttributes(),
223 mbe.getPackageName());
225 Collection<String> transformed = Collections2.transform(mbe
226 .getProvidedServices().keySet(),
227 new Function<String, String>() {
230 public String apply(String input) {
231 return input + ".class";
235 return new AbstractFactoryTemplate(getHeaderFromEntry(mbe),
236 mbe.getPackageName(), mbe.getAbstractFactoryName(),
237 mbe.getGloballyUniqueName(), mbe.getFullyQualifiedName(mbe
238 .getStubModuleName()), attrProcessor.getFields(),
239 Lists.newArrayList(transformed), mbe);
242 public static AbstractModuleTemplate abstractModuleTemplateFromMbe(
243 ModuleMXBeanEntry mbe) {
244 AbstractModuleAttributesProcessor attrProcessor = new AbstractModuleAttributesProcessor();
245 attrProcessor.processAttributes(mbe.getAttributes(),
246 mbe.getPackageName());
248 List<ModuleField> moduleFields = attrProcessor.getModuleFields();
249 List<String> implementedIfcs = Lists.newArrayList(
250 Module.class.getCanonicalName(),
251 mbe.getFullyQualifiedName(mbe.getMXBeanInterfaceName()));
253 for (String implementedService : mbe.getProvidedServices().keySet()) {
254 implementedIfcs.add(implementedService);
257 boolean generateRuntime = false;
258 String registratorFullyQualifiedName = null;
259 if (mbe.getRuntimeBeans() != null
260 && mbe.getRuntimeBeans().isEmpty() == false) {
261 generateRuntime = true;
262 RuntimeBeanEntry rootEntry = RuntimeRegistratorFtlTemplate
263 .findRoot(mbe.getRuntimeBeans());
264 registratorFullyQualifiedName = rootEntry
267 .concat(RuntimeRegistratorFtlTemplate.getJavaNameOfRuntimeRegistrator(rootEntry));
268 implementedIfcs.add(RuntimeBeanRegistratorAwareModule.class
269 .getCanonicalName());
272 AbstractModuleTemplate abstractModuleTemplate = new AbstractModuleTemplate(
273 getHeaderFromEntry(mbe), mbe.getPackageName(),
274 mbe.getAbstractModuleName(), implementedIfcs, moduleFields,
275 attrProcessor.getMethods(), generateRuntime,
276 registratorFullyQualifiedName);
278 if (mbe.getNullableDescription() != null)
279 abstractModuleTemplate.getAnnotations().add(
280 Annotation.createDescriptionAnnotation(mbe
281 .getNullableDescription()));
282 return abstractModuleTemplate;
285 public static StubFactoryTemplate stubFactoryTemplateFromMbe(
286 ModuleMXBeanEntry mbe) {
287 return new StubFactoryTemplate(getHeaderFromEntry(mbe),
288 mbe.getPackageName(), mbe.getStubFactoryName(),
289 mbe.getFullyQualifiedName(mbe.getAbstractFactoryName()),
290 mbe.getStubModuleName());
293 public static StubModuleTemplate stubModuleTemplateFromMbe(
294 ModuleMXBeanEntry mbe) {
295 return new StubModuleTemplate(getHeaderFromEntry(mbe),
296 mbe.getPackageName(), mbe.getStubModuleName(),
297 mbe.getFullyQualifiedName(mbe.getAbstractModuleName()));
300 public static GeneralInterfaceTemplate mXBeanInterfaceTemplateFromMbe(
301 ModuleMXBeanEntry mbe) {
302 MXBeanInterfaceAttributesProcessor attrProcessor = new MXBeanInterfaceAttributesProcessor();
303 attrProcessor.processAttributes(mbe.getAttributes());
304 GeneralInterfaceTemplate ifcTemplate = new GeneralInterfaceTemplate(
305 getHeaderFromEntry(mbe), mbe.getPackageName(),
306 mbe.getMXBeanInterfaceName(), Lists.<String> newArrayList(),
307 attrProcessor.getMethods());
308 ifcTemplate.setJavadoc(mbe.getNullableDescription());
312 public static Map<String, GeneralClassTemplate> tOsFromMbe(
313 ModuleMXBeanEntry mbe) {
314 Map<String, GeneralClassTemplate> retVal = Maps.newHashMap();
315 TOAttributesProcessor processor = new TOAttributesProcessor();
316 processor.processAttributes(mbe.getAttributes());
317 for (org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.TemplateFactory.TOAttributesProcessor.TOInternal to : processor
319 List<Constructor> constructors = Lists.newArrayList();
320 constructors.add(new Constructor(to.getName(), "super();"));
322 Header header = getHeaderFromEntry(mbe);
325 new GeneralClassTemplate(header, mbe.getPackageName(), to
326 .getName(), Collections.<String> emptyList(),
327 Collections.<String> emptyList(), to.getFields(),
328 to.getMethods(), false, false, constructors));
333 public static Map<String, GeneralClassTemplate> tOsFromRbe(
334 RuntimeBeanEntry rbe) {
335 Map<String, GeneralClassTemplate> retVal = Maps.newHashMap();
336 TOAttributesProcessor processor = new TOAttributesProcessor();
337 Map<String, AttributeIfc> yangPropertiesToTypesMap = Maps.newHashMap(rbe.getYangPropertiesToTypesMap());
339 // Add TOs from output parameters
340 for (Rpc rpc : rbe.getRpcs()) {
341 AttributeIfc returnType = rpc.getReturnType();
343 if (returnType == VoidAttribute.getInstance())
345 if (returnType instanceof JavaAttribute)
347 if (returnType instanceof ListAttribute && returnType.getOpenType() instanceof SimpleType)
350 Preconditions.checkState(yangPropertiesToTypesMap.containsKey(returnType.getAttributeYangName()) == false,
351 "Duplicate TO %s for %s", returnType.getAttributeYangName(), rbe);
352 yangPropertiesToTypesMap.put(returnType.getAttributeYangName(), returnType);
355 processor.processAttributes(yangPropertiesToTypesMap);
356 for (org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.TemplateFactory.TOAttributesProcessor.TOInternal to : processor
358 List<Constructor> constructors = Lists.newArrayList();
359 constructors.add(new Constructor(to.getName(), "super();"));
364 new GeneralClassTemplate(null, rbe.getPackageName(), to
365 .getName(), Collections.<String> emptyList(),
366 Collections.<String> emptyList(), to.getFields(),
367 to.getMethods(), false, false, constructors));
372 private static Header getHeaderFromEntry(AbstractEntry mbe) {
373 return new Header(mbe.getYangModuleName(), mbe.getYangModuleLocalname());
376 // TODO refactor attribute processors
378 private static class TOAttributesProcessor {
380 private final List<TOInternal> tos = Lists.newArrayList();
382 void processAttributes(Map<String, AttributeIfc> attributes) {
383 for (Entry<String, AttributeIfc> attrEntry : attributes.entrySet()) {
384 AttributeIfc attributeIfc = attrEntry.getValue();
385 if (attributeIfc instanceof TOAttribute) {
386 createTOInternal((TOAttribute) attributeIfc);
388 if (attributeIfc instanceof ListAttribute) {
389 AttributeIfc innerAttr = ((ListAttribute) attributeIfc)
390 .getInnerAttribute();
391 if (innerAttr instanceof TOAttribute) {
392 createTOInternal((TOAttribute) innerAttr);
398 private void createTOInternal(TOAttribute toAttribute) {
400 Map<String, AttributeIfc> attrs = toAttribute.getCapitalizedPropertiesToTypesMap();
401 // recursive processing of TO's attributes
402 processAttributes(attrs);
404 tos.add(new TOInternal(toAttribute.getType(), attrs));
407 List<TOInternal> getTOs() {
411 private static class TOInternal {
412 private final String fullyQualifiedName, name;
413 private List<Field> fields;
414 private List<MethodDefinition> methods;
416 public TOInternal(Type type, Map<String, AttributeIfc> attrs) {
417 this(type.getFullyQualifiedName(), type.getName(), attrs, type.getPackageName());
420 public TOInternal(String fullyQualifiedName, String name,
421 Map<String, AttributeIfc> attrs, String packageName) {
422 this.fullyQualifiedName = fullyQualifiedName;
424 processAttrs(attrs, packageName);
427 private void processAttrs(Map<String, AttributeIfc> attrs, String packageName) {
428 fields = Lists.newArrayList();
429 methods = Lists.newArrayList();
431 for (Entry<String, AttributeIfc> attrEntry : attrs.entrySet()) {
432 String innerName = attrEntry.getKey();
433 String varName = BindingGeneratorUtil
434 .parseToValidParamName(attrEntry.getKey());
436 String fullyQualifiedName, nullableDefault = null;
437 if (attrEntry.getValue() instanceof TypedAttribute) {
438 Type type = ((TypedAttribute) attrEntry.getValue()).getType();
439 fullyQualifiedName = serializeType(type);
440 if(attrEntry.getValue() instanceof JavaAttribute) {
441 nullableDefault = ((JavaAttribute)attrEntry.getValue()).getNullableDefaultWrappedForCode();
444 fullyQualifiedName = FullyQualifiedNameHelper
445 .getFullyQualifiedName(packageName, attrEntry.getValue().getUpperCaseCammelCase());
447 fields.add(new Field(fullyQualifiedName, varName, nullableDefault));
449 String getterName = "get" + innerName;
450 MethodDefinition getter = new MethodDefinition(
451 fullyQualifiedName, getterName,
452 Collections.<Field> emptyList(), "return "
455 String setterName = "set" + innerName;
456 MethodDefinition setter = new MethodDefinition("void",
457 setterName, Lists.newArrayList(new Field(
458 fullyQualifiedName, varName)), "this."
459 + varName + " = " + varName + ";");
467 return fullyQualifiedName;
474 List<Field> getFields() {
478 List<MethodDefinition> getMethods() {
484 private static class MXBeanInterfaceAttributesProcessor {
485 private final List<MethodDeclaration> methods = Lists.newArrayList();
487 void processAttributes(Map<String, AttributeIfc> attributes) {
488 for (Entry<String, AttributeIfc> attrEntry : attributes.entrySet()) {
490 AttributeIfc attributeIfc = attrEntry.getValue();
492 if (attributeIfc instanceof TypedAttribute) {
493 TypedAttribute typedAttribute = (TypedAttribute) attributeIfc;
494 returnType = serializeType(typedAttribute.getType());
496 throw new UnsupportedOperationException(
497 "Attribute not supported: "
498 + attributeIfc.getClass());
501 String getterName = "get"
502 + attributeIfc.getUpperCaseCammelCase();
503 MethodDeclaration getter = new MethodDeclaration(returnType,
504 getterName, Collections.<Field> emptyList());
506 String varName = BindingGeneratorUtil
507 .parseToValidParamName(attrEntry.getKey());
508 String setterName = "set"
509 + attributeIfc.getUpperCaseCammelCase();
510 MethodDeclaration setter = new MethodDeclaration("void",
511 setterName, Lists.newArrayList(new Field(returnType,
516 if (attributeIfc.getNullableDescription() != null) {
517 setter.setJavadoc(attrEntry.getValue()
518 .getNullableDescription());
523 List<MethodDeclaration> getMethods() {
528 private static class AbstractFactoryAttributesProcessor {
530 private final List<Field> fields = Lists.newArrayList();
531 private static final String STRING_FULLY_QUALIFIED_NAME = "java.util.List";
533 void processAttributes(Map<String, AttributeIfc> attributes,
534 String packageName) {
535 for (Entry<String, AttributeIfc> attrEntry : attributes.entrySet()) {
537 String nullableDefaultWrapped = null;
538 AttributeIfc attributeIfc = attrEntry.getValue();
540 if (attributeIfc instanceof TypedAttribute) {
541 TypedAttribute typedAttribute = (TypedAttribute) attributeIfc;
542 type = serializeType(typedAttribute.getType());
543 } else if (attributeIfc instanceof TOAttribute) {
544 String fullyQualifiedName = FullyQualifiedNameHelper
545 .getFullyQualifiedName(packageName, attributeIfc.getUpperCaseCammelCase());
547 type = fullyQualifiedName;
548 } else if (attributeIfc instanceof ListAttribute) { //FIXME: listAttribute might extend TypedAttribute
549 String fullyQualifiedName = null;
550 AttributeIfc innerAttr = ((ListAttribute) attributeIfc)
551 .getInnerAttribute();
552 if (innerAttr instanceof JavaAttribute) {
553 fullyQualifiedName = ((JavaAttribute) innerAttr)
554 .getType().getFullyQualifiedName();
555 nullableDefaultWrapped = ((JavaAttribute) innerAttr).getNullableDefaultWrappedForCode();
556 } else if (innerAttr instanceof TOAttribute) {
557 fullyQualifiedName = FullyQualifiedNameHelper
558 .getFullyQualifiedName(packageName, innerAttr.getUpperCaseCammelCase());
561 type = STRING_FULLY_QUALIFIED_NAME.concat("<")
562 .concat(fullyQualifiedName).concat(">");
565 throw new UnsupportedOperationException(
566 "Attribute not supported: "
567 + attributeIfc.getClass());
570 fields.add(new Field(type, attributeIfc
571 .getUpperCaseCammelCase(), nullableDefaultWrapped));
575 List<Field> getFields() {
580 private static class AbstractModuleAttributesProcessor {
582 private static final String STRING_FULLY_QUALIFIED_NAME = "java.util.List";
584 private final List<ModuleField> moduleFields = Lists.newArrayList();
585 private final List<MethodDefinition> methods = Lists.newArrayList();
587 void processAttributes(Map<String, AttributeIfc> attributes,
588 String packageName) {
589 for (Entry<String, AttributeIfc> attrEntry : attributes.entrySet()) {
590 String type, nullableDefaultWrapped = null;
591 AttributeIfc attributeIfc = attrEntry.getValue();
593 if (attributeIfc instanceof TypedAttribute) {
594 TypedAttribute typedAttribute = (TypedAttribute) attributeIfc;
595 type = serializeType(typedAttribute.getType());
596 if (attributeIfc instanceof JavaAttribute) {
597 nullableDefaultWrapped = ((JavaAttribute) attributeIfc).getNullableDefaultWrappedForCode();
600 } else if (attributeIfc instanceof TOAttribute) {
601 String fullyQualifiedName = FullyQualifiedNameHelper
602 .getFullyQualifiedName(packageName, attributeIfc.getUpperCaseCammelCase());
604 type = fullyQualifiedName;
605 } else if (attributeIfc instanceof ListAttribute) {
606 String fullyQualifiedName = null;
607 AttributeIfc innerAttr = ((ListAttribute) attributeIfc)
608 .getInnerAttribute();
609 if (innerAttr instanceof JavaAttribute) {
610 fullyQualifiedName = ((JavaAttribute) innerAttr)
611 .getType().getFullyQualifiedName();
612 nullableDefaultWrapped = ((JavaAttribute) innerAttr).getNullableDefaultWrappedForCode();
613 } else if (innerAttr instanceof TOAttribute) {
614 fullyQualifiedName = FullyQualifiedNameHelper
615 .getFullyQualifiedName(packageName, innerAttr.getUpperCaseCammelCase());
618 type = STRING_FULLY_QUALIFIED_NAME.concat("<")
619 .concat(fullyQualifiedName).concat(">");
621 throw new UnsupportedOperationException(
622 "Attribute not supported: "
623 + attributeIfc.getClass());
626 boolean isDependency = false;
627 boolean isListOfDependencies = false;
628 Dependency dependency = null;
629 Annotation overrideAnnotation = new Annotation("Override",
630 Collections.<Parameter> emptyList());
631 List<Annotation> annotations = Lists
632 .newArrayList(overrideAnnotation);
634 if (attributeIfc instanceof AbstractDependencyAttribute) {
636 dependency = ((AbstractDependencyAttribute) attributeIfc)
638 annotations.add(Annotation
639 .createRequireIfcAnnotation(dependency.getSie()));
640 if (attributeIfc instanceof ListDependenciesAttribute) {
641 isListOfDependencies = true;
645 String varName = BindingGeneratorUtil
646 .parseToValidParamName(attrEntry.getKey());
647 moduleFields.add(new ModuleField(type, varName, attributeIfc
648 .getUpperCaseCammelCase(), nullableDefaultWrapped, isDependency, dependency, isListOfDependencies));
650 String getterName = "get"
651 + attributeIfc.getUpperCaseCammelCase();
652 MethodDefinition getter = new MethodDefinition(type,
653 getterName, Collections.<Field> emptyList(),
654 Lists.newArrayList(overrideAnnotation), "return "
657 String setterName = "set"
658 + attributeIfc.getUpperCaseCammelCase();
660 if (attributeIfc.getNullableDescription() != null) {
661 annotations.add(Annotation
662 .createDescriptionAnnotation(attributeIfc.getNullableDescription()));
665 String setterBody = "this." + varName + " = " + varName + ";";
666 if (isListOfDependencies) {
667 String nullCheck = String.format("if (%s == null) throw new IllegalArgumentException(\"Null not supported\");%n",
669 setterBody = nullCheck + setterBody;
671 MethodDefinition setter = new MethodDefinition("void",
673 Lists.newArrayList(new Field(type, varName)),
674 annotations, setterBody);
675 setter.setJavadoc(attributeIfc.getNullableDescription());
682 List<ModuleField> getModuleFields() {
686 List<MethodDefinition> getMethods() {