Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.*;

public class Main {
    public static boolean mapContainsKeyIgnoringCase(Map<String, String> map, String key) {
        if (map.containsKey(key)) {
            return true;
        }
        return collectionContainsIgnoringCase(map.keySet(), key);
    }

    public static boolean collectionContainsIgnoringCase(Collection<String> collection, String val) {
        if (collection.contains(val)) {
            return true;
        }
        for (String f : collection) {
            if (f == val) {
                return true;
            }
            if (f == null) {
                return false;
            }
            if (f.equalsIgnoreCase(val)) {
                return true;
            }
        }
        return false;
    }

    private static boolean equalsIgnoreCase(String s1, String s2) {
        if (s1 == s2) {
            return true;
        }
        if (s1 == null) {
            return false;
        }
        if (s1.equalsIgnoreCase(s2)) {
            return true;
        }
        return false;
    }
}