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 / model / TypeDeclaration.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.model;
9
10 import org.opendaylight.controller.config.yangjmxgenerator.plugin.java.TypeName;
11
12 import java.util.List;
13
14 public class TypeDeclaration {
15     private final String type, name;
16     private final List<String> extended, implemented;
17     private final boolean isAbstract, isFinal;
18
19     public TypeDeclaration(String type, String name, List<String> extended,
20             List<String> implemented, boolean isAbstract, boolean isFinal) {
21         super();
22         this.type = type;
23         this.name = name;
24         this.extended = extended;
25         this.implemented = implemented;
26         this.isAbstract = isAbstract;
27         this.isFinal = isFinal;
28     }
29
30     public TypeDeclaration(String type, String name, List<String> extended,
31             List<String> implemented) {
32         this(type, name, extended, implemented, false, false);
33     }
34
35     public boolean isAbstract() {
36         return isAbstract;
37     }
38
39     public boolean isFinal() {
40         return isFinal;
41     }
42
43     public String getType() {
44         return type;
45     }
46
47     public String getName() {
48         return name;
49     }
50
51     public List<String> getExtended() {
52         return extended;
53     }
54
55     public List<String> getImplemented() {
56         return implemented;
57     }
58
59     public TypeName toTypeName() {
60         if ("interface".equals(type)) {
61             return TypeName.interfaceType;
62         } else if ("class".equals(type)) {
63             if (isAbstract) {
64                 return TypeName.absClassType;
65             } else if (isFinal) {
66                 return TypeName.finalClassType;
67             } else {
68                 return TypeName.classType;
69             }
70         } else if ("enum".equals(type)) {
71             return TypeName.enumType;
72         } else {
73             throw new IllegalStateException("Type not supported: " + type);
74         }
75     }
76
77     @Override
78     public String toString() {
79         return "TypeDeclaration{" + "type='" + type + '\'' + ", name='" + name
80                 + '\'' + '}';
81     }
82 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.