<commit_before>/*
 * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */
package org.opendaylight.yangtools.sal.binding.generator.impl

import java.util.Collection
import java.util.Date
import java.util.List
import java.util.Map
import java.util.Set
import java.util.StringTokenizer
import org.opendaylight.yangtools.yang.common.QName
import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode
import org.opendaylight.yangtools.yang.model.api.AugmentationSchema
import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode
import org.opendaylight.yangtools.yang.model.api.ChoiceNode
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode
import org.opendaylight.yangtools.yang.model.api.Deviation
import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition
import org.opendaylight.yangtools.yang.model.api.FeatureDefinition
import org.opendaylight.yangtools.yang.model.api.GroupingDefinition
import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode
import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode
import org.opendaylight.yangtools.yang.model.api.ListSchemaNode
import org.opendaylight.yangtools.yang.model.api.Module
import org.opendaylight.yangtools.yang.model.api.ModuleImport
import org.opendaylight.yangtools.yang.model.api.NotificationDefinition
import org.opendaylight.yangtools.yang.model.api.RpcDefinition
import org.opendaylight.yangtools.yang.model.api.SchemaNode
import org.opendaylight.yangtools.yang.model.api.SchemaPath
import org.opendaylight.yangtools.yang.model.api.TypeDefinition
import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode
import org.opendaylight.yangtools.yang.model.api.UsesNode
import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition
import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.EnumPair
import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil

class YangTemplate {

    private static var Module module = null

    def static String generateYangSnipet(SchemaNode schemaNode) {
        if (schemaNode == null)
            return ''

        '''
            «IF schemaNode instanceof DataSchemaNode»
            «writeDataSchemaNode(schemaNode as DataSchemaNode)»
            «ENDIF»
            «IF schemaNode instanceof EnumTypeDefinition.EnumPair»
            «writeEnumPair(schemaNode as EnumTypeDefinition.EnumPair)»
            «ENDIF»
            «IF schemaNode instanceof ExtensionDefinition»
            «writeExtension(schemaNode as ExtensionDefinition)»
            «ENDIF»
            «IF schemaNode instanceof FeatureDefinition»
            «writeFeature(schemaNode as FeatureDefinition)»
            «ENDIF»
            «IF schemaNode instanceof GroupingDefinition»
            «writeGroupingDef(schemaNode as GroupingDefinition)»<commit_msg>BUG-1611: drop a FIXME for thread-safety<commit_after>/*
 * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */
package org.opendaylight.yangtools.sal.binding.generator.impl

import java.util.Collection
import java.util.Date
import java.util.List
import java.util.Map
import java.util.Set
import java.util.StringTokenizer
import org.opendaylight.yangtools.yang.common.QName
import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode
import org.opendaylight.yangtools.yang.model.api.AugmentationSchema
import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode
import org.opendaylight.yangtools.yang.model.api.ChoiceNode
import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode
import org.opendaylight.yangtools.yang.model.api.Deviation
import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition
import org.opendaylight.yangtools.yang.model.api.FeatureDefinition
import org.opendaylight.yangtools.yang.model.api.GroupingDefinition
import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode
import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode
import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode
import org.opendaylight.yangtools.yang.model.api.ListSchemaNode
import org.opendaylight.yangtools.yang.model.api.Module
import org.opendaylight.yangtools.yang.model.api.ModuleImport
import org.opendaylight.yangtools.yang.model.api.NotificationDefinition
import org.opendaylight.yangtools.yang.model.api.RpcDefinition
import org.opendaylight.yangtools.yang.model.api.SchemaNode
import org.opendaylight.yangtools.yang.model.api.SchemaPath
import org.opendaylight.yangtools.yang.model.api.TypeDefinition
import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode
import org.opendaylight.yangtools.yang.model.api.UsesNode
import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition
import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.EnumPair
import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil

class YangTemplate {

    // FIXME: this is not thread-safe and seems to be unused!
    private static var Module module = null

    def static String generateYangSnipet(SchemaNode schemaNode) {
        if (schemaNode == null)
            return ''

        '''
            «IF schemaNode instanceof DataSchemaNode»
            «writeDataSchemaNode(schemaNode as DataSchemaNode)»
            «ENDIF»
            «IF schemaNode instanceof EnumTypeDefinition.EnumPair»
            «writeEnumPair(schemaNode as EnumTypeDefinition.EnumPair)»
            «ENDIF»
            «IF schemaNode instanceof ExtensionDefinition»
            «writeExtension(schemaNode as ExtensionDefinition)»
            «ENDIF»
            «IF schemaNode instanceof FeatureDefinition»
            «writeFeature(schemaNode as FeatureDefinition)»
            «ENDIF»
            «IF schemaNode instanceof GroupingDefinition»
            «writeGroupingDef(schemaNode as GroupingDefinition)»
{'fraction_non_alphanumeric': 0.08265227447956823, 'fraction_numerical': 0.0030840400925212026, 'mean_word_length': 4.405, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5402192', 'n_tokens_mistral': 2011, 'n_tokens_neox': 1865, 'n_words': 397}