Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法生成这样的字段:
public static final TypedKey<String> UM_USR = new TypedKey<String>() {};
我没有找到任何方法将 UM_USR 的类型设置为通用接口。
您需要使用 aParameterizedTypeName而不是简单的ClassName:
ParameterizedTypeName
ClassName
ParameterizedTypeName paramTypedKey = ParameterizedTypeName.get(ClassName.get(TypedKey.class), ClassName.get(String.class));