<commit_before>package com.t28.rxweather.util;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

public class CollectionUtils {
    private CollectionUtils() {
    }

    public static boolean isEmpty(List list) {
        if (list == null) {
            return true;
        }
        return list.isEmpty();
    }

    public static <T> List<T> newList(Iterator<T> iterator) {
        if (iterator == null) {
            return Collections.emptyList();
        }

        final List<T> list = new ArrayList<>();
        while (iterator.hasNext()) {
            final T element = iterator.next();
            list.add(element);
        }
        return list;
    }

    public static <T1, T2> T2 getValue(Map<T1, T2> map, T1 key, T2 defaultValue) {
        if (map == null) {
            return defaultValue;
        }

        final T2 value = map.get(key);
        if (value == null) {
            return defaultValue;
        }
        return value;
    }
}<commit_msg>getValueAsXxxの実装を追加<commit_after>package com.t28.rxweather.util;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

public class CollectionUtils {
    private CollectionUtils() {
    }

    public static boolean isEmpty(List list) {
        if (list == null) {
            return true;
        }
        return list.isEmpty();
    }

    public static <T> List<T> newList(Iterator<T> iterator) {
        if (iterator == null) {
            return Collections.emptyList();
        }

        final List<T> list = new ArrayList<>();
        while (iterator.hasNext()) {
            final T element = iterator.next();
            list.add(element);
        }
        return list;
    }

    public static <T1, T2> T2 getValue(Map<T1, T2> map, T1 key, T2 defaultValue) {
        if (map == null) {
            return defaultValue;
        }

        final T2 value = map.get(key);
        if (value == null) {
            return defaultValue;
        }
        return value;
    }

    public static long getValueAsLong(Map map, Object key, long defaultValue) {
        final Object value = getValue(map, key, null);
        if (value == null) {
            return defaultValue;
        }
        return Long.valueOf(value.toString());
    }

    public static String getValueAsString(Map map, Object key, String defaultValue) {
        final Object value = getValue(map, key, null);
        if (value == null) {
            return defaultValue;
        }
        return String.valueOf(value);
    }
}
{'fraction_non_alphanumeric': 0.10984416571645762, 'fraction_numerical': 0.007601672367920942, 'mean_word_length': 1.9841269841269842, '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': '2013040', 'n_tokens_mistral': 766, 'n_tokens_neox': 750, 'n_words': 208}