You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are circumstances where we need the type expression for the alias (eg inside dynamics).
Possibly emit a java class for the type alias, but which only has static factory and jsonbinding methods.
For reference the workaround is a helper function like:
public static <T> JsonBinding<T> typeAliasJsonBinding(String moduleName, String typeAliasName, JsonBinding<T> jb) {
return new JsonBinding<T>() {
public Factory<T> factory() {
return new Factory<T>() {
@Override
public T create() {
return jb.factory().create();
}
@Override
public T create(T other) {
return jb.factory().create(other);
}
@Override
public TypeExpr typeExpr() {
return new TypeExpr(TypeRef.reference(new ScopedName(moduleName, typeAliasName)), new ArrayList<>(); }
};
}
@Override
public JsonElement toJson(T value) {
return jb.toJson(value);
}
@Override
public T fromJson(JsonElement json) {
return jb.fromJson(json);
}
};
}
The text was updated successfully, but these errors were encountered:
There are circumstances where we need the type expression for the alias (eg inside dynamics).
Possibly emit a java class for the type alias, but which only has static factory and jsonbinding methods.
For reference the workaround is a helper function like:
The text was updated successfully, but these errors were encountered: