<commit_before>package com.softteco.toolset.bl;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;

/**
 *
 * @author serge
 */
public abstract class AutofillAbstractAssembler<E, D> extends AbstractAssembler<E, D> {

    @Override
    protected Class<D> getDtoClass() {
        final ParameterizedType superclass = (ParameterizedType) getClass().getGenericSuperclass();
        return (Class<D>) superclass.getActualTypeArguments()[1];
    }

    @Override
    public void assemble(D dto, E entity) {
        if (entity == null) {
            return;
        }

        final Class entityClass = entity.getClass();
        for (Field each : getDtoClass().getFields()) {
            try {
                Method method = null;
                if (each.getType().equals(boolean.class)) {
                    method = entityClass.getMethod("is" + each.getName().substring(0, 1).toUpperCase() + each.getName().substring(1));
                } else {
                    method = entityClass.getMethod("get" + each.getName().substring(0, 1).toUpperCase() + each.getName().substring(1));
                }

                try {
                    each.set(dto, method.invoke(entity));
                } catch (IllegalAccessException e) {
                    e.printStackTrace(System.out);
                } catch (InvocationTargetException e) {
                    e.printStackTrace(System.out);
                }
            } catch (NoSuchMethodException e) {
                System.out.println("Skipped field " + each.getName());
            }
        }
    }

    public void disassemble(E entity, D dto) {
        final Class entityClass = entity.getClass();
        for (Field each : getDtoClass().getFields()) {
            Method method = null;
            try {
                method = entityClass.getMethod("set" + each.getName().substring(0, 1).toUpperCase() + each.getName().substring(1), each.getType());
            } catch (NoSuchMethodException e) {
                e.printStackTrace(System.out);
            }

            try {
                method.invoke(entity, each.get(dto));
            } catch (IllegalAccessException e) {
                e.printStackTrace(System.out);
            } catch (InvocationTargetException e) {
                e.printStackTrace(System.out);
            }
        }
    }
}<commit_msg>no message<commit_after>package com.softteco.toolset.bl;

import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;

/**
 *
 * @author serge
 */
public abstract class AutofillAbstractAssembler<E, D> extends AbstractAssembler<E, D> {

    @Override
    protected Class<D> getDtoClass() {
        final ParameterizedType superclass = (ParameterizedType) getClass().getGenericSuperclass();
        return (Class<D>) superclass.getActualTypeArguments()[1];
    }

    @Override
    public void assemble(D dto, E entity) {
        if (entity == null) {
            return;
        }

        final Class entityClass = entity.getClass();
        for (Field each : getDtoClass().getFields()) {
            try {
                final Method method;
                if (each.getType().equals(boolean.class)) {
                    method = entityClass.getMethod("is" + each.getName().substring(0, 1).toUpperCase() + each.getName().substring(1));
                } else {
                    method = entityClass.getMethod("get" + each.getName().substring(0, 1).toUpperCase() + each.getName().substring(1));
                }

                try {
                    each.set(dto, method.invoke(entity));
                } catch (IllegalAccessException e) {
                    e.printStackTrace(System.out);
                } catch (InvocationTargetException e) {
                    e.printStackTrace(System.out);
                }
            } catch (NoSuchMethodException e) {
                System.out.println("Skipped field " + each.getName());
            }
        }
    }

    public void disassemble(E entity, D dto) {
        final Class entityClass = entity.getClass();
        for (Field each : getDtoClass().getFields()) {
            try {
                final Method method = entityClass.getMethod("set" + each.getName().substring(0, 1).toUpperCase() + each.getName().substring(1), each.getType());

                try {
                    method.invoke(entity, each.get(dto));
                } catch (IllegalAccessException e) {
                    e.printStackTrace(System.out);
                } catch (InvocationTargetException e) {
                    e.printStackTrace(System.out);
                }
            } catch (NoSuchMethodException e) {
                System.out.println("Skipped field " + each.getName());
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.11973978450904656, 'fraction_numerical': 0.004065867046147591, 'mean_word_length': 1.9043683589138134, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '5530243', 'n_tokens_mistral': 1321, 'n_tokens_neox': 1274, 'n_words': 250}