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