Resolve Bug:445 Remove freemarker from config code generator.
[controller.git] / opendaylight / config / yang-jmx-generator-plugin / src / main / java / org / opendaylight / controller / config / yangjmxgenerator / plugin / ftl / GeneralClassTemplate.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl;
9
10 import java.util.Collections;
11 import java.util.List;
12
13 import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Constructor;
14 import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Field;
15 import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Header;
16 import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.MethodDefinition;
17 import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.TypeDeclaration;
18
19 public class GeneralClassTemplate extends AbstractFtlTemplate {
20
21     private final List<Constructor> constructors;
22
23     public GeneralClassTemplate(Header header, String packageName, String name,
24             List<String> extendedClasses, List<String> implementedIfcs,
25             List<Field> fields, List<MethodDefinition> methods) {
26         this(header, packageName, name, extendedClasses, implementedIfcs,
27                 fields, methods, false, false, Collections
28                         .<Constructor> emptyList());
29     }
30
31     public GeneralClassTemplate(Header header, String packageName, String name,
32             List<String> extendedClasses, List<String> implementedIfcs,
33             List<Field> fields, List<MethodDefinition> methods,
34             boolean isAbstract, boolean isFinal, List<Constructor> constructors) {
35         super(header, packageName, fields, methods, new TypeDeclaration(
36                 "class", name, checkCardinality(extendedClasses),
37                 implementedIfcs, isAbstract, isFinal));
38         this.constructors = constructors;
39     }
40
41     static List<String> checkCardinality(List<String> extendedClass) {
42         if (extendedClass.size() > 1)
43             throw new IllegalArgumentException(
44                     "Class cannot have more than one super " + "class");
45         return extendedClass;
46     }
47
48     public List<Constructor> getConstructors() {
49         return constructors;
50     }
51
52 }