cae4cbb773cc09a90d0dff4ed71808d58618ebd1
[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 import java.util.Set;
29
30 public abstract class Loader {
31
32         private final SchemaVersion 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          */
41         public Loader (SchemaVersion 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(SchemaVersion 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 SchemaVersion getVersion() {
108                 return this.version;
109         }
110
111         public abstract Map<String, Introspector> getAllObjects();
112
113     public abstract Set<String> getNamedPropNodes();
114 }