<commit_before>package ru.job4j.monitore;

import net.jcip.annotations.GuardedBy;
import net.jcip.annotations.ThreadSafe;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;

/**
 * class UserStorage.
 */
@ThreadSafe
public class UserStorage {
    /** storage to keep users.*/
    @GuardedBy("this") private TreeMap<Integer, User> storage = new TreeMap<>();

    /**
     * method add.
     * @param user - user.
     */
    public void add(User user) {
        synchronized (this) {
            storage.put(user.getId(), user);
        }
    }

    /**
     * method delete.
     * @param id - id.
     */
    public void delete(int id) {
        synchronized (this) {
            storage.remove(id);
        }
    }

    /**
     * method findUser.
     * @param id - id.
     * @return user.
     */
    public User findUser(int id) {
        return storage.get(id);
    }

    /**
     * method upDate.<commit_msg>task 1104 threadSafe userStorage remake<commit_after>package ru.job4j.monitore;

import net.jcip.annotations.GuardedBy;
import net.jcip.annotations.ThreadSafe;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;

/**
 * class UserStorage.
 */
@ThreadSafe
public class UserStorage {
    /** storage to keep users.*/
    @GuardedBy("this") private TreeMap<Integer, User> storage = new TreeMap<>();

    /**
     * method add.
     * @param user - user.
     */
    public void add(User user) {
        synchronized (this) {
            storage.put(user.getId(), user);
        }
    }

    /**
     * method delete.
     * @param id - id.
     */
    public void delete(int id) {
        synchronized (this) {
            storage.remove(id);
        }
    }

    /**
     * method findUser.
     * @param id - id.
     * @return user.
     */
    public User findUser(int id) {
        synchronized (this) {
            return storage.get(id);
        }
    }

    /**
     * method upDate.
{'fraction_non_alphanumeric': 0.13435897435897437, 'fraction_numerical': 0.003076923076923077, 'mean_word_length': 1.9250374812593702, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '2494530', 'n_tokens_mistral': 615, 'n_tokens_neox': 616, 'n_words': 143}