2 * Copyright (c) 2020 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.yangtools.yang2sources.plugin;
10 import static java.util.Objects.requireNonNull;
13 import java.io.IOException;
14 import java.util.Collection;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.opendaylight.yangtools.plugin.generator.api.FileGeneratorException;
17 import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
18 import org.sonatype.plexus.build.incremental.BuildContext;
21 abstract class GeneratorTask<T extends GeneratorTaskFactory> extends ParserModeAware {
22 private final ContextHolder context;
23 private final T factory;
25 GeneratorTask(final T factory, final ContextHolder context) {
26 this.factory = requireNonNull(factory);
27 this.context = requireNonNull(context);
31 final StatementParserMode parserMode() {
32 return factory.parserMode();
35 final Collection<File> execute(final BuildContext buildContext) throws FileGeneratorException, IOException {
36 return execute(factory, context, buildContext);
39 abstract Collection<File> execute(T factory, ContextHolder modelContext, BuildContext buildContext)
40 throws FileGeneratorException, IOException;