Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.LinkedHashMap;

import java.util.Map;
import java.util.Map.Entry;

public class Main {
    public static <G> Map<String, G> transferRootNameMap(Map<Integer, Integer> rootIdIdMap,
            Map<Integer, G> idValueMap, G defaultValue) {
        Map<String, G> rootValueMap = new LinkedHashMap<String, G>();
        for (Entry<Integer, Integer> entry : rootIdIdMap.entrySet()) {
            if (idValueMap.containsKey(entry.getValue())) {
                rootValueMap.put(entry.getKey().toString(), idValueMap.get(entry.getValue()));
            } else {
                rootValueMap.put(entry.getKey().toString(), defaultValue);
            }
        }
        return rootValueMap;
    }
}