<commit_before>package com.mysema.query.scala

import com.mysema.query.codegen._
import com.mysema.codegen.CodeWriter
import com.mysema.query

import java.util._
import java.io.IOException

import scala.reflect.BeanProperty
import scala.collection.JavaConversions._
import scala.collection.mutable.Set

/**
 * BeanSerializer for Scala
 * 
 * @author tiwe
 *
 */
class ScalaBeanSerializer extends Serializer {

  var javaBeanSupport = true

  var javadocSuffix = " is a Querydsl bean type"

  def serialize(model: EntityType, serializerConfig: SerializerConfig, writer: CodeWriter) {
    val simpleName = model.getSimpleName

    // package
    if (!model.getPackageName.isEmpty) writer.packageDecl(model.getPackageName)

    // imports
    val importedClasses = getAnnotationTypes(model)
    if (javaBeanSupport)  importedClasses.add("scala.reflect.BeanProperty")    
    if (model.hasLists()) importedClasses.add(classOf[List[_]].getName)
    if (model.hasMaps())  importedClasses.add(classOf[Map[_, _]].getName)

    writer.importClasses(importedClasses.toArray: _*)

    // javadoc        
    writer.javadoc(simpleName + javadocSuffix)

    // header
    model.getAnnotations foreach (writer.annotation(_))

    writer.beginClass(model)

    // properties
    model.getProperties foreach { property =>
      property.getAnnotations.foreach(writer.annotation(_))
      if (javaBeanSupport) writer.line("@BeanProperty")
      writer.publicField(property.getType(), property.getEscapedName, "_")
    }

    writer.end()
  }

  def getAnnotationTypes(model: EntityType): Set[String] = {
    val imports: Set[String] = Set()
    imports ++ model.getAnnotations.map(_.annotationType.getName);
    // flatMap flattens the results of the map-function.
    // E.g. List(List(1,2,3), List(4,5,6)).flatMap(_.map(_*3)) ends up as List(3, 6, 9, 12, 15, 18).
    imports ++ model.getProperties.flatMap(_.getAnnotations.map(_.annotationType.getName));
  }

}<commit_msg>fixed annotation handling issue<commit_after>package com.mysema.query.scala

import com.mysema.query.codegen._
import com.mysema.codegen.CodeWriter
import com.mysema.query

import java.util._
import java.io.IOException

import scala.reflect.BeanProperty
import scala.collection.JavaConversions._
import scala.collection.mutable.Set

/**
 * BeanSerializer for Scala
 * 
 * @author tiwe
 *
 */
class ScalaBeanSerializer extends Serializer {

  var javaBeanSupport = true

  var javadocSuffix = " is a Querydsl bean type"

  def serialize(model: EntityType, serializerConfig: SerializerConfig, writer: CodeWriter) {
    val simpleName = model.getSimpleName

    // package
    if (!model.getPackageName.isEmpty) writer.packageDecl(model.getPackageName)

    // imports
    val importedClasses = getAnnotationTypes(model)
    if (javaBeanSupport)  importedClasses.add("scala.reflect.BeanProperty")    
    if (model.hasLists()) importedClasses.add(classOf[List[_]].getName)
    if (model.hasMaps())  importedClasses.add(classOf[Map[_, _]].getName)

    writer.importClasses(importedClasses.toArray: _*)

    // javadoc        
    writer.javadoc(simpleName + javadocSuffix)

    // header
    model.getAnnotations foreach (writer.annotation(_))

    writer.beginClass(model)

    // properties
    model.getProperties foreach { property =>
      property.getAnnotations.foreach(writer.annotation(_))
      if (javaBeanSupport) writer.line("@BeanProperty")
      writer.publicField(property.getType(), property.getEscapedName, "_")
    }

    writer.end()
  }

  private def getAnnotationTypes(model: EntityType): Set[String] = {
    val imports = Set() ++ model.getAnnotations.map(_.annotationType.getName);
    // flatMap flattens the results of the map-function.
    // E.g. List(List(1,2,3), List(4,5,6)).flatMap(_.map(_*3)) ends up as List(3, 6, 9, 12, 15, 18).
    imports ++ model.getProperties.flatMap(_.getAnnotations.map(_.annotationType.getName));
  }
  
}
{'fraction_non_alphanumeric': 0.11961234378984953, 'fraction_numerical': 0.00816118337158888, 'mean_word_length': 3.97084917617237, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '5565269', 'n_tokens_mistral': 1249, 'n_tokens_neox': 1193, 'n_words': 234}