e2566a722786cc9cca0896b06de1d2d577708aa9
[mdsal.git] / binding / mdsal-binding-generator-impl / src / main / java / org / opendaylight / mdsal / binding / generator / util / SourceCodeGeneratorFactory.java
1 /*
2  * Copyright (c) 2014 Brocade Communications Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.mdsal.binding.generator.util;
9
10 /**
11  * Factory class for creating SourceCodeGenerator instances.
12  *
13  * @author Thomas Pantelis
14  * @deprecated Code generation is a concert separate from type mapping and is an implementation detail.
15  */
16 @Deprecated
17 public class SourceCodeGeneratorFactory {
18
19     private static final String GENERATE_CODEC_SOURCE_PROP = "org.opendaylight.yangtools.sal.generateCodecSource";
20
21     private static final SourceCodeGenerator NULL_GENERATOR = new NullSourceCodeGenerator();
22
23     /**
24      * Gets a SourceCodeGenerator instance.
25      *
26      * <p>
27      * Generation of source code is controlled by the <i>org.opendaylight.yangtools.sal.generateCodecSource</i>
28      * system property. If set to true, a DefaultSourceCodeGenerator instance is returned, otherwise a
29      * NullSourceCodeGenerator is returned.
30      *
31      * @param generatedSourceDir the directory in which to put generated source files. If null,
32      *     a default is used (see DefaultSourceCodeGenerator).
33      */
34     public SourceCodeGenerator getInstance(final String generatedSourceDir) {
35         boolean generateSource = Boolean.getBoolean(GENERATE_CODEC_SOURCE_PROP);
36         if (generateSource) {
37             return new DefaultSourceCodeGenerator(generatedSourceDir);
38         }
39
40         return NULL_GENERATOR;
41     }
42 }