2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.controller.md.cluster.datastore.model;
11 import java.io.InputStream;
12 import java.util.ArrayList;
13 import java.util.List;
15 import org.opendaylight.yangtools.yang.model.api.Module;
16 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
17 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
19 public class SchemaContextHelper {
21 public static final String ODL_DATASTORE_TEST_YANG = "/odl-datastore-test.yang";
22 public static final String PEOPLE_YANG = "/people.yang";
23 public static final String CARS_YANG = "/cars.yang";
25 public static InputStream getInputStream(final String yangFileName) {
26 return TestModel.class.getResourceAsStream(yangFileName);
29 public static SchemaContext full(){
30 return select(ODL_DATASTORE_TEST_YANG, PEOPLE_YANG, CARS_YANG);
33 public static SchemaContext select(String... schemaFiles){
34 YangParserImpl parser = new YangParserImpl();
35 List<InputStream> streams = new ArrayList<>();
37 for(String schemaFile : schemaFiles){
38 streams.add(getInputStream(schemaFile));
41 Set<Module> modules = parser.parseYangModelsFromStreams(streams);
42 return parser.resolveSchemaContext(modules);