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.yangtools.yang.parser.repo;
11 import com.google.common.base.MoreObjects;
12 import com.google.common.base.Preconditions;
13 import java.io.IOException;
14 import java.io.InputStream;
15 import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
17 final class ResourceYangSource extends YangTextSchemaSource {
19 private final String resourceName;
21 ResourceYangSource(final String resourceName) {
22 super(identifierFromFilename(resourceName));
23 this.resourceName = resourceName;
27 protected MoreObjects.ToStringHelper addToStringAttributes(final MoreObjects.ToStringHelper toStringHelper) {
28 return toStringHelper.add("resource", resourceName);
32 public InputStream openStream() throws IOException {
33 return Preconditions.checkNotNull(getClass().getResourceAsStream(resourceName));