<commit_before>package com.github.webdriverextensions.internal.utils;

import com.google.common.base.Predicate;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.util.Set;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.remote.DesiredCapabilities;

public class WebDriverUtils {

    public static String convertToJsonString(Capabilities capabilities) {
        Gson gson = new GsonBuilder().setPrettyPrinting().create();
        return gson.toJson(capabilities.asMap());
    }

    public static Capabilities removeCapabilities(Capabilities capabilities, String... keysToRemove) {
        if (capabilities == null) {
            return new DesiredCapabilities();
        }

        final Set<String> keysToRemoveSet = Sets.newHashSet(keysToRemove);
        capabilities = new DesiredCapabilities(Maps.filterKeys(capabilities.asMap(), new Predicate<String>() {
            @Override
            public boolean apply(String key) {
                return !keysToRemoveSet.contains(key);
            }
        }));

        return capabilities;
    }
}<commit_msg>Added addCapabilities method to WebDriverUtils<commit_after>package com.github.webdriverextensions.internal.utils;

import com.google.common.base.Predicate;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.util.Map;
import java.util.Set;
import org.openqa.selenium.Capabilities;
import org.openqa.selenium.remote.DesiredCapabilities;

public class WebDriverUtils {

    public static String convertToJsonString(Capabilities capabilities) {
        Gson gson = new GsonBuilder().setPrettyPrinting().create();
        return gson.toJson(capabilities.asMap());
    }

    public static Capabilities removeCapabilities(Capabilities capabilities, String... keysToRemove) {
        if (capabilities == null) {
            return new DesiredCapabilities();
        }

        final Set<String> keysToRemoveSet = Sets.newHashSet(keysToRemove);
        capabilities = new DesiredCapabilities(Maps.filterKeys(capabilities.asMap(), new Predicate<String>() {
            @Override
            public boolean apply(String key) {
                return !keysToRemoveSet.contains(key);
            }
        }));

        return capabilities;
    }

    public static Capabilities addCapabilities(Capabilities capabilities, Map<String, Object> capabilitiesToAdd) {
        if (capabilities == null && capabilitiesToAdd == null) {
            return new DesiredCapabilities();
        }

        if (capabilities == null) {
            return new DesiredCapabilities(capabilitiesToAdd);
        }

        if (capabilitiesToAdd == null) {
            return capabilities;
        }

        return new DesiredCapabilities(capabilities, new DesiredCapabilities(capabilitiesToAdd));
    }
}
{'fraction_non_alphanumeric': 0.0951417004048583, 'fraction_numerical': 0.0, 'mean_word_length': 3.2478510028653296, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '1376644', 'n_tokens_mistral': 803, 'n_tokens_neox': 791, 'n_words': 164}