Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cloud Endpoints Collection Parameter

Im using Google App Engine Cloud Endpoints and Im trying to receive a collection parameter . Not sure if I can do this. I know I can return a List or any Collection.

This:

   public List<Pair> initializationSetup(Pair pPair){}

Works fine, but If I try to receive a list of pairs, the .api file is not created.

   public List<Pair> initializationSetup(List<Pair> pPairs){

Thanks

like image 200
davibq Avatar asked Feb 07 '13 23:02

davibq


2 Answers

Cloud Endpoints only deals with classes having the bean standard.

So, I created a new class named ObjectListContainer:

public class ObjectListContainer {
    public List<Object> getObjectsList() {
        return ObjectsList;
    }
    public void setObjectsList(List<Object> objectsList) {
        ObjectsList = objectsList;
    }
    private List<Object> ObjectsList;
}

Same problem if you are trying to return a String, you can't. You have to make a StringContainer.

like image 70
davibq Avatar answered Oct 16 '22 16:10

davibq


I have used a similar solution after think during long hours . Try this:

public class JsonList<T> { 
private List<T> listItens;

public List<T> getListItens() {
    return listItens;
}

public void setListItens(List<T> listItens) {
    this.listItens = listItens;
}}

and in your method:

@ApiMethod(
        name = "name",
        path = "path",
        httpMethod = ApiMethod.HttpMethod.POST)
public CollectionResponse<Information> getInformation(JsonList<String> listOfItens) {}
like image 44
Jeferson Oliveira Fernande Avatar answered Oct 16 '22 15:10

Jeferson Oliveira Fernande