<commit_before>package com.test.myapplication.model.validator;

import android.support.annotation.NonNull;

import java.lang.reflect.Field;
import java.util.List;

/**
 * Created by Indigo on 3/22/17.
 */

public class ModelValidator {

    private Object model;

    public ModelValidator(@NonNull Object model)  {
        this.model = model;
    }

    public void validate() throws IllegalArgumentException {

        if (model == null) {
            throw new IllegalArgumentException("Model cannot be null");
        }

        final Field[] modelFields = model.getClass().getFields();

        for (Field modelField : modelFields) {

            modelField.setAccessible(true);

            if (!modelField.isAnnotationPresent(IsDefined.class)) {
                continue;
            }

            try {
                Object modelAttribute = modelField.get(model);

                if (modelAttribute == null) {
                    throw new IllegalArgumentException(modelField + " is required");

                } else if (modelAttribute instanceof List) {
                    validateItemsFromListAttribute((List)modelAttribute);

                } else if (!(modelAttribute instanceof Boolean)) {
                    validateInnerAttribte(modelAttribute);
                }
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }

        }
    }

    private void validateItemsFromListAttribute(@NonNull final List attributes) throws IllegalArgumentException{
        for (Object objectFromList : attributes) {
            ModelValidator itemListValidator = new ModelValidator(objectFromList);
            itemListValidator.validate();
        }
    }

    private void validateInnerAttribte(@NonNull final Object innerAttribute) throws IllegalArgumentException {
        ModelValidator innerAttributeValidator = new ModelValidator(innerAttribute);
        innerAttributeValidator.validate();
    }

}<commit_msg>Model validator simplification<commit_after>package com.test.myapplication.model.validator;

import android.support.annotation.NonNull;

import java.lang.reflect.Field;

/**
 * Created by Indigo on 3/22/17.
 */

public class ModelValidator {

    private Object model;

    public ModelValidator(@NonNull Object model)  {
        this.model = model;
    }

    public void validate() throws IllegalArgumentException {

        if (model == null) {
            throw new IllegalArgumentException("Model cannot be null");
        }

        final Field[] modelFields = model.getClass().getFields();

        for (Field modelField : modelFields) {

            modelField.setAccessible(true);

            if (modelField.isAnnotationPresent(IsDefined.class)) {

                try {
                    Object modelAttribute = modelField.get(model);

                    if (modelAttribute == null) {
                        throw new IllegalArgumentException(modelField + " is required");
                    }
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                }
            }

        }
    }

}
{'fraction_non_alphanumeric': 0.0847457627118644, 'fraction_numerical': 0.0031979533098816758, 'mean_word_length': 2.128, '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': '1696918', 'n_tokens_mistral': 746, 'n_tokens_neox': 706, 'n_words': 177}