0

If I write bytebuddy code

.defineProperty("hm",TypeDescription.Generic.Builder.parameterizedType(HashMap.class, String.class, HashSet.class).build())

like this ,Then result is private HashMap<String, HashSet> hm;

but my requirement is private HashMap<String, HashSet<String>> hm;

Rafael Winterhalter
  • 42,759
  • 13
  • 108
  • 192

1 Answers1

0

The builder accepts Byte Buddy's TypeDefinitions just as much as type literals so you can simply nest the built types:

TypeDescription.Generic type = TypeDescription.Generic.Builder.parameterizedType(
  TypeDescription.ForLoadedType.of(HashMap.class),
  TypeDescription.Generic.Sort.describe(String.class),
  TypeDescription.Generic.Builder.parameterizedType(HashSet.class, String.class).build()
).build();
Rafael Winterhalter
  • 42,759
  • 13
  • 108
  • 192