<commit_before>/*
 * Copyright 2015-2018 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.guerinet.fg

import android.graphics.Typeface
import android.support.v7.widget.SwitchCompat
import android.view.View
import android.widget.CompoundButton
import com.guerinet.fg.base.BaseTextViewItem

/**
 * Form item with a [SwitchCompat]
 * @author <NAME>
 * @since 2.0.0
 */
class SwitchItem(fg: FormGenerator, view: View) :
        BaseTextViewItem<SwitchItem, SwitchCompat>(fg, view, view.findViewById(R.id.fg_switch), true) {

    /**
     * @return Item with the switch on if [isChecked]
     */
    fun isChecked(isChecked: Boolean): SwitchItem {
        childView.isChecked = isChecked
        return this
    }

    /**
     * @return Item with the [listener] set on the switch
     */
    fun onCheckChanged(listener: CompoundButton.OnCheckedChangeListener?): SwitchItem {
        childView.setOnCheckedChangeListener(listener)
        return this
    }

    /**
     * Sets the [textOn] and [textOff] texts if not null (both default to null) on the returned item
     */
    fun switchText(textOn: String? = null, textOff: String? = null) {
        childView.showText = true
        if (textOn != null) {
            childView.textOn = textOn
        }
        if (textOff != null) {
            childView.textOff = textOff
        }
    }

    override fun typeface(typeface: Typeface?): SwitchItem {
        // Set the typeface on the switch as well
        childView.setSwitchTypeface(typeface)
        return super.typeface(typeface)
    }
}<commit_msg>Fixed some method return types.<commit_after>/*
 * Copyright 2015-2018 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.guerinet.fg

import android.graphics.Typeface
import android.support.v7.widget.SwitchCompat
import android.view.View
import android.widget.CompoundButton
import com.guerinet.fg.base.BaseTextViewItem

/**
 * Form item with a [SwitchCompat]
 * @author <NAME>
 * @since 2.0.0
 */
class SwitchItem(fg: FormGenerator, view: View) :
        BaseTextViewItem<SwitchItem, SwitchCompat>(fg, view, view.findViewById(R.id.fg_switch), true) {

    /**
     * @return Item with the switch on if [isChecked]
     */
    fun isChecked(isChecked: Boolean): SwitchItem {
        childView.isChecked = isChecked
        return this
    }

    /**
     * @return Item with the [listener] set on the switch
     */
    fun onCheckChanged(listener: CompoundButton.OnCheckedChangeListener?): SwitchItem {
        childView.setOnCheckedChangeListener(listener)
        return this
    }

    /**
     * Sets the [textOn] and [textOff] texts if not null (both default to null) on the returned item
     */
    fun switchText(textOn: String? = null, textOff: String? = null): SwitchItem {
        childView.showText = true
        if (textOn != null) {
            childView.textOn = textOn
        }
        if (textOff != null) {
            childView.textOff = textOff
        }
        return this
    }

    override fun typeface(typeface: Typeface?): SwitchItem {
        // Set the typeface on the switch as well
        childView.setSwitchTypeface(typeface)
        return super.typeface(typeface)
    }
}
{'fraction_non_alphanumeric': 0.09168241965973535, 'fraction_numerical': 0.007561436672967864, 'mean_word_length': 2.9085872576177287, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '6267109', 'n_tokens_mistral': 1197, 'n_tokens_neox': 1165, 'n_words': 401}