package helpers;

import helpers.PublicProperty;
import objects.tasks.Task;

import java.lang.reflect.Field;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class DBObjectUtils
{
    public static String[] getPublicFields(Class<Task> taskClass)
    {
        Field[] declaredFields = taskClass.getDeclaredFields();
        List<String> publicFieldsNames = Stream.of(declaredFields)
                .filter(field -> field.getAnnotation(PublicProperty.class) != null)
                .map(Field::getName)
                .collect(Collectors.toList());

        return publicFieldsNames.toArray(new String[publicFieldsNames.size()]);
    }
}
