76f003905f9672b49319ea2b76c829bb6b5c2d71
[aai/aai-common.git] / aai-core / src / main / java / org / openecomp / aai / introspection / Loader.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * org.openecomp.aai
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
10
11      http://www.apache.org/licenses/LICENSE-2.0
12
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.aai.introspection;
22
23 import java.util.Map;
24
25 import org.openecomp.aai.introspection.exceptions.AAIUnknownObjectException;
26 import org.openecomp.aai.introspection.exceptions.AAIUnmarshallingException;
27 import org.openecomp.aai.restcore.MediaType;
28
29 public abstract class Loader {
30
31         private final Version version;
32         private final ModelType modelType;
33         
34         /**
35          * Instantiates a new loader.
36          *
37          * @param version the version
38          * @param modelType the model type
39          * @param llBuilder the ll builder
40          */
41         public Loader (Version version, ModelType modelType) {
42                 this.version = version;
43                 this.modelType = modelType;
44         }
45         
46         /**
47          * Process.
48          *
49          * @param version the version
50          */
51         protected abstract void process(Version version);
52         
53         /**
54          * Object from name.
55          *
56          * @param name the name
57          * @return the object
58          * @throws AAIUnknownObjectException 
59          */
60         public abstract Object objectFromName(String name) throws AAIUnknownObjectException;
61         
62         /**
63          * Introspector from name.
64          *
65          * @param name the name
66          * @return the introspector
67          * @throws AAIUnknownObjectException 
68          */
69         public abstract Introspector introspectorFromName(String name) throws AAIUnknownObjectException;
70         
71         /**
72          * Unmarshal.
73          *
74          * @param type the type
75          * @param json the json
76          * @param mediaType the media type
77          * @return the introspector
78          */
79         public abstract Introspector unmarshal(String type, String json, MediaType mediaType) throws AAIUnmarshallingException;
80         
81         /**
82          * Unmarshal.
83          *
84          * @param type the type
85          * @param json the json
86          * @return the introspector
87          */
88         public Introspector unmarshal(String type, String json) throws AAIUnmarshallingException {
89                 return unmarshal(type, json, MediaType.APPLICATION_JSON_TYPE);
90         }
91
92         
93         /**
94          * Gets the model type.
95          *
96          * @return the model type
97          */
98         public ModelType getModelType() {
99                 return this.modelType;
100         }
101         
102         /**
103          * Gets the version.
104          *
105          * @return the version
106          */
107         public Version getVersion() {
108                 return this.version;
109         }
110         
111         public abstract Map<String, Introspector> getAllObjects();
112 }