Merge "Create release notes for 13.0.1 AAI release"
[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
21 package org.onap.aai.introspection;
22
23 import java.util.Map;
24 import java.util.Set;
25
26 import org.onap.aai.introspection.exceptions.AAIUnknownObjectException;
27 import org.onap.aai.introspection.exceptions.AAIUnmarshallingException;
28 import org.onap.aai.restcore.MediaType;
29 import org.onap.aai.setup.SchemaVersion;
30
31 public abstract class Loader {
32
33     private final SchemaVersion version;
34     private final ModelType modelType;
35
36     /**
37      * Instantiates a new loader.
38      *
39      * @param version the version
40      * @param modelType the model type
41      */
42     public Loader(SchemaVersion 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(SchemaVersion 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)
81             throws AAIUnmarshallingException;
82
83     /**
84      * Unmarshal.
85      *
86      * @param type the type
87      * @param json the json
88      * @return the introspector
89      */
90     public Introspector unmarshal(String type, String json) throws AAIUnmarshallingException {
91         return unmarshal(type, json, MediaType.APPLICATION_JSON_TYPE);
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 SchemaVersion getVersion() {
109         return this.version;
110     }
111
112     public abstract Map<String, Introspector> getAllObjects();
113
114     public abstract Set<String> getNamedPropNodes();
115 }