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 static java.util.Objects.requireNonNull;
12 import com.google.common.collect.ImmutableSet;
13 import java.util.Optional;
15 import org.opendaylight.yangtools.concepts.Immutable;
16 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
17 import org.opendaylight.yangtools.yang.model.api.Module;
18 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
20 final class ContextHolder implements Immutable {
21 private final EffectiveModelContext context;
22 private final Set<Module> modules;
23 private final Set<SourceIdentifier> sources;
25 ContextHolder(final EffectiveModelContext context, final Set<Module> modules, final Set<SourceIdentifier> sources) {
26 this.context = requireNonNull(context);
27 this.modules = ImmutableSet.copyOf(modules);
28 this.sources = ImmutableSet.copyOf(sources);
31 EffectiveModelContext getContext() {
35 Set<Module> getYangModules() {
39 Optional<String> moduleToResourcePath(final Module mod) {
40 final SourceIdentifier id = Util.moduleToIdentifier(mod);
41 return sources.contains(id)
42 ? Optional.of("/" + YangToSourcesProcessor.META_INF_YANG_STRING_JAR + "/" + id.toYangFilename())