JPad
Snippets
Download
Help
Contact
Guava ImmutableBiMap Builder
Code
final ImmutableBiMap<String, Integer> WORD_TO_INT = new ImmutableBiMap.Builder<String, Integer>() .put("one", 1) .put("two", 2) .put("three", 3) .build(); Dump(WORD_TO_INT); Dump(WORD_TO_INT.get("one")); Dump("inverse = In Reverse"); Dump(WORD_TO_INT.inverse()); Dump(WORD_TO_INT.inverse().get(2));
Result
Console
{one=1, two=2, three=3} 1 inverse = In Reverse {1=one, 2=two, 3=three} two
Bytecode
Compiled from "RunnContainer.java" public class io.jpad.scratch.RunnContainer { public io.jpad.scratch.RunnContainer(); Code: 0: aload_0 1: invokespecial #1 // Method java/lang/Object."<init>":()V 4: return public static void main(java.lang.String...) throws java.lang.Exception; Code: 0: new #2 // class com/google/common/collect/ImmutableBiMap$Builder 3: dup 4: invokespecial #3 // Method com/google/common/collect/ImmutableBiMap$Builder."<init>":()V 7: ldc #4 // String one 9: iconst_1 10: invokestatic #5 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer; 13: invokevirtual #6 // Method com/google/common/collect/ImmutableBiMap$Builder.put:(Ljava/lang/Object;Ljava/lang/Object;)Lcom/google/common/collect/ImmutableBiMap$Builder; 16: ldc #7 // String two 18: iconst_2 19: invokestatic #5 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer; 22: invokevirtual #6 // Method com/google/common/collect/ImmutableBiMap$Builder.put:(Ljava/lang/Object;Ljava/lang/Object;)Lcom/google/common/collect/ImmutableBiMap$Builder; 25: ldc #8 // String three 27: iconst_3 28: invokestatic #5 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer; 31: invokevirtual #6 // Method com/google/common/collect/ImmutableBiMap$Builder.put:(Ljava/lang/Object;Ljava/lang/Object;)Lcom/google/common/collect/ImmutableBiMap$Builder; 34: invokevirtual #9 // Method com/google/common/collect/ImmutableBiMap$Builder.build:()Lcom/google/common/collect/ImmutableBiMap; 37: astore_1 38: aload_1 39: invokestatic #10 // Method io/jpad/scratch/Dumper.Dump:(Ljava/lang/Object;)Ljava/lang/Object; 42: pop 43: aload_1 44: ldc #4 // String one 46: invokevirtual #11 // Method com/google/common/collect/ImmutableBiMap.get:(Ljava/lang/Object;)Ljava/lang/Object; 49: invokestatic #10 // Method io/jpad/scratch/Dumper.Dump:(Ljava/lang/Object;)Ljava/lang/Object; 52: pop 53: ldc #12 // String inverse = In Reverse 55: invokestatic #10 // Method io/jpad/scratch/Dumper.Dump:(Ljava/lang/Object;)Ljava/lang/Object; 58: pop 59: aload_1 60: invokevirtual #13 // Method com/google/common/collect/ImmutableBiMap.inverse:()Lcom/google/common/collect/ImmutableBiMap; 63: invokestatic #10 // Method io/jpad/scratch/Dumper.Dump:(Ljava/lang/Object;)Ljava/lang/Object; 66: pop 67: aload_1 68: invokevirtual #13 // Method com/google/common/collect/ImmutableBiMap.inverse:()Lcom/google/common/collect/ImmutableBiMap; 71: iconst_2 72: invokestatic #5 // Method java/lang/Integer.valueOf:(I)Ljava/lang/Integer; 75: invokevirtual #11 // Method com/google/common/collect/ImmutableBiMap.get:(Ljava/lang/Object;)Ljava/lang/Object; 78: invokestatic #10 // Method io/jpad/scratch/Dumper.Dump:(Ljava/lang/Object;)Ljava/lang/Object; 81: pop 82: return }
Jpad Version:1.04
viewCount:4839
Creator:
admin
Latest Editor:
admin
Tags
ImmutableBiMap
guava
Download
Copy As Markdown:
**code [Guava ImmutableBiMap Builder.java](/example/1q/guava-immutablebimap-builder)** final ImmutableBiMap
WORD_TO_INT = new ImmutableBiMap.Builder
() .put("one", 1) .put("two", 2) .put("three", 3) .build(); Dump(WORD_TO_INT); Dump(WORD_TO_INT.get("one")); Dump("inverse = In Reverse"); Dump(WORD_TO_INT.inverse()); Dump(WORD_TO_INT.inverse().get(2)); **Result:** {one=1, two=2, three=3} 1 inverse = In Reverse {1=one, 2=two, 3=three} two