public static < T extends Enum < T > > @ NonNull NameMap < T > create ( final T @ NonNull [ ] constants , final @ NonNull Function < T , String > namer ) { final Map < String , T > byName = new HashMap <> ( constants . length ) ; final Map < T , String > byValue = new HashMap <> ( constants . length ) ; for ( int i = 0 , length = constants . length ; i < length ; i ++ ) { final T constant = constants [ i ] ; final String name = namer . apply ( constant ) ; byName . put ( name , constant ) ; byValue . put ( constant , name ) ; } return new NameMap <> ( Collections . unmodifiableMap ( byName ) , Collections . unmodifiableMap ( byValue ) ) ; }
Creates a name map .