<commit_before>package com.github.appreciated.quickstart.base.navigation;


import com.github.appreciated.quickstart.base.registration.Field;
import com.github.appreciated.quickstart.base.registration.FieldPropertySet;
import com.vaadin.data.Binder;
import com.vaadin.data.HasValue;
import com.vaadin.ui.TextField;
import javafx.util.Pair;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * Created by Johannes on 05.03.2017.
 */
public interface RegistrationControl<T> {
    void onUserDataEntered(T user);

    default Stream<java.lang.reflect.Field> getAttributes() {
        return Arrays.stream(getUser().getClass().getDeclaredFields()).filter(field -> field.isAnnotationPresent(Field.class));
    }

    T getUser();

    public default List<Pair<HasValue, java.lang.reflect.Field>> getFields() {
        Stream<java.lang.reflect.Field> fields = getAttributes();
        return fields.map(field -> {
            TextField textField = new TextField();
            textField.setData(field);
            textField.setCaption(field.getAnnotation(Field.class).caption());
            return new Pair<HasValue, java.lang.reflect.Field>(textField, field);
        }).collect(Collectors.toList());
    }

    public default Binder<T> getBinderForFields(List<Pair<HasValue, java.lang.reflect.Field>> components) {
        Binder<T> binder = new Binder<T>().withPropertySet(new FieldPropertySet<T>((Class<T>) getUser().getClass()));
        binder.setBean(getUser());
        components.forEach(pairConsumer -> binder.bind(pairConsumer.getKey(),pairConsumer.getValue().getName()));
        return binder;
    }
}<commit_msg>Fixed for required fields<commit_after>package com.github.appreciated.quickstart.base.navigation;


import com.github.appreciated.quickstart.base.registration.Field;
import com.github.appreciated.quickstart.base.registration.FieldPropertySet;
import com.vaadin.data.Binder;
import com.vaadin.data.HasValue;
import com.vaadin.ui.TextField;
import javafx.util.Pair;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * Created by Johannes on 05.03.2017.
 */
public interface RegistrationControl<T> {
    void onUserDataEntered(T user);

    default Stream<java.lang.reflect.Field> getAttributes() {
        return Arrays.stream(getUser().getClass().getDeclaredFields()).filter(field -> field.isAnnotationPresent(Field.class));
    }

    T getUser();

    public default List<Pair<HasValue, java.lang.reflect.Field>> getFields() {
        Stream<java.lang.reflect.Field> fields = getAttributes();
        return fields.map(field -> {
            TextField textField = new TextField();
            textField.setData(field);
            Field annotation = field.getAnnotation(Field.class);
            textField.setCaption(annotation.caption());
            textField.setRequiredIndicatorVisible(annotation.required());
            return new Pair<HasValue, java.lang.reflect.Field>(textField, field);
        }).collect(Collectors.toList());
    }

    public default Binder<T> getBinderForFields(List<Pair<HasValue, java.lang.reflect.Field>> components) {
        Binder<T> binder = new Binder<T>().withPropertySet(new FieldPropertySet<T>((Class<T>) getUser().getClass()));
        binder.setBean(getUser());
        components.forEach(pairConsumer -> binder.bind(pairConsumer.getKey(),pairConsumer.getValue().getName()));
        return binder;
    }
}
{'fraction_non_alphanumeric': 0.1327836224054592, 'fraction_numerical': 0.004549331816889394, 'mean_word_length': 4.004267425320057, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 35, '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': '6276799', 'n_tokens_mistral': 1040, 'n_tokens_neox': 1002, 'n_words': 167}