package nl.jft.logic.statistic.impl;

import nl.jft.logic.participant.Title;
import nl.jft.logic.statistic.AbstractStatistic;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;

/**
 * A {@code TitleStatistic} is a {@link nl.jft.logic.statistic.Statistic} which keeps track of {@link Title titles}.
 *
 * @author Lesley
 */
public class TitleStatistic extends AbstractStatistic<Title> {

    private final List<Title> titles = new ArrayList<>();

    /**
     * Adds a {@link Title} to this {@code TitleStatistic}.
     *
     * @param title The {@code Title} to add, should not be {@code null}.
     */
    public void addTitle(Title title) {
        titles.add(Objects.requireNonNull(title));
    }

    /**
     * Removes a {@link Title} from this {@code TitleStatistic}, given that it was added in the first place.
     *
     * @param title The {@code Title} to remove, should not be {@code null}.
     */
    public void removeTitle(Title title) {
        titles.remove(Objects.requireNonNull(title));
    }

    @Override
    public List<Title> getValues() {
        synchronized (titles) {
            return Collections.unmodifiableList(titles);
        }
    }

}

@@ -706,19 +706,8 @@
     
-titles.add(
 Obje
@@ -723,34 +723,107 @@
 reNonNull(title)
-)
 ;
+%0A%0A        synchronized (titles) %7B%0A            titles.add(title);%0A        %7D
 %0A    %7D%0A%0A    /**%0A
@@ -1078,22 +1078,8 @@
     
-titles.remove(
 Obje
@@ -1103,18 +1103,94 @@
 l(title)
-)
 ;
+%0A%0A        synchronized (titles) %7B%0A            titles.remove(title);%0A        %7D
 %0A    %7D%0A%0A

Fix synchronization in TitleStatistic.