<commit_before>package de.sebastian_daschner.todos.business.tasks.boundary;

import de.sebastian_daschner.todos.business.tasks.entity.Filter;
import de.sebastian_daschner.todos.business.tasks.entity.Task;

import javax.ejb.ConcurrencyManagement;
import javax.ejb.ConcurrencyManagementType;
import javax.ejb.Singleton;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Collectors;

@Singleton
@ConcurrencyManagement(ConcurrencyManagementType.BEAN)
public class TaskStore {

    private Map<Long, Task> tasks = new ConcurrentHashMap<>();

    private AtomicLong next = new AtomicLong(0L);

    public List<Task> listAll() {
        return new LinkedList<>(tasks.values());
    }

    public List<Task> filterAll(final Filter filter) {
        final List<Task> filteredTasks = tasks.values().stream().filter(t -> matches(t, filter)).collect(Collectors.toList());

        return filteredTasks;
    }

    public Task get(long taskId) {
        return tasks.get(taskId);
    }

    public long save(Task task) {
        final long taskId = next.getAndIncrement();
        task.setId(taskId);
        task.setUpdated(new Date());

        tasks.put(taskId, task);

        return taskId;
    }

    public void update(long taskId, Task task) {
        task.setId(taskId);
        task.setUpdated(new Date());

        tasks.put(taskId, task);
    }

    public void delete(long taskId) {
        tasks.remove(taskId);
    }

    private static boolean matches(Task task, Filter filter) {
        if (filter.getText() != null && task.getName().toLowerCase().indexOf(filter.getText()) < 0) {
            return false;
        }
        if (!filter.getContexts().isEmpty() && task.getContexts().stream().noneMatch(c -> filter.getContexts().contains(c))) {
            return false;
        }
        if (filter.getPriorityThreshold() != null && filter.getPriorityThreshold().equals(task.getPriority())) {
            return false;
        }
        return true;
    }


}<commit_msg>updated priority filter<commit_after>package de.sebastian_daschner.todos.business.tasks.boundary;

import de.sebastian_daschner.todos.business.tasks.entity.Filter;
import de.sebastian_daschner.todos.business.tasks.entity.Task;

import javax.ejb.ConcurrencyManagement;
import javax.ejb.ConcurrencyManagementType;
import javax.ejb.Singleton;
import java.util.Date;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
import java.util.stream.Collectors;

@Singleton
@ConcurrencyManagement(ConcurrencyManagementType.BEAN)
public class TaskStore {

    private Map<Long, Task> tasks = new ConcurrentHashMap<>();

    private AtomicLong next = new AtomicLong(0L);

    public List<Task> listAll() {
        return new LinkedList<>(tasks.values());
    }

    public List<Task> filterAll(final Filter filter) {
        final List<Task> filteredTasks = tasks.values().stream().filter(t -> matches(t, filter)).collect(Collectors.toList());

        return filteredTasks;
    }

    public Task get(long taskId) {
        return tasks.get(taskId);
    }

    public long save(Task task) {
        final long taskId = next.getAndIncrement();
        task.setId(taskId);
        task.setUpdated(new Date());

        tasks.put(taskId, task);

        return taskId;
    }

    public void update(long taskId, Task task) {
        task.setId(taskId);
        task.setUpdated(new Date());

        tasks.put(taskId, task);
    }

    public void delete(long taskId) {
        tasks.remove(taskId);
    }

    private static boolean matches(Task task, Filter filter) {
        if (filter.getText() != null && task.getName().toLowerCase().indexOf(filter.getText()) < 0) {
            return false;
        }
        if (!filter.getContexts().isEmpty() && task.getContexts().stream().noneMatch(c -> filter.getContexts().contains(c))) {
            return false;
        }
        if (filter.getPriorityThreshold() != null) {
            if (task.getPriority() == null || filter.getPriorityThreshold().compareTo(task.getPriority()) >= 0) {
                return false;
            }
        }
        return true;
    }


}
{'fraction_non_alphanumeric': 0.12448418156808803, 'fraction_numerical': 0.0011462631820265932, 'mean_word_length': 3.100563909774436, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 20, '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': '3526515', 'n_tokens_mistral': 1293, 'n_tokens_neox': 1269, 'n_words': 258}