@Test public void matchingLabels() { Task task = mockTask(taskLabelName, taskLabelValues); User user = mockUser(userLabelName, userLabelValues); assertThat(TaskHelper.countMatchingLabels(task, user, taskLabelName)).isEqualTo(matchingLabelsResult); }
public static int countMatchingLabels(Task task, User user, String labelName) { final Set<Object> taskLabelValues = task.getLabelValues(labelName); if (taskLabelValues == null || taskLabelValues.isEmpty()) { return 0; } final Set<Object> userLabelValues = user.getLabelValues(labelName); if (userLabelValues == null) { return 0; } return Math.toIntExact(userLabelValues.stream().filter(taskLabelValues::contains).count()); }
TaskHelper { public static int countMatchingLabels(Task task, User user, String labelName) { final Set<Object> taskLabelValues = task.getLabelValues(labelName); if (taskLabelValues == null || taskLabelValues.isEmpty()) { return 0; } final Set<Object> userLabelValues = user.getLabelValues(labelName); if (userLabelValues == null) { return 0; } return Math.toIntExact(userLabelValues.stream().filter(taskLabelValues::contains).count()); } }
TaskHelper { public static int countMatchingLabels(Task task, User user, String labelName) { final Set<Object> taskLabelValues = task.getLabelValues(labelName); if (taskLabelValues == null || taskLabelValues.isEmpty()) { return 0; } final Set<Object> userLabelValues = user.getLabelValues(labelName); if (userLabelValues == null) { return 0; } return Math.toIntExact(userLabelValues.stream().filter(taskLabelValues::contains).count()); } private  TaskHelper(); }
TaskHelper { public static int countMatchingLabels(Task task, User user, String labelName) { final Set<Object> taskLabelValues = task.getLabelValues(labelName); if (taskLabelValues == null || taskLabelValues.isEmpty()) { return 0; } final Set<Object> userLabelValues = user.getLabelValues(labelName); if (userLabelValues == null) { return 0; } return Math.toIntExact(userLabelValues.stream().filter(taskLabelValues::contains).count()); } private  TaskHelper(); static boolean isPotentialOwner(Task task, User user); static boolean hasAllLabels(Task task, User user, String labelName); static int countMatchingLabels(Task task, User user, String labelName); static List<Task> extractTasks(TaskOrUser taskOrUser); static List<Task> extractTasks(TaskOrUser taskOrUser, Predicate<Task> predicate); static boolean hasPinnedTasks(TaskOrUser user); }
TaskHelper { public static int countMatchingLabels(Task task, User user, String labelName) { final Set<Object> taskLabelValues = task.getLabelValues(labelName); if (taskLabelValues == null || taskLabelValues.isEmpty()) { return 0; } final Set<Object> userLabelValues = user.getLabelValues(labelName); if (userLabelValues == null) { return 0; } return Math.toIntExact(userLabelValues.stream().filter(taskLabelValues::contains).count()); } private  TaskHelper(); static boolean isPotentialOwner(Task task, User user); static boolean hasAllLabels(Task task, User user, String labelName); static int countMatchingLabels(Task task, User user, String labelName); static List<Task> extractTasks(TaskOrUser taskOrUser); static List<Task> extractTasks(TaskOrUser taskOrUser, Predicate<Task> predicate); static boolean hasPinnedTasks(TaskOrUser user);  }