<commit_before>/**
 *
 * Copyright 2020 <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 org.jivesoftware.smackx.softwareinfo.form;

import java.util.List;

import org.jivesoftware.smack.util.EqualsUtil;
import org.jivesoftware.smack.util.HashCode;
import org.jivesoftware.smackx.mediaelement.element.MediaElement;
import org.jivesoftware.smackx.xdata.FormField;
import org.jivesoftware.smackx.xdata.FormFieldChildElement;
import org.jivesoftware.smackx.xdata.TextSingleFormField;
import org.jivesoftware.smackx.xdata.form.FilledForm;
import org.jivesoftware.smackx.xdata.form.Form;
import org.jivesoftware.smackx.xdata.packet.DataForm;
import org.jivesoftware.smackx.xdata.packet.DataForm.Type;

/**
 * {@link Form} that contains the software information.
 * <br>
 * Instance of {@link SoftwareInfoForm} can be created using {@link Builder#build()} method.
 * <br>
 * To obtain an instance of {@link Builder}, use {@link SoftwareInfoForm#getBuilder()} method.
 * <br>
 * An example to illustrate is provided inside SoftwareInfoFormTest inside the test package.
 */
public final class SoftwareInfoForm extends FilledForm {

    public static final String FORM_TYPE = "urn:xmpp:dataforms:softwareinfo";
    public static final String OS = "os";
    public static final String OS_VERSION = "os_version";
    public static final String SOFTWARE = "software";
    public static final String SOFTWARE_VERSION = "software_version";
    public static final String ICON = "icon";

    private SoftwareInfoForm(DataForm dataForm) {
        super(dataForm);
    }

    /**
     * Returns name of the OS used by client.
     * <br>
     * @return os
     */
    public String getOS() {
        return readFirstValue(OS);
    }

    /**
     * Returns version of the OS used by client.
     * <br>
     * @return os_version
     */
    public String getOSVersion() {
        return readFirstValue(OS_VERSION);
    }

    /**
     * Returns name of the software used by client.
     * <br><commit_msg>[softwareinfo] Register urn:xmpp:dataforms:softwareinfo's field types<commit_after>/**
 *
 * Copyright 2020 <NAME>, 2021 <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 org.jivesoftware.smackx.softwareinfo.form;

import java.util.List;

import org.jivesoftware.smack.util.EqualsUtil;
import org.jivesoftware.smack.util.HashCode;
import org.jivesoftware.smackx.formtypes.FormFieldRegistry;
import org.jivesoftware.smackx.mediaelement.element.MediaElement;
import org.jivesoftware.smackx.xdata.FormField;
import org.jivesoftware.smackx.xdata.FormFieldChildElement;
import org.jivesoftware.smackx.xdata.TextSingleFormField;
import org.jivesoftware.smackx.xdata.form.FilledForm;
import org.jivesoftware.smackx.xdata.form.Form;
import org.jivesoftware.smackx.xdata.packet.DataForm;
import org.jivesoftware.smackx.xdata.packet.DataForm.Type;

/**
 * {@link Form} that contains the software information.
 * <br>
 * Instance of {@link SoftwareInfoForm} can be created using {@link Builder#build()} method.
 * <br>
 * To obtain an instance of {@link Builder}, use {@link SoftwareInfoForm#getBuilder()} method.
 * <br>
 * An example to illustrate is provided inside SoftwareInfoFormTest inside the test package.
 */
public final class SoftwareInfoForm extends FilledForm {

    public static final String FORM_TYPE = "urn:xmpp:dataforms:softwareinfo";
    public static final String OS = "os";
    public static final String OS_VERSION = "os_version";
    public static final String SOFTWARE = "software";
    public static final String SOFTWARE_VERSION = "software_version";
    public static final String ICON = "icon";

    static {
        FormFieldRegistry.register(FORM_TYPE, FormField.Type.text_single,
                        OS, OS_VERSION, SOFTWARE, SOFTWARE_VERSION);
    }

    private SoftwareInfoForm(DataForm dataForm) {
        super(dataForm);
    }

    /**
     * Returns name of the OS used by client.
     * <br>
     * @return os
     */
    public String getOS() {
        return readFirstValue(OS);
    }

    /**
     * Returns version of the OS used by client.
     * <br>
     * @return os_version
     */
    public String getOSVersion() {
        return readFirstValue(OS_VERSION);
    }

    /**
     * Returns name of the software used by client.
     * <br>
{'fraction_non_alphanumeric': 0.09410217881292261, 'fraction_numerical': 0.003756574004507889, 'mean_word_length': 3.6875, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 18, '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': '381603', 'n_tokens_mistral': 1574, 'n_tokens_neox': 1539, 'n_words': 488}