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
8 package org.opendaylight.yangtools.yang.model.repo.api;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.base.MoreObjects.ToStringHelper;
13 import java.io.IOException;
14 import java.io.InputStream;
16 import java.util.Optional;
17 import org.eclipse.jdt.annotation.NonNull;
18 import org.opendaylight.yangtools.concepts.Delegator;
21 * A resource-backed {@link YinTextSchemaSource}.
23 final class ResourceYangTextSchemaSource extends YangTextSchemaSource implements Delegator<URL> {
24 private final @NonNull URL url;
26 ResourceYangTextSchemaSource(final SourceIdentifier identifier, final URL url) {
28 this.url = requireNonNull(url);
32 public URL getDelegate() {
37 protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
38 return toStringHelper.add("url", url);
42 public InputStream openStream() throws IOException {
43 return url.openStream();
47 public Optional<String> getSymbolicName() {
48 return Optional.of(url.toString());