2 * Copyright (c) 2019 PANTHEON.tech, s.r.o. 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.netconf.sal.connect.netconf;
10 import static java.util.Objects.requireNonNull;
12 import com.google.common.collect.Collections2;
13 import java.util.Collection;
15 import org.opendaylight.yangtools.yang.common.QName;
16 import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
17 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
18 import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
19 import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider;
22 * Contains RequiredSources - sources from capabilities.
24 final class DeviceSources {
25 private final Set<QName> requiredSources;
26 private final Set<QName> providedSources;
27 private final SchemaSourceProvider<YangTextSchemaSource> sourceProvider;
29 DeviceSources(final Set<QName> requiredSources, final Set<QName> providedSources,
30 final SchemaSourceProvider<YangTextSchemaSource> sourceProvider) {
31 this.requiredSources = requireNonNull(requiredSources);
32 this.providedSources = requireNonNull(providedSources);
33 this.sourceProvider = requireNonNull(sourceProvider);
36 Set<QName> getRequiredSourcesQName() {
37 return requiredSources;
40 Set<QName> getProvidedSourcesQName() {
41 return providedSources;
44 Collection<SourceIdentifier> getRequiredSources() {
45 return Collections2.transform(requiredSources, DeviceSources::toSourceId);
48 Collection<SourceIdentifier> getProvidedSources() {
49 return Collections2.transform(providedSources, DeviceSources::toSourceId);
52 SchemaSourceProvider<YangTextSchemaSource> getSourceProvider() {
53 return sourceProvider;
56 private static SourceIdentifier toSourceId(final QName input) {
57 return RevisionSourceIdentifier.create(input.getLocalName(), input.getRevision());