<commit_before>/*
 * Copyright 2014 <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 io.reinert.requestor.form;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;

import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.dom.client.FormElement;

/**
 * Represents FormData interface.
 *
 * @author <NAME>
 */
public class FormData implements Iterable<FormData.Param> {

    private final FormElement formElement;
    private final ArrayList<Param> params;

    private FormData(ArrayList<Param> params) {
        this.formElement = null;
        this.params = params;
    }

    private FormData(FormElement formElement) {
        this.formElement = formElement;
        this.params = null;
    }

    public static FormData wrap(FormElement formElement) {
        return new FormData(formElement);
    }

    public static FormData.Builder builder() {
        return new FormData.Builder();
    }

    public FormElement getFormElement() {
        return formElement;
    }

    @Override
    public Iterator<Param> iterator() {
        return params == null ? Collections.<Param>emptyIterator() : params.iterator();
    }

    static class Builder {

        private final ArrayList<Param> params = new ArrayList<Param>();

        public Builder append(String name, String value) {
            params.add(new Param(name, value));
            return this;
        }

        public Builder append(String name, int value) {
            params.add(new Param(name, String.valueOf(value)));
            return this;
        }

        public Builder append(String name, double value) {
            params.add(new Param(name, String.valueOf(value)));
            return this;
        }

        public Builder append(String name, boolean value) {
            params.add(new Param(name, String.valueOf(value)));
            return this;
        }<commit_msg>Fixed some bugs in FormData.<commit_after>/*
 * Copyright 2014 <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 io.reinert.requestor.form;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;

import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.dom.client.FormElement;

/**
 * Represents FormData interface.
 *
 * @author <NAME>
 */
public class FormData implements Iterable<FormData.Param> {

    private final FormElement formElement;
    private final ArrayList<Param> params;

    private FormData(ArrayList<Param> params) {
        this.formElement = null;
        this.params = params;
    }

    private FormData(FormElement formElement) {
        this.formElement = formElement;
        this.params = null;
    }

    public static FormData wrap(FormElement formElement) {
        return new FormData(formElement);
    }

    public static FormData.Builder builder() {
        return new FormData.Builder();
    }

    public FormElement getFormElement() {
        return formElement;
    }

    @Override
    public Iterator<Param> iterator() {
        return params == null ? Collections.<Param>emptyIterator() : params.iterator();
    }

    public static class Builder {

        private final ArrayList<Param> params = new ArrayList<Param>();

        private Builder() {
        }

        public Builder append(String name, String value) {
            params.add(new Param(name, value));
            return this;
        }

        public Builder append(String name, int value) {
            params.add(new Param(name, String.valueOf(value)));
            return this;
        }

        public Builder append(String name, double value) {
            params.add(new Param(name, String.valueOf(value)));
            return this;
        }

        public Builder append(String name, boolean value) {
            params.add(new Param(name, String.valueOf(value)));
            return this;
        }

        public Builder append(String name, Iterable<?> values) {
            for (Object value : values) {
                params.add(new Param(name, value.toString()));
            }
            return this;
        }
{'fraction_non_alphanumeric': 0.09263934744610604, 'fraction_numerical': 0.003107399495047582, 'mean_word_length': 2.670705630791162, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 22, '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': '833692', 'n_tokens_mistral': 1342, 'n_tokens_neox': 1307, 'n_words': 438}