Cleanup use of Guava library
[yangtools.git] / yang / yang-model-api / src / main / java / org / opendaylight / yangtools / yang / model / repo / api / DelegatedYangTextSchemaSource.java
1 /*
2  * Copyright (c) 2017 Pantheon Technologies, s.r.o. 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 static java.util.Objects.requireNonNull;
11
12 import com.google.common.base.MoreObjects.ToStringHelper;
13 import com.google.common.io.ByteSource;
14 import java.io.IOException;
15 import java.io.InputStream;
16 import org.opendaylight.yangtools.concepts.Delegator;
17
18 final class DelegatedYangTextSchemaSource extends YangTextSchemaSource implements Delegator<ByteSource> {
19     private final ByteSource delegate;
20
21     DelegatedYangTextSchemaSource(final SourceIdentifier identifier, final ByteSource delegate) {
22         super(identifier);
23         this.delegate = requireNonNull(delegate);
24     }
25
26     @Override
27     public ByteSource getDelegate() {
28         return delegate;
29     }
30
31     @Override
32     public InputStream openStream() throws IOException {
33         return delegate.openStream();
34     }
35
36     @Override
37     protected ToStringHelper addToStringAttributes(final ToStringHelper toStringHelper) {
38         return toStringHelper.add("delegate", delegate);
39     }
40 }