2 * Copyright (c) 2013 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.yang2sources.plugin;
10 import com.google.common.base.Preconditions;
11 import com.google.common.collect.ImmutableSet;
12 import java.util.Optional;
14 import org.opendaylight.yangtools.concepts.Immutable;
15 import org.opendaylight.yangtools.yang.model.api.Module;
16 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
17 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
19 final class ContextHolder implements Immutable {
20 private final SchemaContext context;
21 private final Set<Module> modules;
22 private final Set<SourceIdentifier> sources;
24 ContextHolder(final SchemaContext context, final Set<Module> modules, final Set<SourceIdentifier> sources) {
25 this.context = Preconditions.checkNotNull(context);
26 this.modules = ImmutableSet.copyOf(modules);
27 this.sources = ImmutableSet.copyOf(sources);
30 SchemaContext getContext() {
34 Set<Module> getYangModules() {
38 Optional<String> moduleToResourcePath(final Module mod) {
39 final SourceIdentifier id = Util.moduleToIdentifier(mod);
40 return sources.contains(id)
41 ? Optional.of("/" + YangToSourcesProcessor.META_INF_YANG_STRING_JAR + "/" + id.toYangFilename())