aboutsummaryrefslogtreecommitdiffstats
path: root/jython-tosca-parser/src/main/java/org/openecomp/sdc/toscaparser/api/StatefulEntityTypeFactory.java
blob: 554450a50ed960d758c8ef86806cb734ca260691 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package org.openecomp.sdc.toscaparser.api;

import org.openecomp.sdc.toscaparser.api.elements.GroupType;
import org.openecomp.sdc.toscaparser.api.elements.NodeType;
import org.openecomp.sdc.toscaparser.api.elements.StatefulEntityType;
import org.openecomp.sdc.toscaparser.jython.elements.JyGroupType;
import org.openecomp.sdc.toscaparser.jython.elements.JyNodeType;
import org.openecomp.sdc.toscaparser.jython.elements.JyStatefulEntityType;

public class StatefulEntityTypeFactory {
    
    public StatefulEntityType create(JyStatefulEntityType jyStatefulEntityType) {
        String jyClassName = jyStatefulEntityType.getJyClassName();
        StatefulEntityType statefulEntityType;
        switch (jyClassName) {
            case "NodeType":
                statefulEntityType = new NodeType((JyNodeType) jyStatefulEntityType);
                break;
            case "GroupType":
                statefulEntityType = new GroupType((JyGroupType) jyStatefulEntityType);
                break;
            default: 
                throw new UnsupportedOperationException(jyClassName + " is not supported!");
        }
        
        return statefulEntityType;
    }
}