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 com.google.common.base.MoreObjects.ToStringHelper;
11 import org.apache.maven.project.MavenProject;
12 import org.opendaylight.yangtools.concepts.Identifiable;
13 import org.opendaylight.yangtools.plugin.generator.api.FileGenerator;
14 import org.opendaylight.yangtools.plugin.generator.api.FileGeneratorException;
15 import org.opendaylight.yangtools.plugin.generator.api.FileGeneratorFactory;
18 * Bridge to a {@link FileGenerator} instance.
20 * @author Robert Varga
22 final class FileGeneratorTaskFactory extends GeneratorTaskFactory implements Identifiable<String> {
23 private final FileGeneratorArg arg;
24 private final FileGenerator gen;
26 private FileGeneratorTaskFactory(final FileGenerator gen, final FileGeneratorArg arg) {
27 super(gen.importResolutionMode());
32 static FileGeneratorTaskFactory of(final FileGeneratorFactory factory, final FileGeneratorArg arg)
33 throws FileGeneratorException {
34 return new FileGeneratorTaskFactory(factory.newFileGenerator(arg.getConfiguration()), arg);
38 public String getIdentifier() {
39 return arg.getIdentifier();
43 FileGeneratorTask createTask(final MavenProject project, final ContextHolder context) {
44 return new FileGeneratorTask(this, context, project);
48 FileGenerator generator() {
53 ToStringHelper addToStringProperties(final ToStringHelper helper) {
54 return super.addToStringProperties(helper).add("argument", arg);