class Test { static class TKey {} public interface Getter { T getValue(TKey key); } public static > TK getAKey(TK tKeySuffix) { return tKeySuffix; } static final TKey KEY_D = new TKey<>(); public static void f(Getter getter) { double d1 = getter.getValue(KEY_D); double d2 = getter.getValue(getAKey(KEY_D)); TKey aKey = getAKey(KEY_D); double d3 = getter.getValue(aKey); } }