Merge topic 'archetype'
[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 import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Constructor;
13 import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Field;
14 import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.Header;
15 import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.MethodDefinition;
16 import org.opendaylight.controller.config.yangjmxgenerator.plugin.ftl.model.TypeDeclaration;
17
18 public class GeneralClassTemplate extends AbstractFtlTemplate {
19
20     private final List<Constructor> constructors;
21
22     public GeneralClassTemplate(Header header, String packageName, String name,
23             List<String> extendedClasses, List<String> implementedIfcs,
24             List<Field> fields, List<MethodDefinition> methods) {
25         this(header, packageName, name, extendedClasses, implementedIfcs,
26                 fields, methods, false, false, Collections
27                         .<Constructor> emptyList());
28     }
29
30     public GeneralClassTemplate(Header header, String packageName, String name,
31             List<String> extendedClasses, List<String> implementedIfcs,
32             List<Field> fields, List<MethodDefinition> methods,
33             boolean isAbstract, boolean isFinal, List<Constructor> constructors) {
34         super(header, packageName, fields, methods, new TypeDeclaration(
35                 "class", name, checkCardinality(extendedClasses),
36                 implementedIfcs, isAbstract, isFinal));
37         this.constructors = constructors;
38     }
39
40     static List<String> checkCardinality(List<String> extendedClass) {
41         if (extendedClass.size() > 1) {
42             throw new IllegalArgumentException(
43                     "Class cannot have more than one super class, found: " + extendedClass);
44         }
45         return extendedClass;
46     }
47
48     public List<Constructor> getConstructors() {
49         return constructors;
50     }
51
52 }