Java tutorial
//package com.java2s; import java.util.Map; public class Main { public static <T> T getMapOnlyValue(Map<? extends Object, T> map) { if (map.size() != 1) { throw new IllegalArgumentException("Can't get map only value, it has " + map.size() + " elements"); } return map.values().iterator().next(); } }