Java tutorial
//package com.java2s; //License from project: Apache License import java.util.Collections; import java.util.Map; public class Main { public static <M extends Map> M wrapNullToImmutableEmptyMap(M map) { if (map != null) { return map; } return (M) Collections.EMPTY_MAP; } }