Remove deprecated Yin/YangStatementSourceImpl
[yangtools.git] / yang / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / repo / api / ResourceYinTextSchemaSource.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.model.repo.api;
9
10 import com.google.common.base.MoreObjects.ToStringHelper;
11 import com.google.common.base.Preconditions;
12 import java.io.IOException;
13 import java.io.InputStream;
14 import java.net.URL;
15 import java.util.Optional;
16 import org.opendaylight.yangtools.concepts.Delegator;
17
18 /**
19  * A resource-backed {@link YangTextSchemaSource}.
20  */
21 final class ResourceYinTextSchemaSource extends YinTextSchemaSource implements Delegator<URL> {
22     private final URL url;
23
24     ResourceYinTextSchemaSource(final SourceIdentifier identifier, final URL url) {
25         super(identifier);
26         this.url = Preconditions.checkNotNull(url);
27     }
28
29     @Override
30     public URL getDelegate() {
31         return url;
32     }
33
34     @Override
35     protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
36         return toStringHelper.add("url", url);
37     }
38
39     @Override
40     public InputStream openStream() throws IOException {
41         return url.openStream();
42     }
43
44     @Override
45     public Optional<String> getSymbolicName() {
46         return Optional.of(url.toString());
47     }
48 }