Integrate aai-schema-ingest library into aai-core
[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-2018 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 package org.onap.aai.introspection;
21
22 import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
23 import org.onap.aai.introspection.exceptions.AAIUnmarshallingException;
24 import org.onap.aai.restcore.MediaType;
25 import org.onap.aai.setup.SchemaVersion;
26
27 import java.util.Map;
28
29 public abstract class Loader {
30
31         private final SchemaVersion 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          */
40         public Loader (SchemaVersion version, ModelType modelType) {
41                 this.version = version;
42                 this.modelType = modelType;
43         }
44         
45         /**
46          * Process.
47          *
48          * @param version the version
49          */
50         protected abstract void process(SchemaVersion version);
51         
52         /**
53          * Object from name.
54          *
55          * @param name the name
56          * @return the object
57          * @throws AAIUnknownObjectException 
58          */
59         public abstract Object objectFromName(String name) throws AAIUnknownObjectException;
60         
61         /**
62          * Introspector from name.
63          *
64          * @param name the name
65          * @return the introspector
66          * @throws AAIUnknownObjectException 
67          */
68         public abstract Introspector introspectorFromName(String name) throws AAIUnknownObjectException;
69         
70         /**
71          * Unmarshal.
72          *
73          * @param type the type
74          * @param json the json
75          * @param mediaType the media type
76          * @return the introspector
77          */
78         public abstract Introspector unmarshal(String type, String json, MediaType mediaType) throws AAIUnmarshallingException;
79         
80         /**
81          * Unmarshal.
82          *
83          * @param type the type
84          * @param json the json
85          * @return the introspector
86          */
87         public Introspector unmarshal(String type, String json) throws AAIUnmarshallingException {
88                 return unmarshal(type, json, MediaType.APPLICATION_JSON_TYPE);
89         }
90
91         
92         /**
93          * Gets the model type.
94          *
95          * @return the model type
96          */
97         public ModelType getModelType() {
98                 return this.modelType;
99         }
100         
101         /**
102          * Gets the version.
103          *
104          * @return the version
105          */
106         public SchemaVersion getVersion() {
107                 return this.version;
108         }
109         
110         public abstract Map<String, Introspector> getAllObjects();
111 }