0

Is there any way to generate a field like this:

public static final TypedKey<String> UM_USR = new TypedKey<String>() {};

I didn't find any way to set the type of UM_USR to a generic interface.

LaaKii
  • 95
  • 11

1 Answers1

1

You need to use a ParameterizedTypeName instead of a simple ClassName :

ParameterizedTypeName paramTypedKey = ParameterizedTypeName.get(ClassName.get(TypedKey.class), ClassName.get(String.class));
Omar Aflak
  • 2,918
  • 21
  • 39