- private static Logger _logger = LoggerFactory.getLogger(ModelGenerator.class);
-
- private static final String BASE_64 = "base64";
- private static final String BINARY_ENCODING_KEY = "binaryEncoding";
- private static final String MEDIA_KEY = "media";
- private static final String ONE_OF_KEY = "oneOf";
- private static final String UNIQUE_ITEMS_KEY = "uniqueItems";
- private static final String MAX_ITEMS = "maxItems";
- private static final String MIN_ITEMS = "minItems";
- private static final String SCHEMA_URL = "http://json-schema.org/draft-04/schema";
- private static final String SCHEMA_KEY = "$schema";
- private static final String MAX_LENGTH_KEY = "maxLength";
- private static final String MIN_LENGTH_KEY = "minLength";
- private static final String REQUIRED_KEY = "required";
- private static final String REF_KEY = "$ref";
- private static final String ITEMS_KEY = "items";
- private static final String TYPE_KEY = "type";
- private static final String PROPERTIES_KEY = "properties";
- private static final String DESCRIPTION_KEY = "description";
- private static final String OBJECT_TYPE = "object";
- private static final String ARRAY_TYPE = "array";
- private static final String ENUM = "enum";
- private static final String INTEGER = "integer";
- private static final String NUMBER = "number";
- private static final String BOOLEAN = "boolean";
- private static final String STRING = "string";
-
- private static final Map<Class<? extends TypeDefinition<?>>, String> YANG_TYPE_TO_JSON_TYPE_MAPPING;
-
- static {
- Map<Class<? extends TypeDefinition<?>>, String> tempMap1 = new HashMap<Class<? extends TypeDefinition<?>>, String>(10);
- tempMap1.put(StringType.class , STRING);
- tempMap1.put(BooleanType.class , BOOLEAN);
- tempMap1.put(Int8.class , INTEGER);
- tempMap1.put(Int16.class , INTEGER);
- tempMap1.put(Int32.class , INTEGER);
- tempMap1.put(Int64.class , INTEGER);
- tempMap1.put(Uint16.class , INTEGER);
- tempMap1.put(Uint32.class , INTEGER);
- tempMap1.put(Uint64.class , INTEGER);
- tempMap1.put(Uint8.class , INTEGER);
- tempMap1.put(Decimal64.class , NUMBER);
- tempMap1.put(EnumerationType.class , ENUM);
- //TODO: Binary type
-
- YANG_TYPE_TO_JSON_TYPE_MAPPING = Collections.unmodifiableMap(tempMap1);
- }
-
- public ModelGenerator(){
- }
-
- public JSONObject convertToJsonSchema(Module module) throws IOException, JSONException {
- JSONObject models = new JSONObject();
- processContainers(module, models);
- processRPCs(module, models);
-
- return models;
- }
-
+ private static Logger _logger = LoggerFactory.getLogger(ModelGenerator.class);
+
+ private static final String BASE_64 = "base64";
+ private static final String BINARY_ENCODING_KEY = "binaryEncoding";
+ private static final String MEDIA_KEY = "media";
+ private static final String ONE_OF_KEY = "oneOf";
+ private static final String UNIQUE_ITEMS_KEY = "uniqueItems";
+ private static final String MAX_ITEMS = "maxItems";
+ private static final String MIN_ITEMS = "minItems";
+ private static final String SCHEMA_URL = "http://json-schema.org/draft-04/schema";
+ private static final String SCHEMA_KEY = "$schema";
+ private static final String MAX_LENGTH_KEY = "maxLength";
+ private static final String MIN_LENGTH_KEY = "minLength";
+ private static final String REQUIRED_KEY = "required";
+ private static final String REF_KEY = "$ref";
+ private static final String ITEMS_KEY = "items";
+ private static final String TYPE_KEY = "type";
+ private static final String PROPERTIES_KEY = "properties";
+ private static final String DESCRIPTION_KEY = "description";
+ private static final String OBJECT_TYPE = "object";
+ private static final String ARRAY_TYPE = "array";
+ private static final String ENUM = "enum";
+ private static final String INTEGER = "integer";
+ private static final String NUMBER = "number";
+ private static final String BOOLEAN = "boolean";
+ private static final String STRING = "string";
+ private static final String ID_KEY = "id";
+ private static final String SUB_TYPES_KEY = "subTypes";
+
+ private static final Map<Class<? extends TypeDefinition<?>>, String> YANG_TYPE_TO_JSON_TYPE_MAPPING;
+
+ static {
+ Map<Class<? extends TypeDefinition<?>>, String> tempMap1 = new HashMap<Class<? extends TypeDefinition<?>>, String>(
+ 10);
+ tempMap1.put(StringType.class, STRING);
+ tempMap1.put(BooleanType.class, BOOLEAN);
+ tempMap1.put(Int8.class, INTEGER);
+ tempMap1.put(Int16.class, INTEGER);
+ tempMap1.put(Int32.class, INTEGER);
+ tempMap1.put(Int64.class, INTEGER);
+ tempMap1.put(Uint16.class, INTEGER);
+ tempMap1.put(Uint32.class, INTEGER);
+ tempMap1.put(Uint64.class, INTEGER);
+ tempMap1.put(Uint8.class, INTEGER);
+ tempMap1.put(Decimal64.class, NUMBER);
+ tempMap1.put(EnumerationType.class, ENUM);
+ // TODO: Binary type
+
+ YANG_TYPE_TO_JSON_TYPE_MAPPING = Collections.unmodifiableMap(tempMap1);
+ }