2 * Copyright (c) 2014 Brocade Communications 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
9 package org.opendaylight.mdsal.binding.generator.util;
12 * Factory class for creating SourceCodeGenerator instances.
14 * @author Thomas Pantelis
16 public class SourceCodeGeneratorFactory {
18 private static final String GENERATE_CODEC_SOURCE_PROP = "org.opendaylight.yangtools.sal.generateCodecSource";
20 private static final SourceCodeGenerator NULL_GENERATOR = new NullSourceCodeGenerator();
23 * Gets a SourceCodeGenerator instance.
25 * Generation of source code is controlled by the <i>org.opendaylight.yangtools.sal.generateCodecSource</i>
26 * system property. If set to true, a DefaultSourceCodeGenerator instance is returned, otherwise a
27 * NullSourceCodeGenerator is returned.
29 * @param generatedSourceDir the directory in which to put generated source files. If null,
30 * a default is used (see DefaultSourceCodeGenerator).
32 public SourceCodeGenerator getInstance(String generatedSourceDir) {
34 boolean generateSource = Boolean.valueOf(System.getProperty( GENERATE_CODEC_SOURCE_PROP, "false"));
36 return new DefaultSourceCodeGenerator(generatedSourceDir);
39 return NULL_GENERATOR;