Why aren't static methods available in Google Cloud Endpoints client libraries in my models?

I have the following Entity as a return value for one of my endpoints. When I create client libraries it seems to ignore static methods, which leaves Player.key () inaccessible. I can't find any documentation anywhere that explains what will be allowed or removed from client libraries, so I'm trying to figure it out, but some framework to understand other than trial and error would be helpful.

@Entity
public class Player {
  public static final String PLAYER = "Player";
  public static final String UUID = "uuid";
  public static final String NAME = "name";

  @Id
  String uuid;

  String name;

  public String getUuid() {
    return uuid;
  }

  public void setUuid(String uuid) {
    this.uuid = uuid;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public static Key key(String uuid) {
    return KeyFactory.createKey(PLAYER, uuid);
  }
}

      

If I rewrite the methods like this, it works:

  public Key key(String uuid) {
    return KeyFactory.createKey(PLAYER, uuid);
  }

      

But this requires me to do stupid things in my client code that I would like to avoid:

Key playerKey = new Player().key(uuid);

      

I apparently cannot write this method in a separate client-side class because I don't have access to the appengine SDK.

+3


source to share


1 answer


The generated client libraries are mainly for modeling your data, not supporting helper methods. You can include these utilities in another library if you need them. I'm not sure if the non-static version of the method does what you want on the client side, if the syntax works, because the client libraries don't copy objects or their dependencies.



+1


source







All Articles