Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class Main {
    /**
     * 
     * Turns a column of the resultset's value into Set
     * 
     * @param results
     * @param key
     *          key to get the value from the result set
     * @return null if results is null
     */
    public static Set<String> turnMapResultToSet(List<? extends Map<?, ?>> results, String key) {

        if (results == null)
            return null;

        Set<String> set = new HashSet<String>(results.size());
        for (Map<?, ?> map : results) {
            set.add((String) map.get(key));
        }
        return set;
    }
}