ApiTransformer for a parameterized, inaccessible type

I am using Objectify and want to have the Key <> type passed in my API. I created ApiTransformer, but my questions are the declaration, because the serialized Key <> class is not available, so I cannot declare its transformer as a class annotation. I tried to declare it in the @Api annotation, but it does not work, I still get the error message:

There was a problem generating the API metadata for your Cloud Endpoints classes: java.lang.IllegalArgumentException: Parameterized type com.googlecode.objectify.Key<[my package].User> not supported. 

ApiTransformer looks like this:

public class KeyTransformer implements Transformer<Key<?>, String> {

  public String transformTo(Key<?> in) {
    return in.getString();
  }

  public Key<?> transformFrom(String in) {
    return Key.valueOf(in);
  }

}

And in my @Api I:

@Api(name = "users", version = "v1",transformers = {KeyTransformer.class})
+4
source share
2 answers

Sorry, you can’t. As you said, you need to declare it in the Key class, your chances of doing this job too.

1) Key @transformer.

2) Key .

- , , - ( @ApiResourceProperty(ignored=AnnotationBoolean.TRUE)) .

Endpoints frendly, , , Key.create(YourClass.class, longId) , .

+2

Source: https://habr.com/ru/post/1534307/


All Articles