<commit_before>package com.novoda.sqlite.generator.model

import com.novoda.sqlite.generator.JavaHelper
import com.novoda.sqlite.model.Column
import com.novoda.sqlite.model.DataAffinity
import groovy.transform.CompileStatic

@CompileStatic
final class Field {
    String name
    String accessor
    String sqlName
    String getMethod
    String setMethod
    String type
    boolean optional
    String cursorType

    static Field fromColumn(Column column) {
        [name      : JavaHelper.javaName(column.name),
         accessor  : JavaHelper.javaAccessor(column.name),
         sqlName   : column.name,
         getMethod : getGetterPrefix(column) + column.camelizedName,
         setMethod : 'set' + column.camelizedName,
         type      : getDataType(column),
         optional  : column.nullable,
         cursorType: getCursorAccessor(column)] as Field
    }

    private static String getDataType(Column column) {
        switch (column.affinity) {
            case DataAffinity.INTEGER:
                return column.nullable ? "Integer" : "int"
            case DataAffinity.NONE:
                return "byte[]"
            case DataAffinity.TEXT:
                return "String"
            case DataAffinity.NUMERIC:
                if (column.boolean)
                    return column.nullable ? "Boolean" : "boolean"<commit_msg>use JavaHelper also for accessor methods<commit_after>package com.novoda.sqlite.generator.model

import com.novoda.sqlite.generator.JavaHelper
import com.novoda.sqlite.model.Column
import com.novoda.sqlite.model.DataAffinity
import groovy.transform.CompileStatic

@CompileStatic
final class Field {
    String name
    String accessor
    String sqlName
    String getMethod
    String setMethod
    String type
    boolean optional
    String cursorType

    static Field fromColumn(Column column) {
        [name      : JavaHelper.javaName(column.name),
         accessor  : JavaHelper.javaAccessor(column.name),
         sqlName   : column.name,
         getMethod : getGetterPrefix(column) + JavaHelper.javaAccessor(column.name),
         setMethod : 'set' + JavaHelper.javaAccessor(column.name),
         type      : getDataType(column),
         optional  : column.nullable,
         cursorType: getCursorAccessor(column)] as Field
    }

    private static String getDataType(Column column) {
        switch (column.affinity) {
            case DataAffinity.INTEGER:
                return column.nullable ? "Integer" : "int"
            case DataAffinity.NONE:
                return "byte[]"
            case DataAffinity.TEXT:
                return "String"
            case DataAffinity.NUMERIC:
                if (column.boolean)
                    return column.nullable ? "Boolean" : "boolean"
{'fraction_non_alphanumeric': 0.07750814922129663, 'fraction_numerical': 0.0, 'mean_word_length': 2.3600973236009732, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5147382', 'n_tokens_mistral': 738, 'n_tokens_neox': 727, 'n_words': 170}