Guava EnumBiMap - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Guava EnumBiMap class.

This code example shows how to use the following methods:put
        bean.enumHashBiMap.put( AlphaEnum.D, 4 );
        bean.enumHashBiMap.put( AlphaEnum.C, 3 );
        bean.enumHashBiMap.put( AlphaEnum.B, 2 );
 
        bean.enumBiMap = EnumBiMap.create( AlphaEnum.class, NumericEnum.class );
        bean.enumBiMap.put( AlphaEnum.A, NumericEnum.ONE );
        bean.enumBiMap.put( AlphaEnum.D, NumericEnum.FOUR );
        bean.enumBiMap.put( AlphaEnum.C, NumericEnum.THREE );
        bean.enumBiMap.put( AlphaEnum.B, NumericEnum.TWO );
 
        String expected = "{" +
                "\"biMap\":{\"one\":1}," + 
                "\"hashBiMap\":{\"one\":1}," + 
                "\"enumHashBiMap\":{\"A\":1,\"B\":2,\"C\":3,\"D\":4}," + 
                "\"enumBiMap\":{\"A\":\"ONE\",\"B\":\"TWO\",\"C\":\"THREE\",\"D\":\"FOUR\"}" + 
                "}"; 
 
        assertEquals( expected, BeanWithBiMapTypesMapper.INSTANCE.write( bean ) );
    } 
 
4
CodeRank