Change openecomp to onap and update license
[aai/aai-common.git] / aai-core / src / main / java / org / onap / aai / introspection / Loader.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 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  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
21  */
22 package org.onap.aai.introspection;
23
24 import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
25 import org.onap.aai.introspection.exceptions.AAIUnmarshallingException;
26 import org.onap.aai.restcore.MediaType;
27
28 import java.util.Map;
29
30 public abstract class Loader {
31
32         private final Version version;
33         private final ModelType modelType;
34         
35         /**
36          * Instantiates a new loader.
37          *
38          * @param version the version
39          * @param modelType the model type
40          * @param llBuilder the ll builder
41          */
42         public Loader (Version version, ModelType modelType) {
43                 this.version = version;
44                 this.modelType = modelType;
45         }
46         
47         /**
48          * Process.
49          *
50          * @param version the version
51          */
52         protected abstract void process(Version version);
53         
54         /**
55          * Object from name.
56          *
57          * @param name the name
58          * @return the object
59          * @throws AAIUnknownObjectException 
60          */
61         public abstract Object objectFromName(String name) throws AAIUnknownObjectException;
62         
63         /**
64          * Introspector from name.
65          *
66          * @param name the name
67          * @return the introspector
68          * @throws AAIUnknownObjectException 
69          */
70         public abstract Introspector introspectorFromName(String name) throws AAIUnknownObjectException;
71         
72         /**
73          * Unmarshal.
74          *
75          * @param type the type
76          * @param json the json
77          * @param mediaType the media type
78          * @return the introspector
79          */
80         public abstract Introspector unmarshal(String type, String json, MediaType mediaType) throws AAIUnmarshallingException;
81         
82         /**
83          * Unmarshal.
84          *
85          * @param type the type
86          * @param json the json
87          * @return the introspector
88          */
89         public Introspector unmarshal(String type, String json) throws AAIUnmarshallingException {
90                 return unmarshal(type, json, MediaType.APPLICATION_JSON_TYPE);
91         }
92
93         
94         /**
95          * Gets the model type.
96          *
97          * @return the model type
98          */
99         public ModelType getModelType() {
100                 return this.modelType;
101         }
102         
103         /**
104          * Gets the version.
105          *
106          * @return the version
107          */
108         public Version getVersion() {
109                 return this.version;
110         }
111         
112         public abstract Map<String, Introspector> getAllObjects();
113 }