<commit_before>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.sudoku.data.manager;

import com.sudoku.data.model.AccessAction;
import com.sudoku.data.model.AccessRule;
import com.sudoku.data.model.AccessType;
import com.sudoku.data.model.Grid;
import com.sudoku.data.model.Ruleable;
import com.sudoku.data.model.User;
import java.util.ArrayList;
import java.util.HashMap;

/**
 *
 * @author JE
 */
public class AccessManager {
    
    private static AccessManager instance;
    private HashMap<Grid, ArrayList<AccessRule>> rules;
    
    private AccessManager(){
        this.rules = new HashMap<>();
    }
    
    public static AccessManager getInstance(){
        return instance;
    }

    /**
     * @return the rules
     */
    public HashMap<Grid, ArrayList<AccessRule>> getAllAccessRules() {
        return rules;
    }
    
    public ArrayList<AccessRule> getAllAccessRulesForGrid(Grid grid){
        return this.rules.get(grid);
    }
    
    private AccessRule getAccessRule(Grid grid, AccessAction accessAction, Ruleable appliedTo){
        
        ArrayList<AccessRule> rulesList = this.rules.get(grid);
        if(rulesList == null){
            return null;
        }
        
        for(AccessRule ar : rulesList){
            if(ar.getAccessAction() == accessAction && ar.getAppliedTo().equals(appliedTo)){
                return ar;<commit_msg>Correction du singleton dans la classe AccessManager<commit_after>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.sudoku.data.manager;

import com.sudoku.data.model.AccessAction;
import com.sudoku.data.model.AccessRule;
import com.sudoku.data.model.AccessType;
import com.sudoku.data.model.Grid;
import com.sudoku.data.model.Ruleable;
import com.sudoku.data.model.User;
import java.util.ArrayList;
import java.util.HashMap;

/**
 *
 * @author JE
 */
public class AccessManager {
    
    private static AccessManager instance;
    private HashMap<Grid, ArrayList<AccessRule>> rules;
    
    private AccessManager(){
        this.rules = new HashMap<>();
    }
    
    public static AccessManager getInstance(){
        if(instance == null){
            instance = new AccessManager();
        }
        return instance;
    }

    /**
     * @return the rules
     */
    public HashMap<Grid, ArrayList<AccessRule>> getAllAccessRules() {
        return rules;
    }
    
    public ArrayList<AccessRule> getAllAccessRulesForGrid(Grid grid){
        return this.rules.get(grid);
    }
    
    private AccessRule getAccessRule(Grid grid, AccessAction accessAction, Ruleable appliedTo){
        
        ArrayList<AccessRule> rulesList = this.rules.get(grid);
        if(rulesList == null){
            return null;
        }
        
        for(AccessRule ar : rulesList){
            if(ar.getAccessAction() == accessAction && ar.getAppliedTo().equals(appliedTo)){
                return ar;
{'fraction_non_alphanumeric': 0.1018020866266203, 'fraction_numerical': 0.0, 'mean_word_length': 2.8166465621230397, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '5518279', 'n_tokens_mistral': 889, 'n_tokens_neox': 879, 'n_words': 224}